commit ff0de4b8651354673a5e2dc97c1b78cf7c353651
Author: Michael Verde <mverde@agilebits.com>
Date:   Sat Nov 4 11:40:04 2017 -0700

    Updated CredentialClient to utilize ProviderResolver methods (#143)
    
    * Updated CredentialClient to utilize ProviderResolver methods
    
    * Fixed import order to pass checkstyle

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index a326437..3528e7a 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -33,3 +33,2 @@ import android.content.Context;
 import android.content.Intent;
-import android.content.pm.ResolveInfo;
 import android.support.annotation.NonNull;
@@ -46,2 +45,3 @@ import org.openyolo.api.internal.KnownProviders;
 import org.openyolo.api.internal.ProviderPickerActivity;
+import org.openyolo.api.internal.ProviderResolver;
 import org.openyolo.api.persistence.AppSettings;
@@ -61,656 +61,641 @@ import org.openyolo.protocol.MalformedDataException;
 /**
  * The primary way of interacting with OpenYOLO credential providers. The client is light weight
  * allowing new instances to be created as needed.
  *
  * Requests are executed by starting an Activity based intent and its result returned via
  * {@link android.app.Activity#onActivityResult(int, int, Intent)}. For each request/response pair
  * there exist two client methods:
  * 1) Takes a given request and returns the Activity Intent which sends the request.
  * 2) Takes an Intent returned via {@link android.app.Activity#onActivityResult(int, int, Intent)}
  *    and returns the associated result.
  *
  * For example using the retrieve credential flow:
  * <pre>{@code
  * CredentialClient client = CredentialClient.getInstance(getContext());
  * // ...
  *
  * CredentialRetrieveRequest request  =
  *     CredentialRetrieveRequest.fromAuthMethods(
  *         AuthenticationMethods.EMAIL,
  *         AuthenticationMethods.GOOGLE);
  * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
  * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
  *
  * // ...
  * @Override
  * public void onActivityResult(int requestCode, int resultCode, Intent data) {
  *     super.onActivityResult(requestCode, resultCode, data);
  *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
  *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
  *        // handle result ...
  *     }
  * }
  * }</pre>
  *
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#operations">
  *     OpenYOLO Specification: Operations</a>
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private final Context mApplicationContext;
     private final AppSettings mDeviceState;
 
     /**
      * Returns a new credential client instance configured with the default options.
      */
     public static CredentialClient getInstance(@NonNull Context context) {
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(AppSettingsImpl.getInstance(context)).build();
 
         return getInstance(context, options);
     }
 
     /**
      * Returns a new credential client instance configured with the given
      * {@link CredentialClientOptions}.
      */
     public static CredentialClient getInstance(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         return new CredentialClient(context, options);
     }
 
     @VisibleForTesting
     CredentialClient(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         validate(context, notNullValue(), NullPointerException.class);
         validate(options, notNullValue(), NullPointerException.class);
 
         mApplicationContext = context.getApplicationContext();
         mDeviceState = options.getDeviceState();
     }
 
     /**
      * Provides an Activity intent to request any available {@link Credential credentials} from the
      * credential providers on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getCredentialRetrieveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * // ...
      *
      * CredentialRetrieveRequest request  =
      *     CredentialRetrieveRequest.fromAuthMethods(
      *         AuthenticationMethods.EMAIL,
      *         AuthenticationMethods.GOOGLE);
      * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
      * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
      *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getCredentialRetrieveResult(Intent)
      */
     @NonNull
     public Intent getCredentialRetrieveIntent(CredentialRetrieveRequest request) {
         if (mDeviceState.isAutoSignInDisabled()) {
             request = new CredentialRetrieveRequest.Builder(request)
                     .setRequireUserMediation(true)
                     .build();
         }
 
         return CredentialRetrieveActivity.createIntent(mApplicationContext, request);
     }
 
     /**
      * Provides an Activity intent to request any available {@link org.openyolo.protocol.Hint hints}
      * from the credential providers on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getHintRetrieveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * // ...
      *
      * HintRetrieveRequest request  =
      *     HintRetrieveRequest.fromAuthMethods(
      *         AuthenticationMethods.EMAIL,
      *         AuthenticationMethods.GOOGLE);
      * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
      * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_HINT == requestCode) {
      *        HintRetrieveResult result = client.getHintRetrieveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getHintRetrieveResult(Intent)
      */
     @NonNull
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
-        List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
+        List<ComponentName> hintProviders =
+                ProviderResolver.findProviders(mApplicationContext, HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE,
                     HintRetrieveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Creates a {@link CredentialSaveRequest request} from the given credential.
      *
      * @see #getSaveIntent(Credential)
      */
     @NonNull
     public Intent getSaveIntent(final Credential credential) {
         return getSaveIntent(CredentialSaveRequest.fromCredential(credential));
     }
 
     /**
      * Provides an Activity intent to save the provided credential.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getCredentialSaveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * Credential credential = <Valid Credential>;
      * // ...
      *
      * CredentialSaveRequest request  = CredentialSaveRequest.fromCredential(credential);
      * Intent saveCredentialIntent = client.getSaveIntent(request);
      * startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_SAVE_CREDENTIAL == requestCode) {
      *        CredentialSaveResult result = client.getCredentialSaveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getCredentialSaveResult(Intent)
      */
     @NonNull
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
-        List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
+        List<ComponentName> saveProviders =
+                ProviderResolver.findProviders(mApplicationContext, SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     CredentialSaveResult.CODE_NO_PROVIDER_AVAILABLE,
                     CredentialSaveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Creates a {@link CredentialDeleteRequest request} from the given credential.
      *
      * @see #getDeleteIntent(CredentialDeleteRequest)
      */
     @NonNull
     public Intent getDeleteIntent(@NonNull Credential credential) {
         require(credential, notNullValue());
 
         return getDeleteIntent(CredentialDeleteRequest.fromCredential(credential));
     }
 
     /**
      * Provides an Activity intent to delete the given {@link Credential credential} from the
      * credential provider on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getCredentialDeleteResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * Credential credential = <Credential that is no longer valid>;
      * // ...
      *
      * Intent deleteCredentialIntent = client.getDeleteIntent(request);
      * startActivityForResult(deleteCredentialIntent, RC_DELETE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_DELETE_CREDENTIAL == requestCode) {
      *         result = client.getCredentialDeleteResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getCredentialDeleteResult(Intent)
      */
     @NonNull
     public Intent getDeleteIntent(@NonNull CredentialDeleteRequest request) {
         require(request, notNullValue());
 
         List<ComponentName> deleteProviders =
-                findProviders(DELETE_CREDENTIAL_ACTION);
+                ProviderResolver.findProviders(mApplicationContext, DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     CredentialDeleteResult.CODE_NO_PROVIDER_AVAILABLE,
                     CredentialDeleteResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Returns the result of a {@link CredentialRetrieveResult}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
      *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
      *        if (result.isSuccessful()) {
      *          // A credential was retrieved, you may automatically sign the user in.
      *          result.getCredential();
      *        } else {
      *          // A credential was not retrieved, you may look at the result code to determine why
      *          // and decide what step to take next. For example, result code may inform you of the
      *          // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
      *          result.getResultCode();
      *        }
      *     }
      * }
      * }</pre>
      *
      *
      * @see #getCredentialRetrieveIntent(CredentialRetrieveRequest)
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return CredentialRetrieveResult.UNKNOWN;
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return CredentialRetrieveResult.UNKNOWN;
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return CredentialRetrieveResult.UNKNOWN;
         }
 
         try {
             CredentialRetrieveResult result =
                     CredentialRetrieveResult.fromProtobufBytes(resultBytes);
 
             // Once a successfully retrieve result has been handled, re-enable auto sign-in.
             if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
                 mDeviceState.setIsAutoSignInDisabled(false);
             }
 
             return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return CredentialRetrieveResult.UNKNOWN;
         }
     }
 
     /**
      * Returns the result of a {@link HintRetrieveResult}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_HINT == requestCode) {
      *        HintRetrieveResult result = client.getHintRetrieveResult(data);
      *        if (result.isSuccessful()) {
      *          // A hint was retrieved, you may be able to automatically create an account for the
      *          // user, or offer the user to sign in if an existing account matches the hint.
      *          result.getHint();
      *        } else {
      *          // A credential was not retrieved, you may look at the result code to determine why
      *          // and decide what step to take next. For example, result code may inform you of the
      *          // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
      *          result.getResultCode();
      *        }
      *     }
      * }
      * }</pre>
      *
      * @see #getHintRetrieveIntent(HintRetrieveRequest)
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return HintRetrieveResult.UNKNOWN;
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return HintRetrieveResult.UNKNOWN;
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return HintRetrieveResult.UNKNOWN;
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return HintRetrieveResult.UNKNOWN;
         }
     }
 
     /**
      * Returns the result of a {@link CredentialSaveRequest}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_SAVE_CREDENTIAL == requestCode) {
      *        CredentialSaveResult result = client.getCredentialSaveResult(data);
      *        // Most people will not need to check the result of a save request. Simply fire and
      *        // forget.
      *     }
      * }
      * }</pre>
      *
      * @see #getSaveIntent(CredentialSaveRequest)
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return CredentialSaveResult.UNKNOWN;
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return CredentialSaveResult.UNKNOWN;
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return CredentialSaveResult.UNKNOWN;
         }
     }
 
     /**
      * Returns the result of a {@link CredentialDeleteRequest}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_DELETE_CREDENTIAL == requestCode) {
      *        CredentialSaveResult result = client.getCredentialSaveResult(data);
      *        // Most people will not need to check the result of a delete request. Simply fire and
      *        // forget.
      *     }
      * }
      * }</pre>
      *
      * @see #getDeleteIntent(CredentialDeleteRequest)
      */
     @NonNull
     public CredentialDeleteResult getCredentialDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     /**
      * Disables automatically signing in a user until a successful response is given to
      * {@link CredentialClient#getCredentialRetrieveResult(Intent)}. Instead a user is required to
      * interact with the providers (e.g. click the credential they would like to sign in) before a
      * credential is returned.
      *
      * This feature allows clients to easily avoid a common case where a user signs out and is then
      * automatically signed back in. By calling this method when a user is signed out no additional
      * logic to track the user's intention is required.
      * <pre>{@code
      *
      * // ...
      * public void signOutUser() {
      *     // Your application's custom sign out logic.
      *     // ...
      *     CredentialClient client = CredentialClient.getInstance(getContext());
      *     client.disableAutoSignIn();
      * }
      * }</pre>
      */
     public void disableAutoSignIn() {
         mDeviceState.setIsAutoSignInDisabled(true);
     }
 
-    private List<ComponentName> findProviders(@NonNull String action) {
-        Intent saveIntent = new Intent(action);
-        saveIntent.addCategory(OPENYOLO_CATEGORY);
-
-        List<ResolveInfo> resolveInfos =
-                mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
-
-        ArrayList<ComponentName> responders = new ArrayList<>();
-        for (ResolveInfo info : resolveInfos) {
-            responders.add(new ComponentName(
-                    info.activityInfo.packageName,
-                    info.activityInfo.name));
-        }
-
-        return responders;
-    }
-
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 }

commit 49e61170ba5462ec58dbb06b2b688fe12c857328
Author: Stan Kocken <stan.kocken@gmail.com>
Date:   Fri Nov 3 12:06:57 2017 +0100

    Added demo application “simplest” (#154)
    
    * Added demo application “simplest”
    
    A very simple demo application of OpenYolo API

diff --git a/api/README.md b/api/README.md
index 6e89de6..3797e48 100644
--- a/api/README.md
+++ b/api/README.md
@@ -89,20 +89,21 @@ user wants to branch away from assisted account creation are:
 ```java
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);
     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+       CredentialClient client = CredentialClient.getInstance(this);
        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
        if (result.isSuccessful()) {
            // A credential was retrieved, you may automatically sign the user in.
            result.getCredential();
        } else {
            // A credential was not retrieved, you may look at the result code to determine why
            // and decide what step to take next. For example, result code may inform you of the
            // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
            result.getResultCode();
        }
     }
 }
 ```
 
 ### Account Creation
@@ -121,3 +122,3 @@ HintRetrieveRequest request  =
 Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
-startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
+startActivityForResult(retrieveHintIntent, RC_RETRIEVE_HINT);
 ```
@@ -140,20 +141,21 @@ Once the account has been created you should save the credential for future retr
 ```java
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);
     if (RC_RETRIEVE_HINT == requestCode) {
+       CredentialClient client = CredentialClient.getInstance(this);
        HintRetrieveResult result = client.getHintRetrieveResult(data);
        if (result.isSuccessful()) {
          // A hint was retrieved, you may be able to automatically create an account for the
          // user, or offer the user to sign in if an existing account matches the hint.
          result.getHint();
        } else {
          // A credential was not retrieved, you may look at the result code to determine why
          // and decide what step to take next. For example, result code may inform you of the
          // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
          result.getResultCode();
        }
     }
 }
 ```
 
 ### Saving Valid Credentials
@@ -163,11 +165,13 @@ is created) it is recommended that you save the new or updated credential to ena
 automatic sign-in experience.
 
 ```java
+CredentialClient client = CredentialClient.getInstance(getContext());
 // Craft the valid credential.
-String identifer = "joe@gmail.com";
+String identifier = "joe@gmail.com";
 AuthenticationMethod authMethod = AuthenticationMethods.EMAIL;
 AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(this);
-Credential credential = new Credential.Builder(identifier, authMethod, authDomain).build();
-
+Credential credential = new Credential.Builder(identifier, authMethod, authDomain)
+                                         .setPassword(password)
+                                         .build();
 // Or if you have created an account using a hint there is a utility method that will convert the
 // hint into a new Credential.Builder.
diff --git a/api/proguard-rules.txt b/api/proguard-rules.txt
index bdd2a5b..0d5fbc5 100644
--- a/api/proguard-rules.txt
+++ b/api/proguard-rules.txt
@@ -1,11 +1,14 @@
 # it is safe to ignore the resources ids from OpenYOLO api. Without this flag we have issue with picker_title, provider_list
 -dontwarn org.openyolo.api.R$id
 
 # valid4j use reflection to inject Providers and Policy
 -keep class org.valid4j.** { *; }
 
 # it is safe to ignore okio warnings
 -dontwarn okio.**
 
 # Hamcrest reflection
--keep class org.hamcrest.** { *; }
\ No newline at end of file
+-keep class org.hamcrest.** { *; }
+
+# Used by com.google.protobuf.UnsafeUtil
+-dontwarn sun.misc.Unsafe
\ No newline at end of file
diff --git a/demoapps/simplest/build.gradle b/demoapps/simplest/build.gradle
new file mode 100644
index 0000000..5086b29
--- /dev/null
+++ b/demoapps/simplest/build.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'com.android.application'
+apply plugin: 'checkstyle'
+
+android {
+    compileSdkVersion rootProject.ext.compileSdkVersion
+    buildToolsVersion rootProject.ext.buildToolsVersion
+
+    defaultConfig {
+        applicationId 'org.openyolo.demoapp.simplest'
+        project.archivesBaseName = 'openyolo-demoapp-simplest'
+        minSdkVersion rootProject.ext.minSdkVersion
+        targetSdkVersion rootProject.ext.compileSdkVersion
+        versionCode rootProject.ext.versionNum
+        versionName rootProject.ext.versionName
+    }
+
+    lintOptions {
+        warningsAsErrors true
+        disable 'GradleDependency'
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt')
+        }
+    }
+}
+
+dependencies {
+    implementation project(':api')
+
+    implementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    implementation "com.android.support:design:${rootProject.supportLibVersion}"
+
+    apply from: "${rootDir}/config/testdeps.gradle", to: it
+}
+
+apply from: "${rootDir}/config/style.gradle"
\ No newline at end of file
diff --git a/demoapps/simplest/src/main/AndroidManifest.xml b/demoapps/simplest/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a052335
--- /dev/null
+++ b/demoapps/simplest/src/main/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="org.openyolo.demoapp.simplest">
+
+    <application
+        android:allowBackup="true"
+        android:fullBackupContent="false"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+        <activity android:name=".MainActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:name=".CreateAccountActivity"
+            android:label="@string/sign_up_button"/>
+        <activity
+            android:name=".LoginActivity"
+            android:label="@string/sign_in_button"/>
+        <activity android:name=".LoggedInActivity">
+        </activity>
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/CreateAccountActivity.java b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/CreateAccountActivity.java
new file mode 100644
index 0000000..f30d261
--- /dev/null
+++ b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/CreateAccountActivity.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openyolo.demoapp.simplest;
+
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+
+import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Hint;
+import org.openyolo.protocol.HintRetrieveRequest;
+import org.openyolo.protocol.HintRetrieveResult;
+
+public class CreateAccountActivity extends AppCompatActivity {
+
+    private static final int RC_RETRIEVE_HINT = 324;
+
+    private EditText mUsernameEditText;
+    private EditText mPasswordEditText;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_create_account);
+
+        mUsernameEditText = findViewById(R.id.username_edittext);
+        mPasswordEditText = findViewById(R.id.password_edittext);
+
+        if (savedInstanceState == null) {
+            // only on first launch
+            startActivityForHintResult();
+        }
+    }
+
+    public void onClickCreateAccount(View view) {
+        String username = mUsernameEditText.getText().toString();
+        String password = mPasswordEditText.getText().toString();
+
+        // in your client application, store the credential here
+
+        startActivity(new Intent(this, LoggedInActivity.class));
+        finish();
+
+        // call OpenYolo provider to save the credential
+        new SaveInOpenYoloUtil().save(this, username, password);
+    }
+
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (RC_RETRIEVE_HINT == requestCode) {
+            // receive an hint from an OpenYolo provider
+            CredentialClient client = CredentialClient.getInstance(this);
+            HintRetrieveResult result = client.getHintRetrieveResult(data);
+            Hint hint = result.getHint();
+            if (result.isSuccessful() && hint != null) {
+                // A hint was retrieved, you may be able to automatically create an account for the
+                // user, or offer the user to sign in if an existing account matches the hint.
+                mUsernameEditText.setText(hint.getIdentifier());
+                mPasswordEditText.setText(hint.getGeneratedPassword());
+            }
+        }
+    }
+
+    private void startActivityForHintResult() {
+        // request some hints for the account creation
+        CredentialClient client = CredentialClient.getInstance(this);
+
+        HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
+                AuthenticationMethods.EMAIL, AuthenticationMethods.USER_NAME);
+        Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
+        startActivityForResult(retrieveHintIntent, RC_RETRIEVE_HINT);
+    }
+}
diff --git a/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/LoggedInActivity.java b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/LoggedInActivity.java
new file mode 100644
index 0000000..2fc727b
--- /dev/null
+++ b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/LoggedInActivity.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openyolo.demoapp.simplest;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+
+public class LoggedInActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_logged_in);
+    }
+}
diff --git a/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/LoginActivity.java b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/LoginActivity.java
new file mode 100644
index 0000000..48a06b1
--- /dev/null
+++ b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/LoginActivity.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openyolo.demoapp.simplest;
+
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
+
+public class LoginActivity extends AppCompatActivity {
+
+    private static final int RC_RETRIEVE_CREDENTIAL = 234;
+    private EditText mUsernameEditText;
+    private EditText mPasswordEditText;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_login);
+
+        mUsernameEditText = findViewById(R.id.username_edittext);
+        mPasswordEditText = findViewById(R.id.password_edittext);
+
+        if (savedInstanceState == null) {
+            // only on first launch
+            startActivityForCredentialResult();
+        }
+    }
+
+    public void onClickLogin(View view) {
+        // clicked on the login button
+        loginWith(mUsernameEditText.toString(), mPasswordEditText.toString());
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+            CredentialClient client = CredentialClient.getInstance(this);
+            CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
+            Credential credential = result.getCredential();
+            if (result.isSuccessful() && credential != null) {
+                // A credential was retrieved, automatically sign the user in.
+                String username = credential.getIdentifier();
+                String password = credential.getPassword();
+                mUsernameEditText.setText(username);
+                mPasswordEditText.setText(password);
+                loginWith(username, password);
+            }
+        }
+    }
+
+    private void loginWith(String username, String password) {
+        if (validateCredentialWithBackend()) {
+            startActivity(new Intent(this, LoggedInActivity.class));
+            finish();
+
+            // call OpenYolo provider to save the credential
+            new SaveInOpenYoloUtil().save(this, username, password);
+        } else {
+            Toast.makeText(this, R.string.invalid_credentials, Toast.LENGTH_LONG).show();
+        }
+    }
+
+    private void startActivityForCredentialResult() {
+        // request credential from open yolo providers
+        CredentialClient client = CredentialClient.getInstance(this);
+
+        CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(
+                AuthenticationMethods.EMAIL, AuthenticationMethods.USER_NAME);
+        Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
+        startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
+    }
+
+    private boolean validateCredentialWithBackend() {
+        // do the validation of the credential here
+        return true;
+    }
+}
diff --git a/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/MainActivity.java b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/MainActivity.java
new file mode 100644
index 0000000..61c682a
--- /dev/null
+++ b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/MainActivity.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openyolo.demoapp.simplest;
+
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+
+public class MainActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+    }
+
+    public void onClickSignIn(View view) {
+        startActivity(new Intent(this, LoginActivity.class));
+    }
+
+    public void onClickSignUp(View view) {
+        startActivity(new Intent(this, CreateAccountActivity.class));
+    }
+}
diff --git a/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/SaveInOpenYoloUtil.java b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/SaveInOpenYoloUtil.java
new file mode 100644
index 0000000..88aeb31
--- /dev/null
+++ b/demoapps/simplest/src/main/java/org/openyolo/demoapp/simplest/SaveInOpenYoloUtil.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openyolo.demoapp.simplest;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.util.Patterns;
+
+import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethod;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Credential;
+
+class SaveInOpenYoloUtil {
+
+    private static final int RC_SAVE_CREDENTIAL = 754;
+
+    void save(Activity activity, String identifier, String password) {
+        // Craft the valid credential.
+        AuthenticationMethod authMethod = isEmail(identifier) ?
+                AuthenticationMethods.EMAIL :  AuthenticationMethods.USER_NAME;
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(activity);
+        Credential credential = new Credential.Builder(identifier, authMethod, authDomain)
+                .setPassword(password)
+                .build();
+
+        // Send the request. It is safe to ignore the result.
+        CredentialClient client = CredentialClient.getInstance(activity);
+        Intent saveCredentialIntent = client.getSaveIntent(credential);
+        activity.startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
+    }
+
+    private boolean isEmail(String identifier) {
+        return Patterns.EMAIL_ADDRESS.matcher(identifier).find();
+    }
+}
diff --git a/demoapps/simplest/src/main/res/layout/activity_create_account.xml b/demoapps/simplest/src/main/res/layout/activity_create_account.xml
new file mode 100644
index 0000000..60b5a87
--- /dev/null
+++ b/demoapps/simplest/src/main/res/layout/activity_create_account.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:padding="16dp"
+    android:importantForAutofill="noExcludeDescendants"
+    tools:context="org.openyolo.demoapp.simplest.CreateAccountActivity"
+    tools:ignore="UnusedAttribute">
+
+    <android.support.design.widget.TextInputLayout
+        android:layout_width="250dp"
+        android:layout_height="wrap_content"
+        app:passwordToggleEnabled="true"
+        app:passwordToggleTint="@color/colorAccent">
+
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/username_edittext"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:hint="@string/username_hint"
+            android:inputType="text"/>
+    </android.support.design.widget.TextInputLayout>
+
+    <android.support.design.widget.TextInputLayout
+        android:layout_width="250dp"
+        android:layout_height="wrap_content"
+        app:passwordToggleEnabled="true"
+        app:passwordToggleTint="@color/colorAccent">
+
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/password_edittext"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:hint="@string/password_hint"
+            android:inputType="textPassword"/>
+    </android.support.design.widget.TextInputLayout>
+
+    <Button
+        android:layout_width="200dp"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:onClick="onClickCreateAccount"
+        android:text="@string/create_the_account_btn"/>
+
+</LinearLayout>
diff --git a/demoapps/simplest/src/main/res/layout/activity_logged_in.xml b/demoapps/simplest/src/main/res/layout/activity_logged_in.xml
new file mode 100644
index 0000000..4fa1678
--- /dev/null
+++ b/demoapps/simplest/src/main/res/layout/activity_logged_in.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:text="@string/logged_in_label"
+    android:padding="16dp"
+    tools:context="org.openyolo.demoapp.simplest.LoggedInActivity"
+    />
diff --git a/demoapps/simplest/src/main/res/layout/activity_login.xml b/demoapps/simplest/src/main/res/layout/activity_login.xml
new file mode 100644
index 0000000..4e1f0ea
--- /dev/null
+++ b/demoapps/simplest/src/main/res/layout/activity_login.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:padding="16dp"
+    android:importantForAutofill="noExcludeDescendants"
+    tools:context="org.openyolo.demoapp.simplest.LoginActivity"
+    tools:ignore="UnusedAttribute">
+
+    <android.support.design.widget.TextInputLayout
+        android:layout_width="250dp"
+        android:layout_height="wrap_content"
+        app:passwordToggleEnabled="true"
+        app:passwordToggleTint="@color/colorAccent">
+
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/username_edittext"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:hint="@string/username_hint"
+            android:inputType="text"/>
+    </android.support.design.widget.TextInputLayout>
+
+    <android.support.design.widget.TextInputLayout
+        android:layout_width="250dp"
+        android:layout_height="wrap_content"
+        app:passwordToggleEnabled="true"
+        app:passwordToggleTint="@color/colorAccent">
+
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/password_edittext"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:hint="@string/password_hint"
+            android:inputType="textPassword"/>
+    </android.support.design.widget.TextInputLayout>
+
+    <Button
+        android:layout_width="200dp"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:onClick="onClickLogin"
+        android:text="@string/login_btn"/>
+
+</LinearLayout>
diff --git a/demoapps/simplest/src/main/res/layout/activity_main.xml b/demoapps/simplest/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..f82795f
--- /dev/null
+++ b/demoapps/simplest/src/main/res/layout/activity_main.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    tools:context="org.openyolo.demoapp.simplest.MainActivity">
+
+    <TextView
+        android:text="@string/welcome_label"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="16dp"/>
+
+    <Button
+        android:text="@string/sign_in_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="onClickSignIn"
+        android:layout_margin="16dp"/>
+
+    <Button
+        android:text="@string/sign_up_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="onClickSignUp"
+        android:layout_margin="16dp"/>
+
+</LinearLayout>
diff --git a/demoapps/simplest/src/main/res/mipmap-hdpi/ic_launcher.png b/demoapps/simplest/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..a2f5908
Binary files /dev/null and b/demoapps/simplest/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/demoapps/simplest/src/main/res/mipmap-mdpi/ic_launcher.png b/demoapps/simplest/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..ff10afd
Binary files /dev/null and b/demoapps/simplest/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/demoapps/simplest/src/main/res/mipmap-xhdpi/ic_launcher.png b/demoapps/simplest/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..dcd3cd8
Binary files /dev/null and b/demoapps/simplest/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/demoapps/simplest/src/main/res/mipmap-xxhdpi/ic_launcher.png b/demoapps/simplest/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..8ca12fe
Binary files /dev/null and b/demoapps/simplest/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/demoapps/simplest/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/demoapps/simplest/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b824ebd
Binary files /dev/null and b/demoapps/simplest/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/demoapps/simplest/src/main/res/values/colors.xml b/demoapps/simplest/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/demoapps/simplest/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimaryDark">#303F9F</color>
+    <color name="colorAccent">#FF4081</color>
+</resources>
diff --git a/demoapps/simplest/src/main/res/values/strings.xml b/demoapps/simplest/src/main/res/values/strings.xml
new file mode 100644
index 0000000..8c4ca48
--- /dev/null
+++ b/demoapps/simplest/src/main/res/values/strings.xml
@@ -0,0 +1,12 @@
+<resources>
+    <string name="app_name">OpenYolo Simplest</string>
+    <string name="welcome_label">Demo of OpenYolo login/password authentication into a very simple application</string>
+    <string name="sign_in_button">I have an account</string>
+    <string name="sign_up_button">Create an account</string>
+    <string name="username_hint">Username or Email</string>
+    <string name="password_hint">Password</string>
+    <string name="login_btn">Login</string>
+    <string name="create_the_account_btn">Create the account</string>
+    <string name="logged_in_label">You are logged in!</string>
+    <string name="invalid_credentials">Either the login or the password is incorrect</string>
+</resources>
diff --git a/demoapps/simplest/src/main/res/values/styles.xml b/demoapps/simplest/src/main/res/values/styles.xml
new file mode 100644
index 0000000..5885930
--- /dev/null
+++ b/demoapps/simplest/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
+    </style>
+
+</resources>
diff --git a/settings.gradle b/settings.gradle
index fa0376a..31b8133 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1,9 @@
-include ':bbq', ':protocol', ':api', ':spi', ':testapp', ':demoproviders:barbican', ':demoproviders:trapdoor', ':demoapps:passwordlogin'
+include ':bbq'
+include ':protocol'
+include ':api'
+include ':spi'
+include ':testapp'
+include ':demoproviders:barbican'
+include ':demoproviders:trapdoor'
+include ':demoapps:passwordlogin'
+include ':demoapps:simplest'

commit a2972c690b71962492d7303922b077b2a684d33d
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Tue Oct 31 20:19:42 2017 +0000

    Fix minor issues in password login demo app (#153)

diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java
index b32ed7e..9485798 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java
@@ -18,29 +18,41 @@ import android.databinding.BindingAdapter;
 import android.support.design.widget.TextInputLayout;
+import android.widget.EditText;
 import android.widget.ImageView;
+import android.widget.TextView;
 
 /**
  * Android data binding extensions which make facilitate binding to more advanced field types.
  */
 public final class DataBindingAdapters {
 
     private DataBindingAdapters() {}
 
     /**
      * Facilitates loading images into an ImageView using Glide, by binding a string URI.
      */
     @BindingAdapter("android:src")
     public static void setImageUri(ImageView view, String imageUri) {
         GlideApp.with(view)
                 .load(imageUri)
                 .fitCenter()
                 .into(view);
     }
 
     /**
      * Facilitates binding error text to a TextInputLayout.
      */
     @BindingAdapter("errorText")
     public static void setErrorText(TextInputLayout layout, String errorText) {
         layout.setError(errorText);
     }
+
+    /**
+     * Facilitates binding editor action listeners on EditText fields.
+     */
+    @BindingAdapter("onEditorAction")
+    public static void setOnEditorActionListener(
+            EditText layout,
+            TextView.OnEditorActionListener listener) {
+        layout.setOnEditorActionListener(listener);
+    }
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index d40e598..d1db5ae 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -29,2 +29,3 @@ import android.support.annotation.StringRes;
 import android.support.annotation.WorkerThread;
+import android.util.Base64;
 import android.util.Log;
@@ -32,3 +33,7 @@ import android.util.Patterns;
 import android.view.View;
+import android.widget.TextView;
 import java.lang.ref.WeakReference;
+import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.concurrent.ScheduledExecutorService;
@@ -50,445 +55,466 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
-    private static final int MIN_PASSWORD_LENGTH = 4;
-
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
     public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
     public final ObservableBoolean showError = new ObservableBoolean(false);
 
+    /**
+     * Listener for IME action events on the email and password fields.
+     */
+    public final TextView.OnEditorActionListener editorActionListener =
+            (view, actionId, event) -> {
+                processAction(view);
+                return true;
+            };
+
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
     private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
         mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
         mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
             mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
      * Initiates an OpenYOLO credential retrieval request.
      */
     private void tryRetrieveExistingCredential() {
         setShowLoading(R.string.existing_account_search_prompt);
         Intent intent =
                 mCredentialClient.getCredentialRetrieveIntent(
                         CredentialRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL));
         mNavigator.get().startOpenYoloRetrieve(intent);
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
                 boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
                         credential.getPassword());
                 if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
+            case CredentialRetrieveResult.CODE_NO_PROVIDER_AVAILABLE:
+                Log.i(TAG, "No OpenYOLO providers available");
+                break;
+            case CredentialRetrieveResult.CODE_PROVIDER_TIMEOUT:
+                Log.i(TAG, "Provider failed to response in a timely manner");
+                break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL));
 
         if (hintIntent != null) {
             setShowLoading(R.string.requesting_hint_prompt);
             mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
                         hint.getDisplayPicture());
                 String hintPassword = hint.getGeneratedPassword();
 
 
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
                 boolean authenticated = false;
 
                 if (hintPassword != null) {
                     authenticated = mUserDataSource.createPasswordAccount(
                             hintEmail, displayName, displayPicture, hintPassword);
 
                     if (authenticated) {
                         // account created, attempt to save it back to the OpenYOLO provider
                         trySaveCredential(hint.toCredentialBuilder(mApplication).build());
                     }
                 }
 
                 if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
 
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
-    public void signInButtonClicked(View view) {
+    public void processAction(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
-        if (userPassword.length() < MIN_PASSWORD_LENGTH) {
-            passwordError.set(getResourceString(R.string.error_password_too_short));
-            return;
-        } else {
-            emailError.set("");
-        }
-
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
+            String profilePictureUri = "https://robohash.org/"
+                    + base64Sha256Hash(userEmail.getBytes(Charset.forName("UTF-8")));
+
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
-                    null, // name
-                    null, // profilePictureUri
+                    null, // no provided display name
+                    profilePictureUri, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 showError.set(true);
             }
         }
     }
 
+    private String base64Sha256Hash(byte[] data) {
+        try {
+            MessageDigest digest = MessageDigest.getInstance("SHA-256");
+            byte[] sha256Bytes = digest.digest(data);
+            return new String(
+                    Base64.encode(sha256Bytes, Base64.NO_WRAP | Base64.URL_SAFE),
+                    Charset.forName("UTF-8"));
+        } catch (NoSuchAlgorithmException e) {
+            throw new IllegalStateException("SHA-256 not supported on this platform!");
+        }
+    }
+
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
             mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
         mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
         mNavigator.get().goToMain();
     }
 
     private void setShowLoading(@StringRes int loadingLabelId) {
         setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
     private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
         showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
         showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
index b3db543..ec2be13 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
@@ -22,2 +22,3 @@ import android.support.annotation.NonNull;
 import android.support.annotation.WorkerThread;
+import android.text.TextUtils;
 import android.view.View;
@@ -26,2 +27,4 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.openyolo.api.CredentialClient;
 import org.openyolo.demoapp.passwordlogin.userdata.User;
@@ -30,82 +33,96 @@ import org.openyolo.demoapp.passwordlogin.userdata.UserDataSource;
 /**
  * The view model for the main activity, which is displayed when the user has authenticated
  * successfully.
  */
 @WorkerThread
 public final class MainViewModel extends ObservableViewModel {
 
     /**
      * The user's display name for display on screen, if known.
      */
     public final ObservableField<String> displayName = new ObservableField<>("");
 
     /**
      * The user's email address for display on screen.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The user's display picture for display on screen, if known.
      */
     public final ObservableField<String> displayPicture = new ObservableField<>("");
 
     private final AtomicBoolean mFirstLoad = new AtomicBoolean(true);
     private final UserDataSource mUserDataSource;
+    private final CredentialClient mCredentialClient;
+    private final String mNoDisplayNameText;
+
     private WeakReference<MainNavigator> mNavigator;
 
     /**
      * Creates the view model, with the required application reference.
      */
     public MainViewModel(@NonNull Application application) {
         super(application);
         mUserDataSource = ((OpenYoloDemoApplication)application).getUserRepository();
+        mCredentialClient = CredentialClient.getInstance(application);
+        mNoDisplayNameText = application.getResources().getString(R.string.no_display_name);
     }
 
     /**
      * Specifies the navigator for use in communicating with the activity environment.
      */
     @MainThread
     public void setNavigator(@NonNull MainNavigator navigator) {
         mNavigator = new WeakReference<>(navigator);
     }
 
     /**
      * The entry point to the view model's behavior. Determines whether a user is currently
      * authenticated, and if not, redirects to the login activity. Otherwise, the currently
      * authenticated user is displayed on screen.
      */
     public void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         User currentUser = mUserDataSource.getCurrentUser();
         if (currentUser == null) {
             // no user available, go to login screen
             mNavigator.get().goToLogin();
             return;
         }
 
         this.email.set(currentUser.getEmail());
-        this.displayName.set(currentUser.getName());
+        this.displayName.set(getDisplayName(currentUser));
         this.displayPicture.set(currentUser.getProfilePictureUri());
     }
 
     /**
      * Delegates handling of sign-out to a background thread, which de-authenticates the current
      * user and redirects to the login activity.
      */
     @MainThread
     public void onSignOutClicked(View view) {
         getExecutor().execute(() -> {
             mUserDataSource.signOut();
+            mCredentialClient.disableAutoSignIn();
             mNavigator.get().goToLogin();
         });
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return OpenYoloDemoApplication.getInstance(getApplication()).getExecutor();
     }
+
+    private String getDisplayName(User user) {
+        String name = user.getName();
+        if (TextUtils.isEmpty(name)) {
+            name = mNoDisplayNameText;
+        }
+        return name;
+    }
 }
diff --git a/demoapps/passwordlogin/res/drawable/rect_border_grey_300.xml b/demoapps/passwordlogin/res/drawable/rect_border_grey_300.xml
new file mode 100644
index 0000000..65b1265
--- /dev/null
+++ b/demoapps/passwordlogin/res/drawable/rect_border_grey_300.xml
@@ -0,0 +1,6 @@
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <stroke
+        android:width="1dp"
+        android:color="@color/grey_300_opaque" />
+</shape>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/drawable/rounded_rect_border_grey_500.xml b/demoapps/passwordlogin/res/drawable/rounded_rect_border_grey_500.xml
new file mode 100644
index 0000000..6d88f32
--- /dev/null
+++ b/demoapps/passwordlogin/res/drawable/rounded_rect_border_grey_500.xml
@@ -0,0 +1,8 @@
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <corners
+        android:radius="6dp" />
+    <stroke
+        android:width="1dp"
+        android:color="@color/grey_500_opaque" />
+</shape>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/layout/login_layout.xml b/demoapps/passwordlogin/res/layout/login_layout.xml
index e4065d3..ee4ff89 100644
--- a/demoapps/passwordlogin/res/layout/login_layout.xml
+++ b/demoapps/passwordlogin/res/layout/login_layout.xml
@@ -1,136 +1,142 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout>
 
   <data>
 
     <import type="android.text.InputType" />
     <import type="android.view.View" />
 
     <variable
         name="viewmodel"
         type="org.openyolo.demoapp.passwordlogin.LoginViewModel" />
   </data>
 
   <android.support.design.widget.CoordinatorLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:id="@+id/contentFrame"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
-      tools:context=".LoginActivity">
+      android:importantForAutofill="noExcludeDescendants"
+      tools:context=".LoginActivity"
+      tools:ignore="UnusedAttribute">
 
     <LinearLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         xmlns:tools="http://schemas.android.com/tools"
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:padding="16dp">
 
       <ImageView
           android:layout_width="128dp"
           android:layout_height="128dp"
           android:layout_gravity="center"
           app:srcCompat="@drawable/openyolo_logo"
           android:contentDescription="@string/openyolo_logo_contentDescription" />
 
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           android:layout_marginTop="8dp"
           android:layout_marginBottom="16dp"
           android:textAppearance="@style/TextAppearance.AppCompat.Title"
           android:text="@string/login_header"/>
 
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:orientation="vertical"
           android:visibility="@{viewmodel.showLoading ? View.VISIBLE : View.GONE}"
           android:gravity="center">
 
         <ProgressBar
             style="@style/Base.Widget.AppCompat.ProgressBar"
             android:layout_width="64dp"
             android:layout_height="64dp"
             android:indeterminate="true"/>
 
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@{viewmodel.loadingLabel}"
             tools:text="Loading..."/>
 
       </LinearLayout>
 
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:paddingBottom="16dp"
           android:orientation="vertical"
           android:visibility="@{viewmodel.showLoading ? View.GONE : View.VISIBLE}">
 
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center_horizontal"
             android:text="@{viewmodel.authPrompt}"
             android:layout_marginBottom="16dp"/>
 
         <android.support.design.widget.TextInputLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             app:errorEnabled="true"
             app:errorText="@{viewmodel.emailError}">
 
           <android.support.design.widget.TextInputEditText
               android:id="@+id/email"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:hint="@string/email_field_hint"
               android:inputType="textEmailAddress"
-              android:text="@={viewmodel.email}"/>
+              android:text="@={viewmodel.email}"
+              android:imeOptions="actionNext"
+              app:onEditorAction="@{viewmodel.editorActionListener}"/>
 
         </android.support.design.widget.TextInputLayout>
 
         <android.support.design.widget.TextInputLayout
             android:id="@+id/password"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:visibility="@{viewmodel.showPasswordField ? View.VISIBLE : View.GONE}"
             app:passwordToggleEnabled="true"
             app:errorEnabled="true"
             app:errorText="@{viewmodel.passwordError}">
 
           <android.support.design.widget.TextInputEditText
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:text="@={viewmodel.password}"
               android:inputType="textPassword"
-              android:hint="@string/password_field_hint" />
+              android:hint="@string/password_field_hint"
+              android:imeOptions="actionDone"
+              app:onEditorAction="@{viewmodel.editorActionListener}" />
 
         </android.support.design.widget.TextInputLayout>
 
         <android.support.design.widget.FloatingActionButton
             android:layout_width="72dp"
             android:layout_height="72dp"
             android:layout_gravity="center"
             android:layout_margin="8dp"
-            android:onClick="@{viewmodel::signInButtonClicked}"
+            android:onClick="@{viewmodel::processAction}"
             app:srcCompat="@drawable/ic_done" />
 
         <TextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="8dp"
             android:text="@string/error_prompt"
             android:textAlignment="center"
             android:visibility="@{viewmodel.showError ? View.VISIBLE : View.GONE}"/>
 
       </LinearLayout>
     </LinearLayout>
   </android.support.design.widget.CoordinatorLayout>
 
 </layout>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/layout/main_layout.xml b/demoapps/passwordlogin/res/layout/main_layout.xml
index 76fbe01..3ccc709 100644
--- a/demoapps/passwordlogin/res/layout/main_layout.xml
+++ b/demoapps/passwordlogin/res/layout/main_layout.xml
@@ -1,90 +1,100 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout>
 
   <data>
     <import type="android.view.View" />
     <variable
         name="viewmodel"
         type="org.openyolo.demoapp.passwordlogin.MainViewModel" />
   </data>
 
   <android.support.design.widget.CoordinatorLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:id="@+id/contentFrame"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       tools:context=".LoginActivity">
 
     <LinearLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         xmlns:tools="http://schemas.android.com/tools"
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:padding="16dp">
 
       <ImageView
           android:layout_width="128dp"
           android:layout_height="128dp"
           android:layout_gravity="center_horizontal"
           app:srcCompat="@drawable/openyolo_logo"
           android:contentDescription="@string/openyolo_logo_contentDescription"/>
 
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center_horizontal"
           android:layout_marginTop="8dp"
           android:textAppearance="@style/TextAppearance.AppCompat.Title"
           android:text="@string/signed_in_prompt"/>
 
       <LinearLayout
-          android:layout_width="match_parent"
+          android:layout_marginTop="8dp"
+          android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:padding="16dp"
-          android:orientation="horizontal">
+          android:paddingTop="8dp"
+          android:paddingBottom="8dp"
+          android:paddingLeft="12dp"
+          android:paddingRight="12dp"
+          android:orientation="horizontal"
+          android:layout_gravity="center"
+          android:background="@drawable/rounded_rect_border_grey_500">
 
         <ImageView
             android:id="@+id/profile_picture"
             android:layout_width="64dp"
             android:layout_height="64dp"
             android:src="@{viewmodel.displayPicture}"
-            android:contentDescription="@string/user_profile_picture"/>
+            android:contentDescription="@string/user_profile_picture"
+            android:background="@drawable/rect_border_grey_300"/>
 
         <LinearLayout
             android:layout_width="0dp"
             android:layout_weight="1"
             android:layout_height="wrap_content"
             android:layout_marginStart="8dp"
             android:layout_marginLeft="8dp"
-            android:orientation="horizontal">
+            android:layout_gravity="center_vertical"
+            android:orientation="vertical">
 
           <TextView
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
-              android:text="@{viewmodel.displayName}"/>
+              android:text="@{viewmodel.displayName}"
+              tools:text="John Doe"/>
 
           <TextView
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:textAppearance="@style/TextAppearance.AppCompat.Body1"
-              android:text="@{viewmodel.email}"/>
+              android:text="@{viewmodel.email}"
+              tools:text="jdoe@example.com"/>
         </LinearLayout>
 
       </LinearLayout>
 
       <Button
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center_horizontal"
           android:layout_marginTop="16dp"
           android:onClick="@{viewmodel::onSignOutClicked}"
           android:text="@string/sign_out_label"
           style="@style/Widget.AppCompat.Button.Colored" />
 
     </LinearLayout>
   </android.support.design.widget.CoordinatorLayout>
 </layout>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/values/colors.xml b/demoapps/passwordlogin/res/values/colors.xml
index 0c017cc..ca8f815 100644
--- a/demoapps/passwordlogin/res/values/colors.xml
+++ b/demoapps/passwordlogin/res/values/colors.xml
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
   <color name="colorPrimary">#2491eb</color>
   <color name="colorPrimaryDark">#36434f</color>
   <color name="colorAccent">#4fc3f7</color>
+  <color name="grey_300_opaque">#e0e0e0</color>
+  <color name="grey_500_opaque">#9e9e9e</color>
 </resources>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/values/strings.xml b/demoapps/passwordlogin/res/values/strings.xml
index 99a7e22..722fc00 100644
--- a/demoapps/passwordlogin/res/values/strings.xml
+++ b/demoapps/passwordlogin/res/values/strings.xml
@@ -1,21 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-  <string name="app_name_short">OpenYOLO</string>
+  <string name="app_name_short">Pwd Demo</string>
   <string name="email_field_hint">Email</string>
   <string name="password_field_hint">Password</string>
   <string name="login_header">OpenYOLO Demo - Password Login</string>
   <string name="sign_out_label">Sign out</string>
   <string name="openyolo_logo_contentDescription">OpenYOLO logo</string>
   <string name="enter_email_prompt">Enter your email address:</string>
   <string name="incorrect_stored_password">Incorrect stored password in credential provider. Please re-enter your password:</string>
   <string name="existing_account_enter_password">Welcome back! Please enter your password:</string>
   <string name="new_account_enter_password">Hey, you\'re new! Please choose a password for your account</string>
   <string name="error_prompt">Oops, that didn\'t work. Maybe try again?</string>
   <string name="signed_in_prompt">You are signed in as:</string>
   <string name="error_invalid_email">Invalid email address</string>
-  <string name="error_password_too_short">Password is too short</string>
   <string name="error_incorrect_password">Wrong password, please try again</string>
   <string name="user_profile_picture">User profile picture</string>
   <string name="existing_account_search_prompt">Looking for an existing account…</string>
   <string name="requesting_hint_prompt">Asking your credential manager for account details…</string>
+    <string name="no_display_name">[ no display name ]</string>
 </resources>

commit 546d4e11c6dda760aa5c8f46d6a6073740861513
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Mon Oct 30 10:44:19 2017 -0700

    Added LastPass to list of production implementations. (#152)

diff --git a/README.md b/README.md
index c904865..45473df 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,6 @@ OpenYOLO has reached beta production ready stage and can be integrated into prod
 The following credential providers include production implementations of OpenYOLO:
 
-| <img src="https://user-images.githubusercontent.com/445775/31100963-59c51db2-a780-11e7-87f4-e7ab2750b92a.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/31101083-0cc4fd92-a781-11e7-95fe-9f9e9fadae70.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/31101050-eeb9966e-a780-11e7-96ae-614f765f3f12.png" width="200" height="200" /> |
-|:---:|:---:|:---:|
-| 1Password | Dashlane | Google Smart Lock |
+| <img src="https://user-images.githubusercontent.com/445775/31100963-59c51db2-a780-11e7-87f4-e7ab2750b92a.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/31101083-0cc4fd92-a781-11e7-95fe-9f9e9fadae70.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/31101050-eeb9966e-a780-11e7-96ae-614f765f3f12.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/32184911-078a0814-bd5b-11e7-8957-9a9b4d3cc415.png" width="200" height="200" /> |
+|:---:|:---:|:---:|:---:|
+| 1Password | Dashlane | Google Smart Lock | LastPass |
 

commit 0ae3b1da002905f7a14009dde879ea44ecac035b
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Mon Oct 30 10:06:44 2017 -0700

    Changed the default source and target java version  to 1.7 :( (#151)

diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
index aa58851..9061e77 100644
--- a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
@@ -27,2 +27,3 @@ import com.google.protobuf.InvalidProtocolBufferException;
 
+import org.assertj.core.api.ThrowableAssert;
 import org.junit.Before;
@@ -39,65 +40,69 @@ import java.util.List;
 /**
  * This class contains a set of tests for QueryResponseSenderTest.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class QueryResponseSenderTest {
 
     private BroadcastQuery mQuery;
     private QueryResponseSender mResponseSender;
 
     @Before
     public void setUp() throws Exception {
         //set mock values.
         mQuery = BroadcastQuery.newBuilder()
             .setDataType("example")
             .setRequestingApp("com.example.app")
             .setRequestId(128L)
             .setResponseId(256L)
             .build();
 
         mResponseSender = new QueryResponseSender(RuntimeEnvironment.application);
     }
 
     @Test
     public void sendResponse() throws Exception {
         byte[] responseMessageBytes = new byte[] { 0, 1, 2 };
         mResponseSender.sendResponse(mQuery, responseMessageBytes);
         checkBroadcastResponse(ByteString.copyFrom(responseMessageBytes));
     }
 
     @Test
     public void sendResponse_nonNullQuery_nullReponse() throws Exception {
         mResponseSender.sendResponse(mQuery, null);
         checkBroadcastResponse(ByteString.EMPTY);
     }
 
     private void checkBroadcastResponse(ByteString expectedResponseBytes)
             throws InvalidProtocolBufferException {
         List<Intent> broadcasts =
                 Shadows.shadowOf(RuntimeEnvironment.application).getBroadcastIntents();
 
         assertThat(broadcasts.size()).isEqualTo(1);
         Intent broadcastIntent = broadcasts.get(0);
 
         assertThat(broadcastIntent.getAction())
                 .isEqualTo("example:0000000000000080");
         assertThat(broadcastIntent.getCategories()).containsExactly(QueryUtil.BBQ_CATEGORY);
         assertThat(broadcastIntent.getPackage()).isEqualTo(mQuery.getRequestingApp());
         assertThat(broadcastIntent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE)).isNotNull();
 
         byte[] responseBytes = broadcastIntent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
         BroadcastQueryResponse response = BroadcastQueryResponse.parseFrom(responseBytes);
 
         assertThat(response.getRequestId()).isEqualTo(mQuery.getRequestId());
         assertThat(response.getResponseId()).isEqualTo(mQuery.getResponseId());
         assertThat(response.getResponseMessage()).isEqualTo(expectedResponseBytes);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test
     public void sendResponse_nullQuery_nullReponse() throws Exception {
-        assertThatThrownBy(() -> mResponseSender.sendResponse(null, null))
-                .isInstanceOf(NullPointerException.class);
+        assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
+            @Override
+            public void call() throws Throwable {
+                mResponseSender.sendResponse(null, null);
+            }
+        }).isInstanceOf(NullPointerException.class);
     }
 }
diff --git a/build.gradle b/build.gradle
index 85e3bcc..5716d30 100644
--- a/build.gradle
+++ b/build.gradle
@@ -62,2 +62,4 @@ project.ext.hamcrestVersion = '1.3'
 project.ext.guavaVersion = '23.0-android'
+project.ext.sourceJavaVersion = JavaVersion.VERSION_1_7
+project.ext.targetJavaVersion = JavaVersion.VERSION_1_7
 
diff --git a/config/android-common.gradle b/config/android-common.gradle
index 0264015..299d178 100644
--- a/config/android-common.gradle
+++ b/config/android-common.gradle
@@ -1,40 +1,40 @@
 android {
     compileSdkVersion rootProject.ext.compileSdkVersion
     buildToolsVersion rootProject.ext.buildToolsVersion
 
     defaultConfig {
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.compileSdkVersion
         versionCode rootProject.ext.versionNum
         versionName rootProject.ext.versionName
     }
 
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_1_8
-        targetCompatibility = JavaVersion.VERSION_1_8
+        sourceCompatibility = rootProject.ext.sourceJavaVersion
+        targetCompatibility = rootProject.ext.targetJavaVersion
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
         main.java.srcDirs = ['java']
         main.aidl.srcDirs = ['java']
         main.res.srcDir 'res'
         main.assets.srcDir 'assets'
         main.resources.srcDir 'java'
 
         test.setRoot('javatests');
         test.java.srcDir('javatests');
     }
 
     lintOptions {
         warningsAsErrors true
         disable 'InvalidPackage', 'TrulyRandom', 'GradleDependency', 'ObsoleteLintCustomCheck'
     }
 
     packagingOptions {
         exclude 'META-INF/LICENSE.txt'
         exclude 'META-INF/NOTICE.txt'
     }
 }
 
 // produces a JAR containing sources
diff --git a/demoapps/passwordlogin/build.gradle b/demoapps/passwordlogin/build.gradle
index 37c3e3f..5eb733f 100644
--- a/demoapps/passwordlogin/build.gradle
+++ b/demoapps/passwordlogin/build.gradle
@@ -6,22 +6,22 @@ apply from: "${rootDir}/config/android-common.gradle"
 android {
     defaultConfig {
         applicationId 'org.openyolo.demoapp.passwordonly'
         project.archivesBaseName = 'openyolo-demoapp-passwordonly'
         vectorDrawables.useSupportLibrary = true
     }
 
     dataBinding {
         enabled = true
     }
 
     buildTypes {
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
         }
     }
     compileOptions {
-        targetCompatibility 1.8
-        sourceCompatibility 1.8
+        targetCompatibility JavaVersion.VERSION_1_8
+        sourceCompatibility JavaVersion.VERSION_1_8
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java b/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java
index 571909d..2340914 100644
--- a/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java
+++ b/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java
@@ -29,2 +29,4 @@ import java.util.Map;
 import java.util.concurrent.Callable;
+
+import org.assertj.core.api.ThrowableAssert;
 import org.assertj.core.util.Maps;
@@ -40,184 +42,244 @@ import org.robolectric.annotation.Config;
 /**
  * Tests additional property storage and retrieval, for all types that implement the
  * {@link AdditionalPropertiesContainer} interface.
  */
 @RunWith(ParameterizedRobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AdditionalPropertiesTest {
 
     private final String mContainerClassName;
 
     /**
      * Classloader shenanigans within Robolectric mean that we can't just directly instantiate
      * and provide the instances of AdditionalPropertiesBuilder via the @Parameters annotated
      * method. We must ensure that the instances are only created once the test methods are
      * actually executing, as it is only at this point that the robolectric shadows have been
      * loaded. So, as an awkward workaround, this map holds lambdas to create the builders
      * on-demand, and the tests are parameterized by the keys of the map.
      */
     private static final Map<String, Callable<AdditionalPropertiesBuilder>> buildersByContainerType =
             ImmutableMap.<String, Callable<AdditionalPropertiesBuilder>>builder()
                     .put("Credential",
-                            () -> new Credential.Builder(
-                                    ValidFacebookCredential.ID,
-                                    ValidFacebookCredential.AUTHENTICATION_METHOD,
-                                    ValidFacebookCredential.AUTHENTICATION_DOMAIN))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new Credential.Builder(
+                                            ValidFacebookCredential.ID,
+                                            ValidFacebookCredential.AUTHENTICATION_METHOD,
+                                            ValidFacebookCredential.AUTHENTICATION_DOMAIN);
+                                }
+                            })
                     .put("CredentialDeleteRequest",
-                            () -> new CredentialDeleteRequest.Builder(
-                                    ValidFacebookCredential.make()))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new CredentialDeleteRequest.Builder(
+                                            ValidFacebookCredential.make());
+                                }
+                            })
                     .put("CredentialDeleteResult",
-                            () -> new CredentialDeleteResult.Builder(
-                                    CredentialDeleteResult.CODE_DELETED))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new CredentialDeleteResult.Builder(
+                                            CredentialDeleteResult.CODE_DELETED);
+                                }
+                            })
                     .put("CredentialRetrieveRequest",
-                            () -> new CredentialRetrieveRequest.Builder(
-                                    AuthenticationMethods.EMAIL))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new CredentialRetrieveRequest.Builder(
+                                            AuthenticationMethods.EMAIL);
+                                }
+                            })
                     .put("CredentialRetrieveResult",
-                            () -> new CredentialRetrieveResult.Builder(
-                                    CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new CredentialRetrieveResult.Builder(
+                                            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
+                                }
+                            })
                     .put("CredentialSaveRequest",
-                            () -> new CredentialSaveRequest.Builder(
-                                    ValidFacebookCredential.make()))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new CredentialSaveRequest.Builder(
+                                            ValidFacebookCredential.make());
+                                }
+                            })
                     .put("CredentialSaveResult",
-                            () -> new CredentialSaveResult.Builder(
-                                    CredentialSaveResult.CODE_SAVED))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new CredentialSaveResult.Builder(
+                                            CredentialSaveResult.CODE_SAVED);
+                                }
+                            })
                     .put("Hint",
-                            () -> new Hint.Builder(
-                                    ValidFacebookCredential.ID,
-                                    ValidFacebookCredential.AUTHENTICATION_METHOD))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new Hint.Builder(
+                                            ValidFacebookCredential.ID,
+                                            ValidFacebookCredential.AUTHENTICATION_METHOD);
+                                }
+                            })
                     .put("HintRetrieveRequest",
-                            () -> new HintRetrieveRequest.Builder(
-                                    AuthenticationMethods.EMAIL))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new HintRetrieveRequest.Builder(
+                                            AuthenticationMethods.EMAIL);
+                                }
+                            })
                     .put("HintRetrieveResult",
-                            () -> new HintRetrieveResult.Builder(
-                                    HintRetrieveResult.CODE_NO_HINTS_AVAILABLE))
+                            new Callable<AdditionalPropertiesBuilder>() {
+                                @Override
+                                public AdditionalPropertiesBuilder call() throws Exception {
+                                    return new HintRetrieveResult.Builder(
+                                            HintRetrieveResult.CODE_NO_HINTS_AVAILABLE);
+                                }
+                            })
             .build();
 
     @Parameters(name = "AdditionalPropertiesTest for {0}")
     public static Collection params() {
         ArrayList<Object[]> params = new ArrayList<>();
 
         for (String containerTypeName : buildersByContainerType.keySet()) {
             params.add(new Object[] { containerTypeName });
         }
 
         return params;
     }
 
     private AdditionalPropertiesBuilder<?, ?> mBuilder;
 
     public AdditionalPropertiesTest(String containerClassName) {
         mContainerClassName = containerClassName;
     }
 
     @Before
     public void setUp() throws Exception {
         mBuilder = buildersByContainerType.get(mContainerClassName).call();
     }
 
     @Test
     public void testBuilder_setAdditionalProperties() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
         ValidAdditionalProperties.assertEquals(container.getAdditionalProperties());
     }
 
     @Test
     public void testBuilder_setAdditionalProperties_withNull() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .setAdditionalProperties(null)
                 .build();
 
         assertThat(container.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setAdditionalProperties_nullKey() {
         final Map<String, byte[]> mapWithNullKey = Maps.newHashMap(null, new byte[0]);
-        assertThatThrownBy(() -> mBuilder.setAdditionalProperties(mapWithNullKey))
-                .isInstanceOf(IllegalArgumentException.class);
+        assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
+            @Override
+            public void call() throws Throwable {
+                mBuilder.setAdditionalProperties(mapWithNullKey);
+            }
+        }).isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
     public void testBuild_setAdditionalProperty_nullValue() {
         final Map<String, byte[]> mapWithNullValue = Maps.newHashMap("a", null);
-        assertThatThrownBy(() -> mBuilder.setAdditionalProperties(mapWithNullValue))
-                .isInstanceOf(IllegalArgumentException.class);
+
+
+        assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
+            @Override
+            public void call() throws Throwable {
+                mBuilder.setAdditionalProperties(mapWithNullValue);
+            }
+        }).isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
     public void testBuilder_setAdditionalProperty() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
                 .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
                 .build();
 
         Map<String, byte[]> additionalProps = container.getAdditionalProperties();
         assertThat(additionalProps.size()).isEqualTo(2);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
                 .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
     }
 
     @Test
     public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
                 .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
                 .build();
 
         Map<String, byte[]> additionalProps = container.getAdditionalProperties();
         assertThat(additionalProps.size()).isEqualTo(1);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
     }
 
     @Test
     public void testBuilder_setAdditionalPropertyAsString() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalPropertyAsString(
                         ADDITIONAL_PROP_TEST_KEY,
                         ADDITIONAL_PROP_STRING_VALUE)
                 .build();
 
         Map<String, byte[]> additionalProps = container.getAdditionalProperties();
         assertThat(additionalProps.size()).isEqualTo(1);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
                         ADDITIONAL_PROP_STRING_VALUE));
     }
 
     @Test
     public void testGetAdditionalProperty() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalProperties(ImmutableMap.of(
                         ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE))
                 .build();
 
         assertThat(container.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
     }
 
     @Test
     public void testGetAdditionalProperty_withMissingKey() {
         AdditionalPropertiesContainer container = mBuilder.build();
         assertThat(container.getAdditionalProperty("missingKey")).isNull();
     }
 
     @Test
     public void testGetAdditionalPropertyAsString() {
         AdditionalPropertiesContainer container = mBuilder
                 .setAdditionalPropertyAsString(
                         ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_STRING_VALUE)
                 .build();
 
         assertThat(container.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index 8004df8..d87d569 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -32,283 +32,283 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testFromAuthMethods() {
         HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods()).containsExactly(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testFromAuthMethods_noneProvided() {
         HintRetrieveRequest.fromAuthMethods();
     }
 
     @Test
     public void testFromAuthMethods_withSet() {
         HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
                 ImmutableSet.of(AuthenticationMethods.EMAIL, AuthenticationMethods.FACEBOOK));
 
         assertThat(request.getAuthenticationMethods()).containsExactly(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK);
     }
 
     @Test(expected=IllegalArgumentException.class)
     public void testFromAuthMethods_emptySet() {
-        HintRetrieveRequest.fromAuthMethods(Collections.emptySet());
+        HintRetrieveRequest.fromAuthMethods(Collections.<AuthenticationMethod>emptySet());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethodsSet() {
-        new HintRetrieveRequest.Builder(Collections.emptySet());
+        new HintRetrieveRequest.Builder(Collections.<AuthenticationMethod>emptySet());
     }
 
     @Test
     public void testBuilder_setTokenProviders() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .build();
 
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
     }
 
     @Test
     public void testBuilder_setTokenProviders_nullMap() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setTokenProviders(null)
                 .build();
 
         assertThat(request.getTokenProviders()).isEmpty();
     }
 
     @Test
     public void testBuilder_addTokenProvider_noInfo() {
         String tokenProvider = "https://my.token.provider";
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addTokenProvider(tokenProvider)
                 .build();
 
         assertThat(request.getTokenProviders()).containsKey(tokenProvider);
         assertThat(request.getTokenProviders().get(tokenProvider))
                 .isEqualTo(TokenRequestInfo.DEFAULT);
     }
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setPasswordSpecification(originalSpec)
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL);
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
             ValidTokenProviderMap.assertEquals(read.getTokenProviders());
             ValidAdditionalProperties.assertEquals(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Set<AuthenticationMethod>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java b/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
index 5f817d9..3eef329 100644
--- a/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
+++ b/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
@@ -21,2 +21,3 @@ import static junit.framework.Assert.fail;
 import static junit.framework.TestCase.assertTrue;
+import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
@@ -26,2 +27,4 @@ import android.os.BadParcelableException;
 import android.os.Parcel;
+
+import org.assertj.core.api.ThrowableAssert;
 import org.junit.Test;
@@ -33,98 +36,72 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for IntentUtilTest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class IntentUtilTest {
 
     @Test(expected = RequireViolation.class)
     public void testToBytes_null() throws Exception {
         IntentUtil.toBytes(null);
     }
 
     @Test
     public void toBytes() throws Exception {
         Intent intent = new Intent("com.openyolo");
         byte[] result = IntentUtil.toBytes(intent);
         assertEquals(result.length, 235);
         //comparing a few random locations
         assertEquals(result[0], -84);
         assertEquals(result[8], 0);
         assertEquals(result[16], 22);
         assertEquals(result[32], 46);
         assertEquals(result[64], 0);
         assertEquals(result[128], -107);
         assertEquals(result[234], -1);
     }
 
     @Test
     public void fromBytes() throws Exception {
         Intent fromIntent = new Intent("com.openyolo.ACTION");
         fromIntent.setPackage("com.openyolo");
         byte[] fromBytes = IntentUtil.toBytes(fromIntent);
 
         Intent toIntent = IntentUtil.fromBytes(fromBytes);
         assertTrue(toIntent.getAction().equals(fromIntent.getAction()));
         assertTrue(toIntent.getPackage().equals(fromIntent.getPackage()));
     }
 
     @Test
     public void fromBytes_withNullIntent_throwsBadParcelableException() {
-        byte[] intentBytes = toBytesUnchecked(null);
-
+        final byte[] intentBytes = toBytesUnchecked(null);
 
-        assertThrows(BadParcelableException.class, () -> {
-            IntentUtil.fromBytes(intentBytes);
-        });
+        assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
+            @Override
+            public void call() throws Throwable {
+                IntentUtil.fromBytes(intentBytes);
+            }
+        }).isInstanceOf(BadParcelableException.class);
     }
 
     @Test
     public void fromBytes_withIntentNotPresent_throwsBadParcelableException() {
-        byte[] intentBytes = new byte[10];
+        final byte[] intentBytes = new byte[10];
 
-
-        assertThrows(BadParcelableException.class, () -> {
-            IntentUtil.fromBytes(intentBytes);
-        });
+        assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
+            @Override
+            public void call() throws Throwable {
+                IntentUtil.fromBytes(intentBytes);
+            }
+        }).isInstanceOf(BadParcelableException.class);
     }
 
     private static byte[] toBytesUnchecked(Intent intent) {
         Parcel parcel = Parcel.obtain();
         parcel.writeParcelable(intent,0);
         byte[] intentBytes = parcel.marshall();
         parcel.recycle();
 
         return intentBytes;
     }
 
-    private interface Operation {
-        void execute();
-    }
-
-    private static void assertThrows(Class expectedExceptionType, Operation operation) {
-        try {
-            operation.execute();
-
-            // No exception was thrown.
-            String failureMessage =
-                    String.format(
-                            "No exception was thrown, expected a %s exception",
-                            expectedExceptionType);
-
-            fail(failureMessage);
-        } catch (Exception ex) {
-            if (expectedExceptionType.isInstance(ex)) {
-                // Expected exception was thrown.
-                return;
-            }
-
-            // An unexpected exception was thrown.
-            String failureMessage =
-                    String.format(
-                            "Expected exception to be instance of %s, but was %s",
-                            expectedExceptionType,
-                            ex.getClass());
-            fail(failureMessage);
-        }
-    }
 }
\ No newline at end of file

commit 859e4c18856ae3b8dc1d0aa9a0a3263185ae80c0
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Fri Oct 27 18:32:06 2017 +0100

    Version bump for gradle plugin (AS 3.0 is out!) (#142)

diff --git a/build.gradle b/build.gradle
index 1296516..85e3bcc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,15 +1,15 @@
 buildscript {
     repositories {
         jcenter()
         maven { url 'https://maven.google.com' }
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.0.0-rc2'
+        classpath 'com.android.tools.build:gradle:3.0.0'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
         classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }

commit d818861a1f66eaa9f2c7ff0fa17944162ebe559c
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Fri Oct 27 00:54:00 2017 -0700

    Allow bintrayUpload params to be passed as project properties. (#139)

diff --git a/config/bintray.gradle b/config/bintray.gradle
index f785f25..3a87b0b 100644
--- a/config/bintray.gradle
+++ b/config/bintray.gradle
@@ -4,23 +4,23 @@ apply plugin: 'com.github.dcendents.android-maven'
 bintray {
-    user = System.getenv("BINTRAY_USER")
-    key = System.getenv("BINTRAY_KEY")
+    user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv("BINTRAY_USER")
+    key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv("BINTRAY_API_KEY")
     pkg {
         repo = "net.openid"
         name = project.archivesBaseName
         desc = project.moduleDesc
         userOrg = "openid"
         licenses = ["Apache-2.0"]
         websiteUrl = "https://openid.github.io/OpenYOLO-Android/"
         issueTrackerUrl = "https://github.com/openid/OpenYOLO-Android/issues"
         vcsUrl = "https://github.com/openid/OpenYOLO-Android.git"
         githubRepo = 'openid/OpenYOLO-Android'
 
         version {
             name = rootProject.versionName
             desc = "OpenYOLO for Android"
             released = rootProject.versionDate
             vcsTag = rootProject.versionName
         }
     }
     configurations = ["archives"]
 }

commit 0ea54e848ab8cf72202904c31e144dd4e128e505
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Thu Oct 26 13:53:41 2017 -0700

    Corrected result codes in CredentialRetrieveActivity and added client version code to test app (#140)
    
    * Added client version code to test app.
    
    * Corrected result codes returned from CredentialRetrieveActivity and
    added snackbar message support to test app.

diff --git a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
index e777bc7..330de4b 100644
--- a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
+++ b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
@@ -39,143 +39,151 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * An invisible Activity that forwards a given {@link CredentialRetrieveRequest} based on the
  * the set of available credential providers capable of handling it. A
  * {@link CredentialRetrieveResult} will be returned as described by
  * {@link org.openyolo.api.CredentialClient#getCredentialRetrieveIntent(CredentialRetrieveRequest)}.
  */
 public final class CredentialRetrieveActivity extends Activity {
 
     private static final String LOG_TAG = "CredentialRetrieveAct";
     private static final String EXTRA_REQUEST = "Request";
 
     // The amount of time we will permit providers to "think" about responding to a retrieve
     // BBQ request. The default BBQ timeout of two seconds proved to be too short when the device
     // is actively updating and compiling apps, so we extend it here.
     private static final long RETRIEVE_TIMEOUT_MS = 4000;
 
     private boolean mIsDestroyed = false;
 
     /**
      * Returns an Intent for {@link CredentialRetrieveActivity} for the given
      * {@link CredentialRetrieveRequest}.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         return new Intent()
                 .setClass(context, CredentialRetrieveActivity.class)
                 .putExtra(EXTRA_REQUEST, request);
     }
 
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         getWindow().addFlags(LayoutParams.FLAG_NOT_TOUCHABLE);
 
         CredentialRetrieveRequest request = getIntent().getParcelableExtra(EXTRA_REQUEST);
         if (null == request) {
             setResult(
                     CredentialRetrieveResult.CODE_UNKNOWN,
                     CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
             finish();
             return;
         }
 
         BroadcastQueryClient.getInstance(this)
                 .queryFor(
                         CREDENTIAL_DATA_TYPE,
                         request.toProtocolBuffer(),
                         RETRIEVE_TIMEOUT_MS,
                         new CredentialRetrieveQueryCallback(request));
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         mIsDestroyed = true;
     }
 
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private CredentialRetrieveRequest mRetrieveRequest;
 
         CredentialRetrieveQueryCallback(@NonNull CredentialRetrieveRequest retrieveRequest) {
             mRetrieveRequest = retrieveRequest;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
+            if (queryResponses.isEmpty()) {
+                setResult(
+                        CredentialRetrieveResult.CODE_PROVIDER_TIMEOUT,
+                        CredentialRetrieveResult.PROVIDER_TIMEOUT.toResultDataIntent());
+                finish();
+                return;
+            }
+
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 // 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.
 
                 if (response.getCredentialsAvailable()) {
                     Intent retrieveIntent = ProviderResolver.createIntentForAction(
                             CredentialRetrieveActivity.this.getApplicationContext(),
                             queryResponse.responderPackage,
                             ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
                     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);
                 } else if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: remove backwards compatibility with retrieve_intent after 0.3.0
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                     } else {
                         retrieveIntents.add(retrieveIntent);
                     }
                 }
             }
 
             if (retrieveIntents.isEmpty()) {
                 setResult(
-                        CredentialRetrieveResult.CODE_PROVIDER_TIMEOUT,
-                        CredentialRetrieveResult.PROVIDER_TIMEOUT.toResultDataIntent());
+                        CredentialRetrieveResult.CODE_NO_PROVIDER_AVAILABLE,
+                        CredentialRetrieveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
                 finish();
                 return;
             }
 
             if (retrieveIntents.size() == 1) {
                 forwardResultFromActivity(retrieveIntents.get(0));
                 return;
             }
 
             Intent intent = ProviderPickerActivity.createRetrieveIntent(
                     CredentialRetrieveActivity.this,
                     retrieveIntents);
 
             forwardResultFromActivity(intent);
         }
     }
 
     private void forwardResultFromActivity(Intent intent) {
         if (mIsDestroyed) {
             return;
         }
 
         intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(intent);
         finish();
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java b/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
index 43476fa..0843cce 100644
--- a/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
@@ -20,3 +20,4 @@ import android.view.View;
 import android.view.ViewGroup;
-
+import android.widget.TextView;
+import butterknife.BindView;
 import butterknife.ButterKnife;
@@ -26,35 +27,40 @@ import org.openyolo.api.CredentialClient;
 /**
  * Test page for actions that do not cleanly fit into another category.
  */
 public class OtherTestPageFragment extends TestPageFragment {
 
+    @BindView(R.id.version_text_view)
+    TextView mVersionTextView;
+
     private CredentialClient mApi;
 
     @Override
     public String getPageTitle() {
         return "Other";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.other_test_layout, container, false);
         ButterKnife.bind(this, view);
 
+        mVersionTextView.setText(getString(R.string.client_version_text, BuildConfig.VERSION_NAME));
+
         return view;
     }
 
     @OnClick(R.id.disable_auto_sign_in_button)
     void onDisableAutoSignIn() {
         mApi.disableAutoSignIn();
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index 5c903eb..f2a23ac 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -35,118 +35,121 @@ import org.openyolo.protocol.CredentialRetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.token_providers_input)
     TokenProviderInputView mTokenProviderInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     @BindView(R.id.require_user_mediation_check_box)
     CheckBox mRequireUserMediationCheckBox;
 
     @BindView(R.id.id_token_view)
     IdTokenView mIdTokenView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         Credential credential = result.getCredential();
         if (credential != null) {
             mCredentialView.setFieldsFromCredential(credential);
             mIdTokenView.setIdToken(credential.getIdToken());
             return;
         }
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 resultMessageId = R.string.retrieve_no_credentials;
                 break;
             case CredentialRetrieveResult.CODE_NO_PROVIDER_AVAILABLE:
                 resultMessageId = R.string.retrieve_no_provider_available;
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.retrieve_bad_request;
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.retrieve_user_canceled;
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 resultMessageId = R.string.retrieve_manual_auth;
                 break;
+            case CredentialRetrieveResult.CODE_PROVIDER_TIMEOUT:
+                resultMessageId = R.string.retrieve_provider_timed_out;
+                break;
             default:
                 resultMessageId = R.string.retrieve_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         CredentialRetrieveRequest.Builder requestBuilder =
                 new CredentialRetrieveRequest.Builder(authenticationMethods)
                         .setTokenProviders(mTokenProviderInputView.getTokenProviders());
 
         if (mRequireUserMediationCheckBox.isChecked()) {
             requestBuilder.setRequireUserMediation(true);
         }
 
         startActivityForResult(
                 mApi.getCredentialRetrieveIntent(requestBuilder.build()),
                 RC_RETRIEVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/res/layout/other_test_layout.xml b/testapp/res/layout/other_test_layout.xml
index 1d82159..babc520 100644
--- a/testapp/res/layout/other_test_layout.xml
+++ b/testapp/res/layout/other_test_layout.xml
@@ -1,29 +1,35 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     app:layout_behavior="@string/appbar_scrolling_view_behavior"
     style="@style/DemoContent">
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical">
 
         <Button
             android:id="@+id/disable_auto_sign_in_button"
             style="@style/Widget.AppCompat.Button.Colored"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="16dp"
             android:layout_marginLeft="8dp"
             android:layout_marginRight="8dp"
             android:layout_gravity="center_horizontal"
             android:contentDescription="@string/disable_auto_sign_in_button_content_description"
             android:text="@string/disable_auto_sign_in_button_label"
             android:theme="@style/GreenButtonThemeOverlay"/>
 
+        <TextView
+            android:id="@+id/version_text_view"
+            android:textAlignment="center"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
+
     </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 550c05e..2e065fd 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,106 +1,108 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_no_provider_available">No provider available for credential request</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
+    <string name="retrieve_provider_timed_out">Providers timed out</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
     <string name="phone_authentication_method_checkbox_text">openyolo://phone</string>
     <string name="username_authentication_method_checkbox_text">openyolo://username</string>
 
     <string name="require_user_mediation_checkbox_text">Require User Mediation</string>
     <string name="retrieve_other_section_title">Other</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
 
     <string name="save_invalid_request">Invalid Save Request</string>
 
     <string name="save_result_unknown">Unknown save result</string>
     <string name="save_no_provider_available">No provider available for save request</string>
     <string name="save_result_saved">Credential Saved</string>
     <string name="save_result_bad_request">Malformed save request</string>
     <string name="save_result_provider_refused">Provider refused save request</string>
     <string name="save_result_user_canceled">User canceled save request</string>
     <string name="save_result_user_refused">User refused save request</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
 
     <string name="hint_unknown_response">Unknown hint response</string>
     <string name="hint_no_provider_available">No provider available for hint request</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
 
     <string name="delete_result_unknown_response">Unknown delete response</string>
     <string name="delete_no_provider_available">"No provider available for this delete request</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
 
     <!-- Other Test -->
     <string name="disable_auto_sign_in_button_label">Disable Auto Sign In</string>
     <string name="disable_auto_sign_in_button_content_description">Disable Auto Sign In</string>
+    <string name="client_version_text">Client version: %1$s</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response Properties</string>
     <string name="request">Request Properties</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
     <string name="token_providers_header">Supported token providers</string>
     <string name="use_google_token_provider">Request Google ID tokens</string>
     <string name="token_provider_uri_field_hint">Token provider URI</string>
     <string name="client_id_field_hint">Client ID</string>
     <string name="nonce_field_hint">Nonce</string>
     <string name="clear_token_provider">Clear</string>
     <string name="no_token">No token returned</string>
     <string name="id_token_view_header">ID Token</string>
 
 </resources>

commit 6ee102efefccf4482bdfc27d6de9c8526f91ee83
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Thu Oct 26 13:53:08 2017 -0700

    Removed TODOs from API getting started documentation. (#141)

diff --git a/api/README.md b/api/README.md
index ce19a03..6e89de6 100644
--- a/api/README.md
+++ b/api/README.md
@@ -41,4 +41,4 @@ multiple domains you can safely ignore this concept as a client. However, if you
 both an app and web app you can prove this relationship to credential providers to allow credentials
-to be shared between the two. ```TOOD(dxslly): Add guide for linking authentication domains.```
+to be shared between the two.
 
 ## Usage
@@ -204,12 +204,8 @@ It is recommended you call this method whenever a user is signed out of your app
 ```java
 public void signOutUser() {
     // Your application's custom sign out logic.
     // ...
     CredentialClient client = CredentialClient.getInstance(getContext());
     client.disableAutoSignIn();
 }
 ```
-
-## Testing against providers
-
-// TODO(dxslly): Describe how to test in the wild, enumerate production implementations?

commit 2f854cbf1f67b75e1e107790564607aed3a081d6
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 25 16:06:09 2017 +0100

    Use explicit intents for credential retrieve (#135)

diff --git a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
index 7107269..e777bc7 100644
--- a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
+++ b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
@@ -39,142 +39,143 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * An invisible Activity that forwards a given {@link CredentialRetrieveRequest} based on the
  * the set of available credential providers capable of handling it. A
  * {@link CredentialRetrieveResult} will be returned as described by
  * {@link org.openyolo.api.CredentialClient#getCredentialRetrieveIntent(CredentialRetrieveRequest)}.
  */
 public final class CredentialRetrieveActivity extends Activity {
 
     private static final String LOG_TAG = "CredentialRetrieveAct";
     private static final String EXTRA_REQUEST = "Request";
 
     // The amount of time we will permit providers to "think" about responding to a retrieve
     // BBQ request. The default BBQ timeout of two seconds proved to be too short when the device
     // is actively updating and compiling apps, so we extend it here.
     private static final long RETRIEVE_TIMEOUT_MS = 4000;
 
     private boolean mIsDestroyed = false;
 
     /**
      * Returns an Intent for {@link CredentialRetrieveActivity} for the given
      * {@link CredentialRetrieveRequest}.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         return new Intent()
                 .setClass(context, CredentialRetrieveActivity.class)
                 .putExtra(EXTRA_REQUEST, request);
     }
 
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         getWindow().addFlags(LayoutParams.FLAG_NOT_TOUCHABLE);
 
         CredentialRetrieveRequest request = getIntent().getParcelableExtra(EXTRA_REQUEST);
         if (null == request) {
             setResult(
                     CredentialRetrieveResult.CODE_UNKNOWN,
                     CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
             finish();
             return;
         }
 
         BroadcastQueryClient.getInstance(this)
                 .queryFor(
                         CREDENTIAL_DATA_TYPE,
                         request.toProtocolBuffer(),
                         RETRIEVE_TIMEOUT_MS,
                         new CredentialRetrieveQueryCallback(request));
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         mIsDestroyed = true;
     }
 
 
     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<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 // 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.
 
                 if (response.getCredentialsAvailable()) {
-                    Intent retrieveIntent = new Intent(
+                    Intent retrieveIntent = ProviderResolver.createIntentForAction(
+                            CredentialRetrieveActivity.this.getApplicationContext(),
+                            queryResponse.responderPackage,
                             ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
-                    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);
                 } else if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: remove backwards compatibility with retrieve_intent after 0.3.0
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                     } else {
                         retrieveIntents.add(retrieveIntent);
                     }
                 }
             }
 
             if (retrieveIntents.isEmpty()) {
                 setResult(
                         CredentialRetrieveResult.CODE_PROVIDER_TIMEOUT,
                         CredentialRetrieveResult.PROVIDER_TIMEOUT.toResultDataIntent());
                 finish();
                 return;
             }
 
             if (retrieveIntents.size() == 1) {
                 forwardResultFromActivity(retrieveIntents.get(0));
                 return;
             }
 
             Intent intent = ProviderPickerActivity.createRetrieveIntent(
                     CredentialRetrieveActivity.this,
                     retrieveIntents);
 
             forwardResultFromActivity(intent);
         }
     }
 
     private void forwardResultFromActivity(Intent intent) {
         if (mIsDestroyed) {
             return;
         }
 
         intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(intent);
         finish();
     }
 }
diff --git a/api/java/org/openyolo/api/internal/ProviderResolver.java b/api/java/org/openyolo/api/internal/ProviderResolver.java
new file mode 100644
index 0000000..48cf46c
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/ProviderResolver.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import static org.openyolo.protocol.ProtocolConstants.OPENYOLO_CATEGORY;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility for producing OpenYOLO resolving the activities exposed by providers to handle specific,
+ * OpenYOLO actions.
+ */
+public final class ProviderResolver {
+
+    private ProviderResolver() {
+        // not intended to be constructed
+    }
+
+    /**
+     * Creates an explicit Intent to invoke the specified action on the specified provider,
+     * if the provider has a handler registered.
+     */
+    @Nullable
+    public static Intent createIntentForAction(
+            @NonNull Context applicationContext,
+            @NonNull String providerPackageName,
+            @NonNull String action) {
+
+        ComponentName providerComponent =
+                findProvider(applicationContext, providerPackageName, action);
+
+        if (providerComponent == null) {
+            return null;
+        }
+
+        Intent intent = new Intent(action);
+        intent.setClassName(
+                providerComponent.getPackageName(),
+                providerComponent.getClassName());
+        intent.addCategory(OPENYOLO_CATEGORY);
+        return intent;
+    }
+
+    /**
+     * Resolves a {@link ComponentName} for the activity defined in the specified provider, for
+     * the specified action.
+     */
+    @Nullable
+    public static ComponentName findProvider(
+            @NonNull Context applicationContext,
+            @NonNull String providerPackageName,
+            @NonNull String action) {
+        List<ComponentName> providers = findProviders(applicationContext, action);
+
+        for (ComponentName provider : providers) {
+            if (providerPackageName.equals(provider.getPackageName())) {
+                return provider;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Resolves the {@link ComponentName components} for all providers which can handle the
+     * specified OpenYOLO action.
+     */
+    @NonNull
+    public static List<ComponentName> findProviders(
+            @NonNull Context applicationContext,
+            @NonNull String action) {
+        Intent providerIntent = new Intent(action);
+        providerIntent.addCategory(OPENYOLO_CATEGORY);
+
+        List<ResolveInfo> resolveInfos =
+                applicationContext.getPackageManager()
+                        .queryIntentActivities(providerIntent, 0);
+
+        ArrayList<ComponentName> responders = new ArrayList<>();
+        for (ResolveInfo info : resolveInfos) {
+            responders.add(new ComponentName(
+                    info.activityInfo.packageName,
+                    info.activityInfo.name));
+        }
+
+        return responders;
+    }
+}
diff --git a/api/javatests/org/openyolo/api/internal/ProviderResolverTest.java b/api/javatests/org/openyolo/api/internal/ProviderResolverTest.java
new file mode 100644
index 0000000..1d3282b
--- /dev/null
+++ b/api/javatests/org/openyolo/api/internal/ProviderResolverTest.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.internal;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ResolveInfo;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.ProtocolConstants;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ProviderResolverTest {
+
+    private String EXAMPLE_PROVIDER_PACKAGE = "com.example.provider";
+    private String EXAMPLE_PROVIDER_ACTIVITY_CLASS = "com.example.provider.SaveActivity";
+
+    private ShadowPackageManager shadowPackageManager;
+    private Intent saveIntent;
+
+    @Before
+    public void setUp() {
+        saveIntent = new Intent(ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+        saveIntent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
+
+        shadowPackageManager =
+                Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
+    }
+
+    @Test
+    public void findProviders_noneInstalled() {
+        List<ComponentName> providers = ProviderResolver.findProviders(
+                RuntimeEnvironment.application,
+                ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+
+        assertThat(providers).isEmpty();
+    }
+
+    @Test
+    public void findProviders_singleInstalled() {
+        shadowPackageManager.addResolveInfoForIntent(
+                saveIntent,
+                createResolveInfo(EXAMPLE_PROVIDER_PACKAGE, EXAMPLE_PROVIDER_ACTIVITY_CLASS));
+
+        List<ComponentName> providers = ProviderResolver.findProviders(
+                RuntimeEnvironment.application,
+                ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+
+        ComponentName expectedComponent = new ComponentName(
+                EXAMPLE_PROVIDER_PACKAGE,
+                EXAMPLE_PROVIDER_ACTIVITY_CLASS);
+        assertThat(providers).containsExactly(expectedComponent);
+    }
+
+    @Test
+    public void findProvider_matchingPackage() {
+        shadowPackageManager.addResolveInfoForIntent(
+                saveIntent,
+                createResolveInfo(EXAMPLE_PROVIDER_PACKAGE, EXAMPLE_PROVIDER_ACTIVITY_CLASS));
+
+        ComponentName provider = ProviderResolver.findProvider(
+                RuntimeEnvironment.application,
+                EXAMPLE_PROVIDER_PACKAGE,
+                ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+
+        assertThat(provider).isNotNull();
+        assertThat(provider.getPackageName()).isEqualTo(EXAMPLE_PROVIDER_PACKAGE);
+        assertThat(provider.getClassName()).isEqualTo(EXAMPLE_PROVIDER_ACTIVITY_CLASS);
+    }
+
+    @Test
+    public void findProvider_nonMatchingPackage() {
+        shadowPackageManager.addResolveInfoForIntent(
+                saveIntent,
+                createResolveInfo(EXAMPLE_PROVIDER_PACKAGE, EXAMPLE_PROVIDER_ACTIVITY_CLASS));
+
+        ComponentName provider = ProviderResolver.findProvider(
+                RuntimeEnvironment.application,
+                "com.different.provider",
+                ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+
+        assertThat(provider).isNull();
+    }
+
+    @Test
+    public void createIntentForAction_matchingPackage() {
+        shadowPackageManager.addResolveInfoForIntent(
+                saveIntent,
+                createResolveInfo(EXAMPLE_PROVIDER_PACKAGE, EXAMPLE_PROVIDER_ACTIVITY_CLASS));
+
+        Intent intentForAction = ProviderResolver.createIntentForAction(
+                RuntimeEnvironment.application,
+                EXAMPLE_PROVIDER_PACKAGE,
+                ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+
+        assertThat(intentForAction).isNotNull();
+        assertThat(intentForAction.getAction())
+                .isEqualTo(ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+        assertThat(intentForAction.getCategories())
+                .containsExactly(ProtocolConstants.OPENYOLO_CATEGORY);
+        assertThat(intentForAction.getComponent()).isNotNull();
+        assertThat(intentForAction.getComponent().getPackageName())
+                .isEqualTo(EXAMPLE_PROVIDER_PACKAGE);
+        assertThat(intentForAction.getComponent().getClassName())
+                .isEqualTo(EXAMPLE_PROVIDER_ACTIVITY_CLASS);
+    }
+
+    @Test
+    public void createIntentForAction_nonMatchingPackage() {
+        shadowPackageManager.addResolveInfoForIntent(
+                saveIntent,
+                createResolveInfo(EXAMPLE_PROVIDER_PACKAGE, EXAMPLE_PROVIDER_ACTIVITY_CLASS));
+
+        Intent intentForAction = ProviderResolver.createIntentForAction(
+                RuntimeEnvironment.application,
+                "com.different.provider",
+                ProtocolConstants.SAVE_CREDENTIAL_ACTION);
+
+        assertThat(intentForAction).isNull();
+    }
+
+    private ResolveInfo createResolveInfo(String packageName, String activityClass) {
+        ResolveInfo resolveInfo = new ResolveInfo();
+        resolveInfo.activityInfo = new ActivityInfo();
+        resolveInfo.activityInfo.packageName = packageName;
+        resolveInfo.activityInfo.name = activityClass;
+
+        return resolveInfo;
+    }
+}

commit a2df8496a1f6749f9984a3d45e10914ee3dd88cf
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 25 15:49:58 2017 +0100

    Increase timeout for providers, add new timeout status code (#136)
    
    During testing with @nerdyverde we noticed that if the device is busy (such as
    installing app updates) that the two second timeout is often insufficient, resulting
    in failure to retrieve. This PR boosts the timeout to 4 seconds, and introduces
    an explicit timeout error code to make it easier to understand when this happens.

diff --git a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
index ca30cf9..7107269 100644
--- a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
+++ b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
@@ -39,136 +39,142 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * An invisible Activity that forwards a given {@link CredentialRetrieveRequest} based on the
  * the set of available credential providers capable of handling it. A
  * {@link CredentialRetrieveResult} will be returned as described by
  * {@link org.openyolo.api.CredentialClient#getCredentialRetrieveIntent(CredentialRetrieveRequest)}.
  */
 public final class CredentialRetrieveActivity extends Activity {
 
     private static final String LOG_TAG = "CredentialRetrieveAct";
     private static final String EXTRA_REQUEST = "Request";
 
+    // The amount of time we will permit providers to "think" about responding to a retrieve
+    // BBQ request. The default BBQ timeout of two seconds proved to be too short when the device
+    // is actively updating and compiling apps, so we extend it here.
+    private static final long RETRIEVE_TIMEOUT_MS = 4000;
+
     private boolean mIsDestroyed = false;
 
     /**
      * Returns an Intent for {@link CredentialRetrieveActivity} for the given
      * {@link CredentialRetrieveRequest}.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         return new Intent()
                 .setClass(context, CredentialRetrieveActivity.class)
                 .putExtra(EXTRA_REQUEST, request);
     }
 
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         getWindow().addFlags(LayoutParams.FLAG_NOT_TOUCHABLE);
 
         CredentialRetrieveRequest request = getIntent().getParcelableExtra(EXTRA_REQUEST);
         if (null == request) {
             setResult(
                     CredentialRetrieveResult.CODE_UNKNOWN,
                     CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
             finish();
             return;
         }
 
         BroadcastQueryClient.getInstance(this)
                 .queryFor(
                         CREDENTIAL_DATA_TYPE,
                         request.toProtocolBuffer(),
+                        RETRIEVE_TIMEOUT_MS,
                         new CredentialRetrieveQueryCallback(request));
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         mIsDestroyed = true;
     }
 
 
     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<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 // 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.
 
                 if (response.getCredentialsAvailable()) {
                     Intent retrieveIntent = new Intent(
                             ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
                     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);
                 } else if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: remove backwards compatibility with retrieve_intent after 0.3.0
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                     } else {
                         retrieveIntents.add(retrieveIntent);
                     }
                 }
             }
 
             if (retrieveIntents.isEmpty()) {
                 setResult(
-                        CredentialRetrieveResult.CODE_UNKNOWN,
-                        CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
+                        CredentialRetrieveResult.CODE_PROVIDER_TIMEOUT,
+                        CredentialRetrieveResult.PROVIDER_TIMEOUT.toResultDataIntent());
                 finish();
                 return;
             }
 
             if (retrieveIntents.size() == 1) {
                 forwardResultFromActivity(retrieveIntents.get(0));
                 return;
             }
 
             Intent intent = ProviderPickerActivity.createRetrieveIntent(
                     CredentialRetrieveActivity.this,
                     retrieveIntents);
 
             forwardResultFromActivity(intent);
         }
     }
 
     private void forwardResultFromActivity(Intent intent) {
         if (mIsDestroyed) {
             return;
         }
 
         intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(intent);
         finish();
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 1b4b899..6a47730 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -31,310 +31,324 @@ import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
 public final class CredentialRetrieveResult implements AdditionalPropertiesContainer {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE = ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that a credential was successfully chosen and has been returned as part of this
      * response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
+    /**
+     * Indicates that the provider(s) failed to respond in a timely manner. This error is usually
+     * transient, and due to the device being presently CPU-bound.
+     */
+    public static final int CODE_PROVIDER_TIMEOUT =
+            Protobufs.CredentialRetrieveResult.ResultCode.PROVIDER_TIMEOUT_VALUE;
+
     /**
      * Pre-built result that indicates that the provider returned a response that could not be
      * interpreted.
      */
     public static final CredentialRetrieveResult UNKNOWN =
             new CredentialRetrieveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built result that indicates that no provider was available and able to handle the
      * associated request.
      */
     public static final CredentialRetrieveResult NO_PROVIDER_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
+    /**
+     * Pre-built result that indicates that the provider(s) failed to respond in a timely manner.
+     * This error is usually transient, and due to the device being presently CPU-bound.
+     */
+    public static final CredentialRetrieveResult PROVIDER_TIMEOUT =
+            new CredentialRetrieveResult.Builder(CODE_PROVIDER_TIMEOUT).build();
+
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_CREDENTIAL_SELECTED == mResultCode;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
     }
 
     @Override
     @Nullable
     public byte[] getAdditionalProperty(String key) {
         return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
     }
 
     @Override
     @Nullable
     public String getAdditionalPropertyAsString(String key) {
         return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder
             implements AdditionalPropertiesBuilder<CredentialRetrieveResult, Builder> {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          * @throws MalformedDataException if the given protocol buffer was invalid.
          */
         private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setCredentialFromProto(proto.getCredential());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
                 throws MalformedDataException {
             if (null == credential
                     || Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = null;
             } else {
                 mCredential = Credential.fromProtobuf(credential);
             }
             return this;
         }
 
         @Override
         @NonNull
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
         @Override
         @NonNull
         public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
             AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
             return this;
         }
 
         @Override
         @NonNull
         public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
             AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         @Override
         @NonNull
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index 11349e9..919ce83 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -76,18 +76,19 @@ message CredentialRetrieveBbqResponseList {
 message CredentialRetrieveResult {
 
     enum ResultCode {
         UNSPECIFIED = 0;
         BAD_REQUEST = 1;
         CREDENTIAL_SELECTED = 2;
         NO_CREDENTIALS_AVAILABLE = 3;
         USER_REQUESTS_MANUAL_AUTH = 4;
         USER_CANCELED = 5;
         NO_PROVIDER_AVAILABLE = 6;
+        PROVIDER_TIMEOUT = 7;
     }
 
     // required
     ResultCode result_code = 1;
 
     Credential credential = 2;
     map<string, bytes> additional_props = 3;
 }

commit 4ab074de3a0d3ec3a3bf9223479ae12c423e1d59
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 25 14:40:49 2017 +0100

    Don't attempt to load unusable profile image URIs (#134)
    
    This was causing a red herring stack trace.

diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 6701c8c..79d0058 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -22,2 +22,3 @@ import android.util.AttributeSet;
 import android.util.Log;
+import android.util.Patterns;
 import android.view.View;
@@ -40,231 +41,238 @@ import org.valid4j.errors.RequireViolation;
 public final class CredentialView extends LinearLayout {
 
     private static final String TAG = "CredentialView";
 
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_email_provider_button)
     ImageButton mEmailProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
     /**
      * Simple constructor to use when creating a credential view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mEmailProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void setEmailAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
-        GlideApp.with(getContext())
-                .load(Uri.parse(mProfilePictureField.getText().toString()))
-                .fitCenter()
-                .into(mProfilePictureView);
+        String profilePictureUri = mProfilePictureField.getText().toString();
+
+        if (profilePictureUri.trim().isEmpty()
+                || !Patterns.WEB_URL.matcher(profilePictureUri).matches()) {
+            mProfilePictureView.setImageDrawable(null);
+        } else {
+            GlideApp.with(getContext())
+                    .load(Uri.parse(profilePictureUri))
+                    .fitCenter()
+                    .into(mProfilePictureView);
+        }
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Populates the fragment's fields from a given OpenYOLO hint.
      */
     public void setFieldsFromHint(Hint hint) {
         copyIfNotNull(hint.getIdentifier(), mIdField);
         copyIfNotNull(hint.getGeneratedPassword(), mPasswordField);
         copyIfNotNull(hint.getDisplayName(), mDisplayNameField);
         copyIfNotNull(hint.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(hint.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authMethodStr = mAuthenticationMethodField.getText().toString();
         AuthenticationMethod authMethod;
         try {
             authMethod = new AuthenticationMethod(authMethodStr);
         } catch (RequireViolation ex) {
             Log.w(TAG, "User entered authentication method " + authMethodStr + " is invalid", ex);
             return null;
         }
 
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethod,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         credentialBuilder.setPassword(mPasswordField.getText().toString());
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }

commit 784e30defb88a43a16f1f84304c6fbb8f0888fdf
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 25 12:05:49 2017 +0100

    Version bump for Android gradle plugin and support lib (#133)

diff --git a/build.gradle b/build.gradle
index 4d72ae1..1296516 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,15 +1,15 @@
 buildscript {
     repositories {
         jcenter()
         maven { url 'https://maven.google.com' }
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.0.0-beta7'
+        classpath 'com.android.tools.build:gradle:3.0.0-rc2'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
         classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }
@@ -55,4 +55,5 @@ project.ext.compileSdkVersion = 26
 project.ext.buildToolsVersion = '26.0.2'
-project.ext.supportLibVersion = '26.0.2'
-project.ext.archVersion = '1.0.0-alpha5'
+project.ext.supportLibVersion = '26.1.0'
+project.ext.archRuntimeVersion = '1.0.3'
+project.ext.archVersion = '1.0.0-rc1'
 project.ext.glideVersion = '4.0.0'
diff --git a/demoapps/passwordlogin/build.gradle b/demoapps/passwordlogin/build.gradle
index deef4b8..37c3e3f 100644
--- a/demoapps/passwordlogin/build.gradle
+++ b/demoapps/passwordlogin/build.gradle
@@ -29,19 +29,19 @@ android {
 dependencies {
     implementation project(':api')
-    implementation "android.arch.lifecycle:runtime:${rootProject.archVersion}"
+    implementation "android.arch.lifecycle:runtime:${rootProject.archRuntimeVersion}"
     implementation "android.arch.lifecycle:extensions:${rootProject.archVersion}"
     implementation "android.arch.persistence.room:runtime:${rootProject.archVersion}"
     implementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
     implementation "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
     implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     implementation "com.android.support:design:${rootProject.supportLibVersion}"
 
     implementation "com.github.bumptech.glide:glide:${rootProject.glideVersion}"
 
     annotationProcessor "android.arch.lifecycle:compiler:${rootProject.archVersion}"
     annotationProcessor "android.arch.persistence.room:compiler:${rootProject.archVersion}"
     annotationProcessor "com.github.bumptech.glide:compiler:${rootProject.glideVersion}"
 
     apply from: "${rootDir}/config/testdeps.gradle", to:it
     testImplementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java
index bcfa4af..f412bf5 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java
@@ -24,63 +24,68 @@ import android.support.annotation.Nullable;
 /**
  * A simple model of a user, with information to attempt authentication.
  */
 @Entity(tableName = "users", indices = {@Index(value = "email", unique = true)})
 public final class User {
 
     @PrimaryKey
     @ColumnInfo(name = "email")
+    @NonNull
     private final String mEmail;
 
     @ColumnInfo(name = "first_name")
+    @Nullable
     private final String mName;
 
     @ColumnInfo(name = "passwordSalt")
+    @NonNull
     private final String mPasswordSalt;
 
     @ColumnInfo(name = "passwordHash")
+    @NonNull
     private final String mPasswordHash;
 
     @ColumnInfo(name = "profile_picture_uri")
+    @Nullable
     private final String mProfilePictureUri;
 
     /**
      * Creates a user from their core attributes.
      */
     public User(
             @NonNull String email,
             @Nullable String name,
             @NonNull String passwordSalt,
             @NonNull String passwordHash,
             @Nullable String profilePictureUri) {
         mName = name;
         mEmail = email;
         mPasswordSalt = passwordSalt;
         mPasswordHash = passwordHash;
         mProfilePictureUri = profilePictureUri;
     }
 
     @NonNull
     public String getEmail() {
         return mEmail;
     }
 
     @Nullable
     public String getName() {
         return mName;
     }
 
     @NonNull
     public String getPasswordSalt() {
         return mPasswordSalt;
     }
 
     @NonNull
     public String getPasswordHash() {
         return mPasswordHash;
     }
 
     @Nullable
     public String getProfilePictureUri() {
         return mProfilePictureUri;
     }
 }

commit 7edbce2320270a0f5ab01b4c00df3688ac4f30ee
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Mon Oct 23 15:22:52 2017 +0100

    Remove usage of response intents from retrieve BBQ flow (#132)
    
    Fix for #131. In order to avoid the potential for code injection and request forgery attacks
    from malicious providers, this change deprecates the use of intents as part of the retrieve
    BBQ flow. Instead, providers now signal the availability of credentials via a simple boolean.
    Optionally, they can also specify preloaded data that the client should send back to them
    verbatim, as a replacement for the ability to specify intent extras on returned intents.

diff --git a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
index e1130af..ca30cf9 100644
--- a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
+++ b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
@@ -21,4 +21,4 @@ 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;
@@ -31,5 +31,3 @@ import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import org.openyolo.protocol.CredentialRetrieveRequest;
@@ -37,3 +35,3 @@ import org.openyolo.protocol.CredentialRetrieveResult;
 import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
+import org.openyolo.protocol.ProtocolConstants;
 import org.openyolo.protocol.internal.IntentUtil;
@@ -41,121 +39,136 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * An invisible Activity that forwards a given {@link CredentialRetrieveRequest} based on the
  * the set of available credential providers capable of handling it. A
  * {@link CredentialRetrieveResult} will be returned as described by
  * {@link org.openyolo.api.CredentialClient#getCredentialRetrieveIntent(CredentialRetrieveRequest)}.
  */
 public final class CredentialRetrieveActivity extends Activity {
 
     private static final String LOG_TAG = "CredentialRetrieveAct";
     private static final String EXTRA_REQUEST = "Request";
 
     private boolean mIsDestroyed = false;
 
     /**
      * Returns an Intent for {@link CredentialRetrieveActivity} for the given
      * {@link CredentialRetrieveRequest}.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         return new Intent()
                 .setClass(context, CredentialRetrieveActivity.class)
                 .putExtra(EXTRA_REQUEST, request);
     }
 
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         getWindow().addFlags(LayoutParams.FLAG_NOT_TOUCHABLE);
 
         CredentialRetrieveRequest request = getIntent().getParcelableExtra(EXTRA_REQUEST);
         if (null == request) {
             setResult(
                     CredentialRetrieveResult.CODE_UNKNOWN,
                     CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
             finish();
             return;
         }
 
         BroadcastQueryClient.getInstance(this)
                 .queryFor(
                         CREDENTIAL_DATA_TYPE,
                         request.toProtocolBuffer(),
-                        new CredentialRetrieveQueryCallback());
+                        new CredentialRetrieveQueryCallback(request));
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         mIsDestroyed = true;
     }
 
 
     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<>();
-            Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
-                protoResponses.put(queryResponse.responderPackage, response);
-
-                if (response.getRetrieveIntent().isEmpty()) {
-                    continue;
-                }
-
-                Intent retrieveIntent;
-                try {
-                    retrieveIntent =
+                // 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.
+
+                if (response.getCredentialsAvailable()) {
+                    Intent retrieveIntent = new Intent(
+                            ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
+                    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);
+                } else if (!response.getRetrieveIntent().isEmpty()) {
+                    // TODO: remove backwards compatibility with retrieve_intent after 0.3.0
+                    Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
-                } catch (BadParcelableException ex) {
-                    Log.w(LOG_TAG, "Failed to parse intent from bytes");
-                    continue;
-                }
 
-                if (!queryResponse.responderPackage.equals(
-                        retrieveIntent.getComponent().getPackageName())) {
-                    Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
-                    continue;
+                    if (!queryResponse.responderPackage.equals(
+                            retrieveIntent.getComponent().getPackageName())) {
+                        Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
+                    } else {
+                        retrieveIntents.add(retrieveIntent);
+                    }
                 }
-
-                retrieveIntents.add(retrieveIntent);
             }
 
             if (retrieveIntents.isEmpty()) {
                 setResult(
                         CredentialRetrieveResult.CODE_UNKNOWN,
                         CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
                 finish();
                 return;
             }
 
             if (retrieveIntents.size() == 1) {
                 forwardResultFromActivity(retrieveIntents.get(0));
                 return;
             }
 
             Intent intent = ProviderPickerActivity.createRetrieveIntent(
                     CredentialRetrieveActivity.this,
                     retrieveIntents);
 
             forwardResultFromActivity(intent);
         }
     }
 
     private void forwardResultFromActivity(Intent intent) {
         if (mIsDestroyed) {
             return;
         }
 
         intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(intent);
         finish();
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
index 3be6944..5776987 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
@@ -17,3 +17,2 @@ package org.openyolo.demoprovider.barbican.provider;
 import android.content.Context;
-import android.content.Intent;
 import android.support.annotation.NonNull;
@@ -30,3 +29,2 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
-import org.openyolo.protocol.internal.IntentUtil;
 import org.openyolo.spi.BaseCredentialQueryReceiver;
@@ -34,66 +32,62 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Implements the OpenYOLO credential query receiver. This receiver is able to determine whether
  * a credential exists for the claimed set of authentication domains without unlocking the
  * password store.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull final Context context,
             @NonNull final BroadcastQuery query,
             @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // NOTE: in a more complete implementation, this is where we would expand the set of
         // authentication domains listed in requestorDomains to all equivalent authentication
         // domains (such as affiliated apps and sites). This potentially larger list would then be
         // matched against the requested set of domains.
 
         Log.i(LOG_TAG, "Processing query for " + query.getRequestingApp());
 
         CredentialStorage storage;
         try {
             storage = new CredentialStorage(context);
         }  catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to open credential storage", ex);
             responseSender.sendResponse(query, null);
             return;
         }
 
         boolean credentialsFound = false;
         byte[] responseBytes = null;
 
         Iterator<AuthenticationDomain> authDomainIter = requestorDomains.iterator();
         while (!credentialsFound && authDomainIter.hasNext()) {
             credentialsFound = storage.hasCredentialFor(authDomainIter.next().toString());
         }
 
         Log.d(LOG_TAG, "Credentials found for "
                 + query.getRequestingApp() + ": "
                 + credentialsFound);
 
-        if (credentialsFound) {
-            Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context, request);
-            CredentialRetrieveBbqResponse response =
-                    CredentialRetrieveBbqResponse.newBuilder()
-                            .setRetrieveIntent(IntentUtil.toByteString(retrieveIntent))
-                            .build();
-            responseBytes = response.toByteArray();
-        }
-
-        responseSender.sendResponse(query, responseBytes);
+        responseSender.sendResponse(
+                query,
+                CredentialRetrieveBbqResponse.newBuilder()
+                        .setCredentialsAvailable(credentialsFound)
+                        .build()
+                        .toByteArray());
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
index 9e1377a..3c4017b 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -22,3 +22,2 @@ import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import com.google.protobuf.ByteString;
 import java.util.Set;
@@ -28,3 +27,2 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
-import org.openyolo.protocol.internal.IntentUtil;
 import org.openyolo.spi.BaseCredentialQueryReceiver;
@@ -32,46 +30,46 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
  * we respond to all requests with an intent as long as the
  * {@link org.openyolo.protocol.AuthenticationMethods#EMAIL email} authentication method is
  * supported.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         Log.i(LOG_TAG, "Processing retrieve query from claimed caller: "
                 + query.getRequestingApp());
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // Ensure the caller supports the email authentication method
         if (!request.getAuthenticationMethods().contains(AuthenticationMethods.EMAIL)) {
             responseSender.sendResponse(query,  null /* response */);
             return;
         }
 
         Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
         CredentialRetrieveBbqResponse response = CredentialRetrieveBbqResponse.newBuilder()
-                .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
+                .setCredentialsAvailable(true)
                 .build();
 
         Log.i(LOG_TAG, "Accepting credential request for claimed caller: "
                 + query.getRequestingApp());
         responseSender.sendResponse(query, response.toByteArray());
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
index adb893e..b4d110c 100644
--- a/protocol/java/org/openyolo/protocol/ProtocolConstants.java
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -17,79 +17,88 @@ package org.openyolo.protocol;
 /**
  * Defines key constants that are used to identify data carried in intents.
  */
 public final class ProtocolConstants {
 
     /**
      * The data type used for credential queries using the BBQ protocol.
      */
     public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
 
     /**
      * The extra value key used to carry a credential retrieve request.
      */
     public static final String EXTRA_RETRIEVE_REQUEST = "org.openyolo.credential.retrieve.request";
 
     /**
      * The extra value key used to carry a credential retrieve result.
      */
     public static final String EXTRA_RETRIEVE_RESULT = "org.openyolo.credential.retrieve.result";
 
+    /**
+     * The extra value key used to carry preloaded data as part of a credential retrieve Intent.
+     * This data is supplied by the credential provider during the broadcast phase of the retrieve
+     * flow, and sent back verbatim. The provider _should not_ implicitly trust this data, as it
+     * is possible for the client to tamper with it.
+     */
+    public static final String EXTRA_RETRIEVE_PRELOADED_DATA =
+            "org.openyolo.credential.retrieve.preloaded_data";
+
     /**
      * The extra key value used to carry a hint request.
      */
     public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
 
     /**
      * The extra key value used to carry a hint result.
      */
     public static final String EXTRA_HINT_RESULT = "org.openyolo.hint.result";
 
     /**
      * The extra key value used to carry a credential save request.
      */
     public static final String EXTRA_SAVE_REQUEST = "org.openyolo.credential.save.request";
 
     /**
      * The extra key value used to carry a credential save result.
      */
     public static final String EXTRA_SAVE_RESULT = "org.openyolo.credential.save.result";
 
     /**
      * The category used for all OpenYOLO-related intents.
      */
     public static final String OPENYOLO_CATEGORY = "org.openyolo";
 
     /**
      * The action used for credential retrieval request intents.
      */
     public static final String RETRIEVE_CREDENTIAL_ACTION = "org.openyolo.credential.retrieve";
 
     /**
      * The action used for hint intents.
      */
     public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
 
     /**
      * The action used for save intents.
      */
     public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.credential.save";
 
     /**
      * The action used for delete intents.
      */
     public static final String DELETE_CREDENTIAL_ACTION = "org.openyolo.credential.delete";
 
     /**
      * The extra key value used to carry a credential deletion request.
      */
     public static final String EXTRA_DELETE_REQUEST = "org.openyolo.credential.delete.request";
 
     /**
      * The extra key value used to carry a credential deletion result.
      */
     public static final String EXTRA_DELETE_RESULT = "org.openyolo.credential.delete.result";
 
     private ProtocolConstants() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/RetrieveBbqResponse.java b/protocol/java/org/openyolo/protocol/RetrieveBbqResponse.java
deleted file mode 100644
index 497d1bf..0000000
--- a/protocol/java/org/openyolo/protocol/RetrieveBbqResponse.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.protocol;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.valid4j.Assertive.require;
-
-import android.content.Intent;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import com.google.protobuf.InvalidProtocolBufferException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
-import org.openyolo.protocol.internal.IntentUtil;
-
-/**
- * A response to a {@link CredentialRetrieveRequest credential retrieve request}.
- */
-public class RetrieveBbqResponse implements Parcelable {
-
-    /**
-     * Parcelable reader for {@link RetrieveBbqResponse} instances.
-     * @see android.os.Parcelable
-     */
-    public static final Creator<RetrieveBbqResponse> CREATOR = new RetrieveResultCreator();
-
-    @Nullable
-    private final Intent mRetrieveIntent;
-
-    @NonNull
-    private final Map<String, CredentialRetrieveBbqResponse> mResponses;
-
-    private RetrieveBbqResponse(
-            @Nullable Intent retrieveIntent,
-            @NonNull Map<String, CredentialRetrieveBbqResponse> responses) {
-        mRetrieveIntent = retrieveIntent;
-        mResponses = responses;
-    }
-
-    /**
-     * An intent that can be used to retrieve a credential for the calling app. If no credentials
-     * are available, this will be {@code null}. User input may or may not be required to retrieve
-     * the credential, at the discretion of the credential provider. The retrieve intent
-     * should be fired when the app is ready to retrieve the credential - typically immediately
-     * after the retrieve result is received.
-     */
-    @Nullable
-    public Intent getRetrieveIntent() {
-        return mRetrieveIntent;
-    }
-
-    /**
-     * The package names of responding credential providers that indicated they may have a usable
-     * credential.
-     */
-    @NonNull
-    public Set<String> getResponderPackageNames() {
-        return mResponses.keySet();
-    }
-
-    /**
-     * Retrieves the intent for the specified responder package name, if available.
-     */
-    @NonNull
-    public Intent getRetrieveIntentForResponder(@NonNull String responderPackageName) {
-        require(responderPackageName, notNullValue());
-        CredentialRetrieveBbqResponse response = mResponses.get(responderPackageName);
-        if (response == null) {
-            throw new IllegalArgumentException(responderPackageName + " is not a responder");
-        }
-
-        return IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
-    }
-
-    /**
-     * Retrieves the additional, non-standard response parameters for the specified responder
-     * package name, if available.
-     */
-    @NonNull
-    public Map<String, byte[]> getAdditionalPropsForResponder(String responderPackageName) {
-        CredentialRetrieveBbqResponse response = mResponses.get(responderPackageName);
-        if (response == null) {
-            throw new IllegalArgumentException(responderPackageName + " is not a responder");
-        }
-
-        return CollectionConverter.convertMapValues(
-                response.getAdditionalPropsMap(),
-            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
-    }
-
-    /**
-     * Creates {@link RetrieveBbqResponse} instances.
-     */
-    public static final class Builder {
-
-        @Nullable
-        private Intent mIntent;
-
-        @NonNull
-        private Map<String, CredentialRetrieveBbqResponse> mProtoResponses;
-
-        /**
-         * Starts the process of describing a credential retrieve result.
-         */
-        public Builder() {
-            mIntent = null;
-            mProtoResponses = Collections.emptyMap();
-        }
-
-        /**
-         * Specifies the map of protocol buffer responses received for the credential request,
-         * keyed by the package name of the responder.
-         */
-        @NonNull
-        public Builder setProtoResponses(
-                @NonNull Map<String, CredentialRetrieveBbqResponse> protoResponses) {
-            require(protoResponses, notNullValue());
-            for (CredentialRetrieveBbqResponse value : protoResponses.values()) {
-                require(value, notNullValue());
-            }
-            mProtoResponses = protoResponses;
-            return this;
-        }
-
-        /**
-         * Specifies the retrieve intent, that can be used to retrieve existing credentials from
-         * the provider, if available.
-         */
-        @NonNull
-        public Builder setRetrieveIntent(@Nullable Intent intent) {
-            mIntent = intent;
-            return this;
-        }
-
-        /**
-         * Creates a {@link RetrieveBbqResponse} with the properties described to the builder.
-         */
-        @NonNull
-        public RetrieveBbqResponse build() {
-            return new RetrieveBbqResponse(mIntent, mProtoResponses);
-        }
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeParcelable(mRetrieveIntent, 0);
-        dest.writeInt(mResponses.size());
-
-        for (String key : mResponses.keySet()) {
-            byte[] responseBytes = mResponses.get(key).toByteArray();
-            dest.writeString(key);
-            dest.writeInt(responseBytes.length);
-            dest.writeByteArray(responseBytes);
-        }
-    }
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    static final class RetrieveResultCreator implements Creator<RetrieveBbqResponse> {
-        @Override
-        public RetrieveBbqResponse createFromParcel(Parcel in) {
-            Intent retrieveIntent = in.readParcelable(Intent.class.getClassLoader());
-            int numResponses = in.readInt();
-
-            Map<String, CredentialRetrieveBbqResponse> responses = new HashMap<>(numResponses);
-            for (int i = 0; i < numResponses; i++) {
-                String key = in.readString();
-                int responseSize = in.readInt();
-                byte[] responseBytes = new byte[responseSize];
-                in.readByteArray(responseBytes);
-
-                CredentialRetrieveBbqResponse response;
-                try {
-                    response = CredentialRetrieveBbqResponse.parseFrom(responseBytes);
-                } catch (InvalidProtocolBufferException ex) {
-                    throw new IllegalArgumentException("Unable to parse response proto");
-                }
-
-                responses.put(key, response);
-            }
-
-            return new RetrieveBbqResponse.Builder()
-                    .setRetrieveIntent(retrieveIntent)
-                    .setProtoResponses(responses)
-                    .build();
-        }
-
-        @Override
-        public RetrieveBbqResponse[] newArray(int size) {
-            return new RetrieveBbqResponse[size];
-        }
-    }
-
-}
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
deleted file mode 100644
index c8f2c9a..0000000
--- a/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.protocol;
-
-import static junit.framework.TestCase.assertNotNull;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-import android.content.Intent;
-import android.os.Parcel;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.protocol.internal.IntentUtil;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
-
-/**
- * Battery of tests for the RetrieveIntent class
- */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public class RetrieveResultTest {
-
-    private RetrieveBbqResponse underTest;
-
-    @Before
-    public void setUp() throws Exception {
-        Intent fromIntent = new Intent("com.openyolo.ACTION");
-        fromIntent.setPackage("com.openyolo");
-        byte[] fromBytes = IntentUtil.toBytes(fromIntent);
-        Intent retrieveIntent= IntentUtil.fromBytes(fromBytes);
-
-        Map<String, Protobufs.CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
-
-        underTest = new RetrieveBbqResponse.Builder()
-                .setProtoResponses(protoResponses)
-                .setRetrieveIntent(retrieveIntent)
-                .build();
-    }
-
-    @Test
-    public void testGetRetrieveIntent(){
-        Intent intent = underTest.getRetrieveIntent();
-        assertNotNull(intent);
-    }
-
-    @Test
-    public void testGetResponderPackageNames(){
-        Set<String> responders = underTest.getResponderPackageNames();
-        assertNotNull(responders);
-    }
-
-    @Test(expected = RequireViolation.class)
-    public void testGetRetrieveIntentForResponder_null(){
-        underTest.getRetrieveIntentForResponder(null);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testGetRetrieveIntentForResponder_illegal(){
-        underTest.getRetrieveIntentForResponder("BLahblah");
-    }
-
-    @Test
-    public void testWriteAndRead() {
-        Parcel p = Parcel.obtain();
-        underTest.writeToParcel(p, 0);
-        p.setDataPosition(0);
-
-        RetrieveBbqResponse result = RetrieveBbqResponse.CREATOR.createFromParcel(p);
-        checkIntentsEquivalent(underTest.getRetrieveIntent(), result.getRetrieveIntent());
-        assertThat(result.getResponderPackageNames())
-                .isEqualTo(underTest.getResponderPackageNames());
-
-        for (String responder : result.getResponderPackageNames()) {
-            checkIntentsEquivalent(
-                    underTest.getRetrieveIntentForResponder(responder),
-                    result.getRetrieveIntentForResponder(responder));
-
-            assertThat(result.getAdditionalPropsForResponder(responder))
-                    .isEqualTo(underTest.getAdditionalPropsForResponder(responder));
-        }
-    }
-
-    private void checkIntentsEquivalent(Intent expected, Intent actual) {
-        // NOTE: we don't check the full intent, just the basic properties
-        assertThat(actual.getPackage())
-                .isEqualTo(expected.getPackage());
-        assertThat(actual.getAction())
-                .isEqualTo(expected.getAction());
-    }
-}
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index 80bfbd1..11349e9 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -1,15 +1,15 @@
 /*
- * Copyright 2016 Google Inc. All Rights Reserved.
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
@@ -35,4 +35,36 @@ message CredentialRetrieveRequest {
 message CredentialRetrieveBbqResponse {
-    bytes retrieve_intent = 1;
+    /**
+     * Prior to OpenYOLO 0.3.0, a provider would directly supply the Intent for the client to
+     * invoke via this retrieve_intent field. This exposes the client to a number of possible
+     * security vulnerabilities:
+     *
+     * - A cross-app request forgery attack if the Intent is targeted at a different app.
+     * - A code injection attack exploiting deserialization bugs (see CVE-2015-3837)
+     *
+     * As such, this has now been deprecated in favor of the credentials_available and
+     * preloaded_data fields. The client will now construct the Intent itself if the provider
+     * sets credentials_available to true. The preloaded_data field should be treated as an opaque
+     * byte array from the client's perspective, and if provided should be handed back verbatim to
+     * the provider via an Intent extra. The provider, of course, should not implicitly trust this
+     * data as it is possible for the client to tamper with it. As such, the client
+     */
+    bytes retrieve_intent = 1 [deprecated=true];
+
+    /**
+     * Additional, non-standard properties that the provider can supply as part of the response.
+     */
     map<string, bytes> additional_props = 2;
+
+    /**
+     * Indicates whether the provider believes it has credentials available matching the client's
+     * request.
+     */
+    bool credentials_available = 3;
+
+    /**
+     * Additional data that the client should send back verbatim, as an Intent extra, to the
+     * provider if the client chooses to invoke this provider for credential retrieval. The
+     * byte array should be treated as opaque and meaningless from the client's perspective.
+     */
+    bytes preloaded_data = 4;
 }

commit 9b7394ffcffb38d51e30208fbc94ba0397262518
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 11 15:02:26 2017 -0700

    Rename getDeleteResult to getCredentialDeleteResult (#129)
    
    Fix for #128.

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 1d7cda1..a326437 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -61,656 +61,656 @@ import org.openyolo.protocol.MalformedDataException;
 /**
  * The primary way of interacting with OpenYOLO credential providers. The client is light weight
  * allowing new instances to be created as needed.
  *
  * Requests are executed by starting an Activity based intent and its result returned via
  * {@link android.app.Activity#onActivityResult(int, int, Intent)}. For each request/response pair
  * there exist two client methods:
  * 1) Takes a given request and returns the Activity Intent which sends the request.
  * 2) Takes an Intent returned via {@link android.app.Activity#onActivityResult(int, int, Intent)}
  *    and returns the associated result.
  *
  * For example using the retrieve credential flow:
  * <pre>{@code
  * CredentialClient client = CredentialClient.getInstance(getContext());
  * // ...
  *
  * CredentialRetrieveRequest request  =
  *     CredentialRetrieveRequest.fromAuthMethods(
  *         AuthenticationMethods.EMAIL,
  *         AuthenticationMethods.GOOGLE);
  * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
  * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
  *
  * // ...
  * @Override
  * public void onActivityResult(int requestCode, int resultCode, Intent data) {
  *     super.onActivityResult(requestCode, resultCode, data);
  *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
  *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
  *        // handle result ...
  *     }
  * }
  * }</pre>
  *
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#operations">
  *     OpenYOLO Specification: Operations</a>
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private final Context mApplicationContext;
     private final AppSettings mDeviceState;
 
     /**
      * Returns a new credential client instance configured with the default options.
      */
     public static CredentialClient getInstance(@NonNull Context context) {
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(AppSettingsImpl.getInstance(context)).build();
 
         return getInstance(context, options);
     }
 
     /**
      * Returns a new credential client instance configured with the given
      * {@link CredentialClientOptions}.
      */
     public static CredentialClient getInstance(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         return new CredentialClient(context, options);
     }
 
     @VisibleForTesting
     CredentialClient(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         validate(context, notNullValue(), NullPointerException.class);
         validate(options, notNullValue(), NullPointerException.class);
 
         mApplicationContext = context.getApplicationContext();
         mDeviceState = options.getDeviceState();
     }
 
     /**
      * Provides an Activity intent to request any available {@link Credential credentials} from the
      * credential providers on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getCredentialRetrieveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * // ...
      *
      * CredentialRetrieveRequest request  =
      *     CredentialRetrieveRequest.fromAuthMethods(
      *         AuthenticationMethods.EMAIL,
      *         AuthenticationMethods.GOOGLE);
      * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
      * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
      *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getCredentialRetrieveResult(Intent)
      */
     @NonNull
     public Intent getCredentialRetrieveIntent(CredentialRetrieveRequest request) {
         if (mDeviceState.isAutoSignInDisabled()) {
             request = new CredentialRetrieveRequest.Builder(request)
                     .setRequireUserMediation(true)
                     .build();
         }
 
         return CredentialRetrieveActivity.createIntent(mApplicationContext, request);
     }
 
     /**
      * Provides an Activity intent to request any available {@link org.openyolo.protocol.Hint hints}
      * from the credential providers on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getHintRetrieveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * // ...
      *
      * HintRetrieveRequest request  =
      *     HintRetrieveRequest.fromAuthMethods(
      *         AuthenticationMethods.EMAIL,
      *         AuthenticationMethods.GOOGLE);
      * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
      * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_HINT == requestCode) {
      *        HintRetrieveResult result = client.getHintRetrieveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getHintRetrieveResult(Intent)
      */
     @NonNull
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE,
                     HintRetrieveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Creates a {@link CredentialSaveRequest request} from the given credential.
      *
      * @see #getSaveIntent(Credential)
      */
     @NonNull
     public Intent getSaveIntent(final Credential credential) {
         return getSaveIntent(CredentialSaveRequest.fromCredential(credential));
     }
 
     /**
      * Provides an Activity intent to save the provided credential.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getCredentialSaveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * Credential credential = <Valid Credential>;
      * // ...
      *
      * CredentialSaveRequest request  = CredentialSaveRequest.fromCredential(credential);
      * Intent saveCredentialIntent = client.getSaveIntent(request);
      * startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_SAVE_CREDENTIAL == requestCode) {
      *        CredentialSaveResult result = client.getCredentialSaveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getCredentialSaveResult(Intent)
      */
     @NonNull
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     CredentialSaveResult.CODE_NO_PROVIDER_AVAILABLE,
                     CredentialSaveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Creates a {@link CredentialDeleteRequest request} from the given credential.
      *
      * @see #getDeleteIntent(CredentialDeleteRequest)
      */
     @NonNull
     public Intent getDeleteIntent(@NonNull Credential credential) {
         require(credential, notNullValue());
 
         return getDeleteIntent(CredentialDeleteRequest.fromCredential(credential));
     }
 
     /**
      * Provides an Activity intent to delete the given {@link Credential credential} from the
      * credential provider on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
-     * {@link #getDeleteResult(Intent)} using the Intent data received in the associated
+     * {@link #getCredentialDeleteResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * Credential credential = <Credential that is no longer valid>;
      * // ...
      *
      * Intent deleteCredentialIntent = client.getDeleteIntent(request);
      * startActivityForResult(deleteCredentialIntent, RC_DELETE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_DELETE_CREDENTIAL == requestCode) {
-     *         result = client.getDeleteResult(data);
+     *         result = client.getCredentialDeleteResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
-     * @see #getDeleteResult(Intent)
+     * @see #getCredentialDeleteResult(Intent)
      */
     @NonNull
     public Intent getDeleteIntent(@NonNull CredentialDeleteRequest request) {
         require(request, notNullValue());
 
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     CredentialDeleteResult.CODE_NO_PROVIDER_AVAILABLE,
                     CredentialDeleteResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Returns the result of a {@link CredentialRetrieveResult}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
      *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
      *        if (result.isSuccessful()) {
      *          // A credential was retrieved, you may automatically sign the user in.
      *          result.getCredential();
      *        } else {
      *          // A credential was not retrieved, you may look at the result code to determine why
      *          // and decide what step to take next. For example, result code may inform you of the
      *          // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
      *          result.getResultCode();
      *        }
      *     }
      * }
      * }</pre>
      *
      *
      * @see #getCredentialRetrieveIntent(CredentialRetrieveRequest)
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return CredentialRetrieveResult.UNKNOWN;
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return CredentialRetrieveResult.UNKNOWN;
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return CredentialRetrieveResult.UNKNOWN;
         }
 
         try {
             CredentialRetrieveResult result =
                     CredentialRetrieveResult.fromProtobufBytes(resultBytes);
 
             // Once a successfully retrieve result has been handled, re-enable auto sign-in.
             if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
                 mDeviceState.setIsAutoSignInDisabled(false);
             }
 
             return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return CredentialRetrieveResult.UNKNOWN;
         }
     }
 
     /**
      * Returns the result of a {@link HintRetrieveResult}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_HINT == requestCode) {
      *        HintRetrieveResult result = client.getHintRetrieveResult(data);
      *        if (result.isSuccessful()) {
      *          // A hint was retrieved, you may be able to automatically create an account for the
      *          // user, or offer the user to sign in if an existing account matches the hint.
      *          result.getHint();
      *        } else {
      *          // A credential was not retrieved, you may look at the result code to determine why
      *          // and decide what step to take next. For example, result code may inform you of the
      *          // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
      *          result.getResultCode();
      *        }
      *     }
      * }
      * }</pre>
      *
      * @see #getHintRetrieveIntent(HintRetrieveRequest)
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return HintRetrieveResult.UNKNOWN;
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return HintRetrieveResult.UNKNOWN;
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return HintRetrieveResult.UNKNOWN;
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return HintRetrieveResult.UNKNOWN;
         }
     }
 
     /**
      * Returns the result of a {@link CredentialSaveRequest}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_SAVE_CREDENTIAL == requestCode) {
      *        CredentialSaveResult result = client.getCredentialSaveResult(data);
      *        // Most people will not need to check the result of a save request. Simply fire and
      *        // forget.
      *     }
      * }
      * }</pre>
      *
      * @see #getSaveIntent(CredentialSaveRequest)
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return CredentialSaveResult.UNKNOWN;
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return CredentialSaveResult.UNKNOWN;
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return CredentialSaveResult.UNKNOWN;
         }
     }
 
     /**
      * Returns the result of a {@link CredentialDeleteRequest}.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_DELETE_CREDENTIAL == requestCode) {
      *        CredentialSaveResult result = client.getCredentialSaveResult(data);
      *        // Most people will not need to check the result of a delete request. Simply fire and
      *        // forget.
      *     }
      * }
      * }</pre>
      *
      * @see #getDeleteIntent(CredentialDeleteRequest)
      */
     @NonNull
-    public CredentialDeleteResult getDeleteResult(Intent resultData) {
+    public CredentialDeleteResult getCredentialDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     /**
      * Disables automatically signing in a user until a successful response is given to
      * {@link CredentialClient#getCredentialRetrieveResult(Intent)}. Instead a user is required to
      * interact with the providers (e.g. click the credential they would like to sign in) before a
      * credential is returned.
      *
      * This feature allows clients to easily avoid a common case where a user signs out and is then
      * automatically signed back in. By calling this method when a user is signed out no additional
      * logic to track the user's intention is required.
      * <pre>{@code
      *
      * // ...
      * public void signOutUser() {
      *     // Your application's custom sign out logic.
      *     // ...
      *     CredentialClient client = CredentialClient.getInstance(getContext());
      *     client.disableAutoSignIn();
      * }
      * }</pre>
      */
     public void disableAutoSignIn() {
         mDeviceState.setIsAutoSignInDisabled(true);
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
index bdb59a6..c85119d 100644
--- a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
@@ -31,94 +31,94 @@ import org.openyolo.protocol.CredentialDeleteResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential deletion flow.
  */
 public class DeleteTestPageFragment extends TestPageFragment  {
 
     private static final int RC_DELETE = 100;
 
     @BindView(R.id.credential_to_delete)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.delete_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.delete_button)
     void onDelete() {
         Credential credential = mCredentialView.makeCredentialFromFields();
         if (credential == null) {
             showSnackbar(R.string.invalid_credential_data);
             return;
         }
 
         startActivityForResult(mApi.getDeleteIntent(credential), RC_DELETE);
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_DELETE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
-        CredentialDeleteResult deleteResult = mApi.getDeleteResult(data);
+        CredentialDeleteResult deleteResult = mApi.getCredentialDeleteResult(data);
 
         @StringRes
         int resultMessageId;
         switch (deleteResult.getResultCode()) {
             case CredentialDeleteResult.CODE_DELETED:
                 resultMessageId = R.string.delete_result_deleted;
                 break;
             case CredentialDeleteResult.CODE_NO_PROVIDER_AVAILABLE:
                 resultMessageId = R.string.delete_no_provider_available;
                 break;
             case CredentialDeleteResult.CODE_NO_MATCHING_CREDENTIAL:
                 resultMessageId = R.string.delete_result_no_matching_credential;
                 break;
             case CredentialDeleteResult.CODE_PROVIDER_REFUSED:
                 resultMessageId = R.string.delete_result_provider_refused;
                 break;
             case CredentialDeleteResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.delete_result_user_canceled;
                 break;
             case CredentialDeleteResult.CODE_USER_REFUSED:
                 resultMessageId = R.string.delete_result_user_refused;
                 break;
             case CredentialDeleteResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.delete_result_bad_request;
                 break;
             default:
                 resultMessageId = R.string.delete_result_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @Override
     public String getPageTitle() {
         return "Delete";
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }

commit fc892f118a615a33b9fb6b71c5b079728c6f2579
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Mon Oct 9 15:23:09 2017 -0700

    SmartLock manual migration guide (#123)
    
    This is the first complete pass of documenting how to migrate from
    the Smart Lock for Passwords API to the OpenYOLO API.

diff --git a/docs/how-to-migrate-from-smartlock.md b/docs/how-to-migrate-from-smartlock.md
new file mode 100644
index 0000000..f5dc8fa
--- /dev/null
+++ b/docs/how-to-migrate-from-smartlock.md
@@ -0,0 +1,744 @@
+# Migrating from the Google Smart Lock for Passwords API to OpenYOLO
+
+Google will continue to offer the Smart Lock for Passwords standalone API for
+the foreseeable future. In 2018, the Smart Lock for Passwords API will start
+automatically using the OpenYOLO protocol if other OpenYOLO providers are
+available on the device, however we encourage developers with the available
+resources to explicitly move to the OpenYOLO API, as this is where all future
+work and innovation will occur. The OpenYOLO API also offers other
+non-functional benefits, such as simpler code that is easier to test.
+
+This document describes how to migrate your current integration with the
+Google Smart Lock for Passwords to the OpenYOLO API. If your application does
+not currently utilize Smart Lock for Passwords, we recommend instead reading
+the main [README](../README.md), which contains a getting started guide and
+links to other resources.
+
+OpenYOLO for Android is intended to be the open-standards based successor to
+the Google Smart Lock for Passwords API. OpenYOLO provides the same
+functionality and UX flows as Google Smart Lock for Passwords, while also
+allowing the user to choose from any compatible credential manager.
+
+Migration is a straightforward process, as the APIs are structurally very
+similar. This document will demonstrate how to migrate to the OpenYOLO API for
+each API method that is offered in the Smart Lock for Passwords API.
+
+## Importing the OpenYOLO API
+
+To use the OpenYOLO API, first add the API as a dependency on your project. If
+you do not use any of the other Google authentication features (like Google
+Sign-in), you can also remove the dependency on Play Services Authentication:
+
+```diff
+dependencies {
+-  // optionally, remove play services auth if you no longer require it
+-  implementation 'com.google.android.gms:play-services-auth:x.y.z'
++  // add the OpenYOLO API
++  implementation 'org.openyolo:openyolo-api:x.y.z'
+}
+```
+
+Unlike Smart Lock for Passwords, the OpenYOLO client library will work on
+devices without Google Play Services.
+
+## Account hints
+
+Smart Lock for Passwords defined the concept of a hint request, which allows
+an app to solicit a credential to simplify new account creation or existing
+account discovery. Hints provide a user identifier and authentication method,
+and may optionally include a display name, profile picture and generated
+password.
+
+### Sending a hint request
+
+In both the Smart Lock for Passwords API and the OpenYOLO API, Intents are used
+to communicate with the user’s credential provider to retrieve an account hint.
+
+With Smart Lock for Passwords, a hint request for an email, phone number or
+Google Sign-in based account would be constructed and dispatched as follows:
+
+```java
+// deprecated: this is the old way of doing things
+void sendSmartLockHintRequest() {
+  PendingIntent hintPickerIntent =
+      Auth.CredentialsApi.getHintPickerIntent(
+          mGoogleApiClient,
+          new HintRequest.Builder()
+              .setEmailAddressIdentifierSupported(true)
+              .setPhoneNumberIdentifierSupported(true)
+              .setAccountTypes(IdentityProviders.GOOGLE)
+              .setIdTokenRequested(true)
+              .setServerClientId(MY_GOOGLE_CLIENT_ID)
+              .setIdTokenNonce(“nonceValue”)
+              .build());
+
+  startIntentSenderForResult(
+      hintPickerIntent.getIntentSender(),
+      RC_HINT,
+      null, // fillInIntent
+      0, // flagsMask
+      0, // flagsValues
+      0); // extraFlags
+}
+```
+
+This code assumes that a `GoogleApiClient` instance has already been created and
+connected. Such pre-flight initialization is not necessary for OpenYOLO,
+where the initialization can be fully synchronous, and the code changes to the
+following:
+
+```java
+private mCredentialClient =
+    CredentialClient.getApplicationBoundInstance(this);
+
+void sendOpenYoloHintRequest() {
+  Map<String, TokenRequestInfo> tokenProviders = new HashMap();
+  tokenProviders.put(
+      "https://accounts.google.com",
+      new TokenRequestInfo.Builder()
+          .setClientId(MY_GOOGLE_CLIENT_ID)
+          .setNonce("randomlyGeneratedNonce")
+          .build());
+
+  Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
+      new HintRetrieveRequest.Builder(
+          AuthenticationMethods.EMAIL,
+          AuthenticationMethods.PHONE,
+          AuthenticationMethods.GOOGLE)
+          .setTokenProviders(tokenProviders)
+          .build());
+
+  startActivityForResult(hintIntent, RC_HINT);
+}
+```
+
+The key differences to note are:
+
+- The `CredentialClient` is easier to create than a `GoogleApiClient` instance:
+  a `Context` reference is all that is required, with no asynchronous
+  initialization.
+
+- Account types from the Smart Lock for Passwords API are now “authentication
+  methods”, with email auth, phone auth and federated authentication methods
+  all treated in a consistent manner.
+
+- A plain `Intent` is used instead of a `PendingIntent`.
+
+One may also notice the new `setTokenProviders` method - in an effort to support
+acquiring ID tokens from additional providers, clients are now encouraged to
+explicitly declare the ID token providers they support (e.g. Google,
+Microsoft), along with any provider-specific parameters that may be required.
+Currently, OpenYOLO directly supports specifying your application’s OpenID
+Connect client ID and an ID token nonce value.
+
+### Receiving a hint response
+
+Hint responses are delivered to the application via onActivityResult in both
+the Smart Lock and OpenYOLO APIs. Both indicate the success or failure of the
+request via a result code and Intent extras, though the data is structurally
+different.
+
+With Smart Lock for Passwords:
+
+```java
+// deprecated: this is the old way of doing things
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+
+  if (requestCode == RC_HINT && resultCode == RESULT_OK) {
+    Credential credential =
+        data.getParcelableExtra(Credential.EXTRA_KEY);
+    if (credential == null) {
+      authenticateManually();
+    } else {
+      processSmartLockCredentialAsHint(credential);
+    }
+  }
+}
+```
+
+With OpenYOLO:
+
+```java
+@Override
+protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+
+  if (requestCode == RC_HINT) {
+    HintRetrieveResult result =
+        mCredentialClient.getHintRetrieveResult(data);
+
+    if (result.isSuccessful()) {
+      // condition is equivalent to:
+      // result.getResultCode() == HintRetrieveResult.CODE_HINT_SELECTED
+      Hint hint = result.getHint();
+      processOpenYoloHint(hint);
+    } else {
+      authenticateManually();
+      return;
+    }
+  }
+}
+```
+
+The standard result codes for hint retrieval are all defined as constants on
+the `HintRetrieveResult` class. The result codes in OpenYOLO are more detailed
+than those returned by Smart Lock for Passwords, providing more information
+particularly in the cases where a hint is not returned:
+
+- `CODE_HINT_SELECTED`: The user selected a hint, which can be retrieved by
+  calling the `getHint()` method.
+
+- `CODE_BAD_REQUEST`: The request was malformed in some way. The `getHint()`
+  method will return `null`.
+
+- `CODE_NO_HINTS_AVAILABLE`: There are no hints available in the user’s
+  credential manager that match the request type. The `getHint()` method will
+  return `null`.
+
+- `CODE_USER_REQUESTS_MANUAL_AUTH`: The user has indicated via their credential
+  manager that they wish to manually authenticate. The `getHint()` method will
+  return `null`.
+
+- `CODE_USER_CANCELED`: The user canceled the hint retrieval flow, such as by
+  pressing the back button or tapping outside of a selection dialog. The
+  `getHint()` method will return `null`.
+
+- `CODE_UNKNOWN`: The credential provider failed to handle the hint request.
+  The `getHint()` method will return `null`.
+
+### Processing a returned hint
+
+In the Smart Lock for Passwords API, the same `Credential` type is returned for
+both hint and existing credential requests. In OpenYOLO, a separate `Hint` type
+is introduced - this is intended to help clarify that hints and credentials are
+related but not identical, and will allow for future evolution of hints and
+credentials that may diverge.
+
+OpenYOLO also provides generated passwords with hints. The constraints for
+these passwords can be specified using a `PasswordSpecification` instance,
+optionally provided as a parameter on the HintRequest.
+
+In Smart Lock for Passwords, a hint would be processed as follows:
+
+```java
+// deprecated: this is the old way of doing things
+void processSmartLockCredentialAsHint(Credential credential) {
+  if (credential.getAccountType() == null) {
+    // this is not a federated account. It is not easy to distinguish
+    // between email and phone number accounts with this API,
+    // other than by heuristically evaluating the contents of the
+    // identifier.
+    if (isPhoneNumber(credential.getId()) {
+      createPhoneNumberAccount(
+        credential.getId(),
+        credential.getDisplayName(),
+        credential.getProfilePictureUri());
+    } else {
+      createEmailAccount(credential.getId());
+    }
+
+  } else if (IdentityProviders.GOOGLE.equals(
+      credential.getAccountType()) {
+    // this is a Google Sign-in account. First, see if we have an ID
+    // token that can be used to directly authenticate.
+    if (credential.getIdTokens().size() > 0) {
+      authWithIdToken(credential.getIdTokens().get(0));
+    } else {
+      // if there is no ID token, use the Google Sign-in API to
+      // authenticate.
+      signInWithGoogle(credential.getId());
+    }
+  }
+}
+```
+
+With OpenYOLO, this changes to:
+
+```java
+void processOpenYoloHint(Credential credential) {
+  if (AuthenticationMethods.PHONE.equals(
+      hint.getAuthenticationMethod())) {
+    createPhoneNumberAccount(
+        hint.getId(),
+        hint.getDisplayName(),
+        hint.getDisplayPictureUri());
+
+  } else if (AuthenticationMethods.EMAIL.equals(
+      hint.getAuthenticationMethod())) {
+    // note that we can now use the generated password as part of the
+    // account creation process.
+    createEmailAccount(
+        hint.getId(),
+        hint.getDisplayName(),
+        hint.getDisplayPictureUri(),
+        hint.getGeneratedPassword());
+
+  } else if (AuthenticationMethods.GOOGLE.equals(
+      hint.getAuthenticationMethod())) {
+    // this is a Google Sign-in account. First, see if we have an ID
+    // token that can be used to directly authenticate.
+    if (hint.getIdToken() != null) {
+      authWithIdtoken(hint.getIdToken());
+    } else {
+      // if there is no ID token, use the Google Sign-in API to
+      // authenticate.
+      signInWithGoogle(hint.getId());
+    }
+  }
+}
+```
+
+The notable changes here are that:
+
+- OpenYOLO's authentication methods are more explicit and easier to work with
+  than the mix of identifier inference and account types that Smart Lock for
+  Passwords provided (e.g. the unspecified `isPhoneNumber` method above).
+
+- OpenYOLO guarantees that at most one ID token will be returned; the
+  use case for multiple ID tokens in the Smart Lock for Passwords API never
+  materialized, so the API in OpenYOLO has been simplified to reflect this.
+
+The properties available on Smart Lock's `Credential` type align to the
+properties on OpenYOLO's `Hint` type as follows:
+
+| *Credential method*    | *Hint method*             | *Notes*                 |
+|------------------------|---------------------------|-------------------------|
+| getId()                | getIdentifier()           |                         |
+| getAccountType()       | getAuthenticationMethod() | Both are URI-based, but OpenYOLO defines URIs for email, phone number and username based auth in addition to the same semantics for federated credentials. |
+| getName()              | getDisplayName()          |                         |
+| getProfilePictureUri() | getDisplayPicture()       |                         |
+| getIdTokens()          | getIdToken()              |                         |
+| getGeneratedPassword() | getGeneratedPassword()    | This was not a fully implemented feature in Smart Lock for Passwords, but it is in OpenYOLO; a password will be randomly generated by the credential provider that conforms to the password specification provided in the request. |
+| getFamilyName()        | N/A  | Not defined in the OpenYOLO specification, as this assumes too much culture-specific structure to names. |
+| getGivenName()         | N/A  | Not defined in the OpenYOLO specification, for the same reasons as for `getFamilyName`. |
+| getPassword()          | N/A  | Not applicable to OpenYOLO hints, which do not conflate existing and generated credentials in this way. See `getGeneratedPassword`. |
+| N/A | getAdditionalProperties() | OpenYOLO offers extensibility for Hints via a general map of strings to byte arrays. |
+
+## Existing accounts
+
+Smart Lock for Passwords offers access to existing credentials stored in a
+user's Google account, either automatically or via single tap consent from the
+user. OpenYOLO offers the same functionality, with a restructured API that
+focuses on convenience for the developer.
+
+### Sending a retrieve request
+
+In Smart Lock for Passwords, requesting existing credentials is broken into
+two stages:
+
+1. A credential request is constructed and dispatched, with the initial
+   response delivered via a callback. The callback will either directly contain
+   the credential (automatic sign-in), provide an `Intent` to be invoked
+   (user consent required), or return nothing (no credentials available).
+2. If an `Intent` is provided, this must be invoked and the result captured in
+   `onActivityResult`.
+
+APIs which rely on multiple asynchronous steps, where the responses are
+delivered through different mechanisms, are inherently hard to understand. For
+OpenYOLO, this process has been simplified such that an `Intent` is directly
+created and used for the request, and all processing can be handled via
+`onActivityResult`.
+
+In Smart Lock for Passwords, an existing credential retrieval for an
+app that supports password login, ID token auth for Google accounts, and
+Facebook Sign-in would look like:
+
+```java
+// deprecated: this is the old way of doing things
+void sendSmartLockRetrieveRequest() {
+  CredentialRequest cr = new CredentialRequest.Builder()
+      .setPasswordLoginSupported(true)
+      .setAccountTypes(
+          IdentityProviders.GOOGLE,
+          IdentityProviders.FACEBOOK)
+      .setIdTokenRequested(true)
+      .setServerClientId(GOOGLE_CLIENT_ID)
+      .setIdTokenNonce("randomlyGeneratedNonce")
+      .build();
+
+  Auth.CredentialsApi.request(mGoogleApiClient, cr)
+      .setResultCallback(this::handleSmartLockRequestInitialResult);
+}
+
+void handleSmartLockRequestInitialResult(CredentialRequestResult result) {
+  if (result.getStatus().isSuccess()) {
+    signInWithSmartLockCredential(result.getCredential());
+  } else if (result.getStatus().getStatusCode()
+      == CommonStatusCodes.RESOLUTION_REQUIRED) {
+    try {
+      result.getStatus().startResolutionForResult(this, RC_RETRIEVE);
+      return;
+    } catch (IntentSender.SendIntentException e) {
+      Log.e(TAG, "Oh no :(");
+    }
+  }
+
+  startManualAuthentication();
+}
+
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+  super.onActivityResult(requestCode, resultCode, data);
+
+  if (requestCode == RC_RETRIEVE) {
+    if (resultCode == RESULT_OK) {
+      Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
+      signInWithSmartLockCredential(credential);
+    } else {
+      // user canceled or the request failed
+      startManualAuthentication();
+    }
+  }
+}
+```
+
+The multiple paths to either `signInWithSmartLockCredential` or
+`startManualAuthentication` can be hard to follow. In OpenYOLO, this is
+simplified to:
+
+```java
+void sendOpenYoloRetrieveRequest() {
+  CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
+      AuthenticationMethods.EMAIL,
+      AuthenticationMethods.GOOGLE,
+      AuthenticationMethods.FACEBOOK)
+      .addTokenProvider(
+          "https://accounts.google.com",
+          new TokenRequestInfo.Builder()
+              .setClientId(GOOGLE_CLIENT_ID),
+              .setNonce("randomlyGeneratedNonce")
+              .build())
+      .build();
+
+  startActivityForResult(
+      mOpenYoloClient.getCredentialRetrieveIntent(request),
+      RC_RETRIEVE);
+}
+
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+  super.onActivityResult(requestCode, resultCode, data);
+
+  if (requestCode == RC_RETRIEVE) {
+    CredentialRetrieveResult result =
+        mCredentialClient.getCredentialRetrieveResult(data);
+    if (result.isSuccessful()) {
+      // condition is equivalent to:
+      // result.getResultCode() ==
+      //     CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED
+      signInWithOpenYoloCredential(result.getCredential());
+    } else {
+      // no credential available; further information can be found if necessary
+      // by checking the other status codes defined in CredentialRetrieveResult,
+      // but in most cases manual authentication is the only recourse.
+      startManualAuthentication();
+    }
+  }
+}
+```
+
+Automatic sign-in and consent based sign-in are not distinguished in OpenYOLO;
+both are still possible, but the differences are not exposed via the API to
+the client application.
+
+## Processing the credential response
+
+Smart Lock for Passwords and OpenYOLO both have `Credential` types, which are
+very similar, though as previously noted OpenYOLO distinguishes hints and
+existing credentials through different types.
+
+A credential from Smart Lock for Passwords would be consumed as follows:
+
+```java
+// deprecated: this is the old way of doing things
+void signInWithSmartLockCredential(Credential credential) {
+  if (credential.getIdTokens().size() > 0) {
+    // an ID token was returned, which should be used as the secure alternative
+    // to password auth whenever possible.
+    authWithIdToken(credential.getIdTokens().get(0));
+    return;
+  }
+
+  String at = credential.getAccountType();
+  if (at == null) {
+    // this is not a federated account, so it must be a password based
+    // account.
+    authWithPassword(credential.getId(), credential.getPassword());
+  } else if (at.equals(IdentityProviders.GOOGLE)) {
+    // Use the Google Sign-in API to authenticate.
+    authWithGoogle(credential.getId());
+  } else if (at.equals(IdentityProviders.FACEBOOK)) {
+    // Use the Facebook SDK to authenticate
+    authWithFacebook(credential.getId());
+  } else {
+    Log.w(TAG, "Smart Lock returned unknown credential type, ignoring");
+    startManualAuthentication();
+  }
+}
+```
+
+With OpenYOLO:
+
+```java
+void signInWithOpenYoloCredential(Credential credential) {
+
+  if (credential.getIdToken() != null) {
+    authWithIdToken(credential.getIdToken());
+    return;
+  }
+
+  AuthenticationMethod am = credential.getAuthenticationMethod();
+  if (am.equals(AuthenticationMethods.EMAIL)) {
+    authWithPassword(credential.getIdentifier(), credential.getPassword());
+  } else if (am.equals(AuthenticationMethods.GOOGLE)) {
+    authWithGoogle(credential.getIdentifier());
+  } else if (am.equals(AuthenticationMethods.FACEBOOK)) {
+    authWithFacebook(credential.getIdentifier());
+  } else {
+    Log.w(TAG, "Smart Lock returned unknown credential type, ignoring");
+    startManualAuthencation();
+  }
+}
+```
+
+As can be seen, the code is structurally very similar. The properties on the
+Smart Lock credential type map to the OpenYOLO credential type as follows:
+
+| *Smart Lock Credential method* | *OpenYOLO Credential method* | *Notes*      |
+|------------------------|---------------------------|-------------------------|
+| getId()                        | getIdentifier()              |              |
+| getAccountType()               | getAuthenticationMethod()    | Both are URI-based, but OpenYOLO does not leave password auth as an implicit "other option"; all OpenYOLO credentials must have a defined authentication method, which makes processing the credentials easier. |
+| getPassword()          | getPassword()                        |              |
+| getName()              | getDisplayName()                     |              |
+| getProfilePictureUri() | getDisplayPicture()                  |              |
+| getIdTokens()          | getIdToken()                         |              |
+| getGeneratedPassword() | N/A                                  | As OpenYOLO credentials are specific to the existing account case, generated passwords are not applicable. |
+| getFamilyName()        | N/A                                  | Not defined in the OpenYOLO specification, as this assumes too much culture-specific structure to names. |
+| getGivenName()         | N/A                                  | Not defined in the OpenYOLO specification, for the same reasons as for `getFamilyName`. |
+| N/A                    | getAdditionalProperties()            | OpenYOLO offers extensibility for Credentials via a general map of strings to byte arrays. |
+
+## Saving Credentials
+
+When a credential is determined to be valid, it can be saved to the user's
+credential provider. In the Smart Lock for Passwords API, this was a two-step
+process similar to calling `retrieve()`:
+
+1. The credential is constructed and sent to Smart Lock for Passwords using the
+   `save()` method, with a callback provided. This callback is then invoked,
+   indicating whether the save succeeded, user consent is required to save
+   the credential (a `PendingIntent` is returned), or the save was rejected.
+
+2. If an `Intent` is returned, the developer must invoke this `PendingIntent` in
+   order to prompt the user to save the credential. The result of this is
+   indicated via `onActivityResult()`.
+
+To simplify the API in OpenYOLO, an `Intent` is directly created and used to
+save the credential.
+
+In Smart Lock for Passwords, a credential would be saved as follows:
+
+```java
+// deprecated: this is the old way of doing things
+void saveSmartLockCredential(Credential credential) {
+  Auth.CredentialsApi.save(mGoogleApiClient, credential)
+      .setResultCallback(this::handleSmartLockSaveResult);
+}
+
+void handleSmartLockSaveResult(Status status) {
+  if (status.isSuccess()) {
+      // credential automatically saved
+  } else if (status.hasResolution()) {
+      try {
+          status.startResolutionForResult(this, RC_SAVE);
+      } catch (IntentSender.SendIntentException e) {
+          Log.e(TAG, "Oh no :(");
+      }
+  } else {
+      // save refused by provider or failed.
+      // ...
+  }
+}
+
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+
+  if (requestCode == RC_SAVE) {
+    if (resultCode = RESULT_OK) {
+      // credential saved
+      // ...
+    } else {
+      // credential not saved
+      // ...
+    }
+  }
+}
+```
+
+With OpenYOLO, this is simplified to:
+
+```java
+void saveOpenYoloCredential(Credential credential) {
+  Intent saveIntent = mOpenYoloClient.getSaveIntent(credential);
+  startActivityForResult(saveIntent, RC_SAVE);
+}
+
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+  if (requestCode == RC_SAVE) {
+    CredentialSaveResult result =
+           mCredentialClient.getCredentialSaveResult(data);
+    if (result.isSuccessful()) {
+      // credential was saved. condition is equivalent to:
+      // resultCode == CredentialSaveResult.CODE_SAVED
+    } else {
+      // credential not saved. OpenYOLO distinguishes the failure cases via
+      // additional result codes defined in CredentialSaveResult. Two
+      // particularly useful additional cases are CODE_USER_CANCELED and
+      // CODE_USER_REFUSED, as in some cases an application may wish to handle
+      // these differently.
+      // ...
+    }
+}
+```
+
+There is one additional case to consider for OpenYOLO: as hints are represented
+through a different type, if a new account created through the hint flow is
+to be saved, it is necessary to convert that `Hint` to a `Credential`. This
+can be easily achieved as follows:
+
+```java
+Credential.Builder crBuilder = hint.toCredentialBuilder(this);
+// ... make any necessary changes or additions ...
+saveOpenYoloCredential(crBuilder.build());
+```
+
+This carries across all of the equivalent fields from the hint to the
+credential, including copying any generated password (from
+`getGeneratedPassword()`) into the regular password field (via
+`setPassword()` on `Credential.Builder`). In most cases, further modification
+of the credential is not required, but a builder is returned rather than
+a fully constructed `Credential` to make this convenient when necessary.
+
+## Handling sign out
+
+As Smart Lock for Passwords and OpenYOLO retrieve requests can both result in
+automatic sign-in, it is important to avoid a "sign-in loop" if a user chooses
+to sign out. This can occur where the first activity executed after signing
+out is the login activity; if this invokes the Smart Lock / OpenYOLO retrieve
+flows, this can result in automatically signing in the user again, without
+providing them any opportunity to intervene.
+
+This is prevented in Smart Lock for Passwords by invoking the
+`disableAutoSignIn` method:
+
+```java
+// deprecated: this is the old way of doing things
+void signOut() {
+  Auth.CredentialsApi.disableAutoSignIn(mGoogleApiClient);
+  discardAuthToken();
+  goToLogin();
+}
+```
+
+The same method is provided in the OpenYOLO API:
+
+```java
+void signOut() {
+  mOpenYoloClient.disableAutoSignIn();
+  discardAuthToken();
+  goToLogin();
+}
+```
+
+OpenYOLO stores this state, by default, using a shared preferences file in the
+context of the client application. This behavior can be customized, to save
+this preference wherever you wish, by providing an alternative implementation
+of `AppSettings` via the `CredentialClientOptions` type, which can be provided
+to a `CredentialClient` during construction.
+
+Automatic sign-in can also be explicitly disabled in OpenYOLO at the start of
+the retrieve flow, by setting the `requireUserMediation` property to `true`:
+
+```java
+void sendOpenYoloRetrieveRequest() {
+  CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
+      AuthenticationMethods.EMAIL)
+      // ... other settings
+      setRequireUserMediation(true)
+      .build();
+
+  startActivityForResult(
+      mOpenYoloClient.getCredentialRetrieveIntent(request),
+      RC_RETRIEVE);
+}
+```
+
+## Deleting invalid credentials
+
+Occasionally, a credential held by the user's credential manager is found to
+be invalid during authentication. A client can request that this credential
+be deleted, in order to avoid the frustrating experience of a stale credential
+being offered to the user repeatedly.
+
+Smart Lock for Passwords follows the same two-stage pattern as retrieve and
+save for this functionality, and looks like the following:
+
+```java
+// deprecated: this is the old way of doing things
+void deleteSmartLockCredential(Credential credential) {
+  Auth.CredentialsApi.delete(mGoogleApiClient, credential)
+      .setResultCallback(this::handleSmartLockDeleteResult);
+}
+
+void handleSmartLockDeleteResult(Status status) {
+  if (status.isSuccess()) {
+    // credential automatically deleted
+  } else if (status.hasResolution()) {
+    try {
+      status.startResolutionForResult(this, RC_DELETE);
+    } catch (IntentSender.SendIntentException e) {
+      Log.e(TAG, "Oh no :(");
+    }
+  } else {
+    // delete refused by provider or failed
+  }
+}
+
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+  super.onActivityResult(requestCode, resultCode, data);
+  if (requestCode == RC_DELETE) {
+    if (resultCode == RESULT_OK) {
+      // credential deleted
+    } else {
+      // credential not deleted
+    }
+  }
+}
+```
+
+In OpenYOLO, an `Intent` is used, simplifying the code to the following:
+
+```java
+void deleteOpenYoloCredential(Credential credential) {
+  Intent deleteIntent = mCredentialClient.getDeleteIntent(credential);
+  startActivityForResult(deleteIntent, RC_DELETE);
+}
+
+@Override protected void onActivityResult(
+    int requestCode, int resultCode, Intent data) {
+  super.onActivityResult(requestCode, resultCode, data);
+  if (requestCode == RC_DELETE) {
+    CredentialDeleteResult result =
+        mCredentialClient.getCredentialDeleteResult();
+    if (result.isSuccessful()) {
+      // credential deleted. Condition is equivalent to:
+      // resultCode == CredentialDeleteResult.CODE_DELETED
+    } else {
+      // credential not deleted. OpenYOLO distinguishes the reasons that a
+      // credential has not been deleted via the additional status codes defined
+      // in CredentialDeleteResult.
+    }
+  }
+```

commit 33138129d128743fa49e5a953065082641a4c952
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Mon Oct 9 11:33:56 2017 -0700

     Improved tests for QueryResponseSender (#126)
    
    - Don't rely on mocks
    - Test based on actual broadcasts sent

diff --git a/bbq/java/com/google/bbq/QueryResponseSender.java b/bbq/java/com/google/bbq/QueryResponseSender.java
index cc46888..25f6688 100644
--- a/bbq/java/com/google/bbq/QueryResponseSender.java
+++ b/bbq/java/com/google/bbq/QueryResponseSender.java
@@ -18,2 +18,3 @@ import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -30,56 +31,56 @@ import com.google.protobuf.ByteString;
 /**
  * A utility for data providers that encodes and sends query responses.
  */
 public class QueryResponseSender {
 
     private static final String LOG_TAG = "QueryResponseSender";
 
     private final Context mContext;
 
     /**
      * Creates a response sender.
      */
     public QueryResponseSender(@NonNull Context context) {
         mContext = require(context, notNullValue());
     }
 
     /**
      * Dispatches a query response message for the specified query.
      */
     public void sendResponse(
             @NonNull BroadcastQuery query,
             @Nullable byte[] responseMessage) {
-        require(query, notNullValue());
+        validate(query, notNullValue(), NullPointerException.class);
 
         BroadcastQueryResponse.Builder responseBuilder = createResponseBuilder(query);
         if (responseMessage != null) {
             responseBuilder.setResponseMessage(ByteString.copyFrom(responseMessage));
         }
 
         Intent responseBroadcast = getIntentForQuery(query, responseBuilder);
 
         mContext.sendBroadcast(responseBroadcast);
     }
 
     @VisibleForTesting
     @NonNull
     Intent getIntentForQuery(@NonNull BroadcastQuery query,
                              BroadcastQueryResponse.Builder responseBuilder) {
         Intent responseBroadcast =
                 new Intent(QueryUtil.createResponseAction(
                         query.getDataType(),
                         query.getRequestId()));
         responseBroadcast.addCategory(QueryUtil.BBQ_CATEGORY);
         responseBroadcast.setPackage(query.getRequestingApp());
         responseBroadcast.putExtra(
                 QueryUtil.EXTRA_RESPONSE_MESSAGE,
                 responseBuilder.build().toByteArray());
         return responseBroadcast;
     }
 
     private BroadcastQueryResponse.Builder createResponseBuilder(BroadcastQuery query) {
         return BroadcastQueryResponse.newBuilder()
                 .setRequestId(query.getRequestId())
                 .setResponseId(query.getResponseId());
     }
 }
diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
index a98f503..aa58851 100644
--- a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
@@ -18,62 +18,86 @@ package com.google.bbq;
 
-import static org.mockito.Mockito.verify;
-import static org.mockito.internal.verification.VerificationModeFactory.times;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import android.content.Context;
 import android.content.Intent;
-import android.support.annotation.NonNull;
 import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.Protobufs.BroadcastQueryResponse;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.InvalidProtocolBufferException;
+
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.valid4j.errors.RequireViolation;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
 
 
 /**
  * This class contains a set of tests for QueryResponseSenderTest.
  */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
 public class QueryResponseSenderTest {
-    @Mock
-    Context mockContext;
-    @Mock
-    Intent mockIntent;
 
-    BroadcastQuery mockQuery;
-
-    private QueryResponseSender underTest;
+    private BroadcastQuery mQuery;
+    private QueryResponseSender mResponseSender;
 
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
         //set mock values.
-        mockQuery = BroadcastQuery.newBuilder()
-            .setDataType("dataType")
-            .setRequestingApp("requestingApp")
+        mQuery = BroadcastQuery.newBuilder()
+            .setDataType("example")
+            .setRequestingApp("com.example.app")
             .setRequestId(128L)
             .setResponseId(256L)
             .build();
 
-        //Create a test object for the QueryResponseSender using the mock
-        underTest = new QueryResponseSender(mockContext) {
-            @NonNull
-            @Override
-            Intent getIntentForQuery(@NonNull BroadcastQuery query, BroadcastQueryResponse.Builder responseBuilder) {
-                return mockIntent;
-            }
-        };
+        mResponseSender = new QueryResponseSender(RuntimeEnvironment.application);
+    }
+
+    @Test
+    public void sendResponse() throws Exception {
+        byte[] responseMessageBytes = new byte[] { 0, 1, 2 };
+        mResponseSender.sendResponse(mQuery, responseMessageBytes);
+        checkBroadcastResponse(ByteString.copyFrom(responseMessageBytes));
     }
 
     @Test
     public void sendResponse_nonNullQuery_nullReponse() throws Exception {
-        underTest.sendResponse(mockQuery, null);
-        verify(mockContext, times(1)).sendBroadcast(mockIntent);
+        mResponseSender.sendResponse(mQuery, null);
+        checkBroadcastResponse(ByteString.EMPTY);
     }
 
-    @Test(expected = RequireViolation.class)
+    private void checkBroadcastResponse(ByteString expectedResponseBytes)
+            throws InvalidProtocolBufferException {
+        List<Intent> broadcasts =
+                Shadows.shadowOf(RuntimeEnvironment.application).getBroadcastIntents();
+
+        assertThat(broadcasts.size()).isEqualTo(1);
+        Intent broadcastIntent = broadcasts.get(0);
+
+        assertThat(broadcastIntent.getAction())
+                .isEqualTo("example:0000000000000080");
+        assertThat(broadcastIntent.getCategories()).containsExactly(QueryUtil.BBQ_CATEGORY);
+        assertThat(broadcastIntent.getPackage()).isEqualTo(mQuery.getRequestingApp());
+        assertThat(broadcastIntent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE)).isNotNull();
+
+        byte[] responseBytes = broadcastIntent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
+        BroadcastQueryResponse response = BroadcastQueryResponse.parseFrom(responseBytes);
+
+        assertThat(response.getRequestId()).isEqualTo(mQuery.getRequestId());
+        assertThat(response.getResponseId()).isEqualTo(mQuery.getResponseId());
+        assertThat(response.getResponseMessage()).isEqualTo(expectedResponseBytes);
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test
     public void sendResponse_nullQuery_nullReponse() throws Exception {
-        underTest.sendResponse(null, null);
+        assertThatThrownBy(() -> mResponseSender.sendResponse(null, null))
+                .isInstanceOf(NullPointerException.class);
     }
-}
\ No newline at end of file
+}

commit 77659c6b22b25e55889b90c0314bc9bc0482ae92
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Fri Oct 6 15:07:39 2017 -0700

    Version bump for build tools (#125)
    
    * Version bump for build tools
    
    * Force acceptance for Android SDK license
    
    * Accept preview build licenses
    
    * Update build tools version on travis config
    
    * Disable lint violation for old custom lint rules
    
    Butterknife defines a custom lint rule and is apparently using
    the old API. Ignore this, as it only affects demo apps.

diff --git a/.travis.yml b/.travis.yml
index f2b03da..631349d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,4 +5,4 @@ language: android
 android:
   components:
-    - build-tools-26.0.1
+    - build-tools-26.0.2
     - android-26
@@ -19 +19,4 @@ cache:
     - $HOME/.m2
+licenses:
+  - 'android-sdk-license-.+'
+  - 'android-sdk-preview-license.+'
diff --git a/build.gradle b/build.gradle
index 64ae061..4d72ae1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,15 +1,15 @@
 buildscript {
     repositories {
         jcenter()
         maven { url 'https://maven.google.com' }
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.0.0-beta2'
+        classpath 'com.android.tools.build:gradle:3.0.0-beta7'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
         classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }
@@ -54,4 +54,4 @@ project.ext.minSdkVersion = 15
 project.ext.compileSdkVersion = 26
-project.ext.buildToolsVersion = '26.0.1'
-project.ext.supportLibVersion = '26.0.1'
+project.ext.buildToolsVersion = '26.0.2'
+project.ext.supportLibVersion = '26.0.2'
 project.ext.archVersion = '1.0.0-alpha5'
diff --git a/config/android-common.gradle b/config/android-common.gradle
index be65155..0264015 100644
--- a/config/android-common.gradle
+++ b/config/android-common.gradle
@@ -1,40 +1,40 @@
 android {
     compileSdkVersion rootProject.ext.compileSdkVersion
     buildToolsVersion rootProject.ext.buildToolsVersion
 
     defaultConfig {
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.compileSdkVersion
         versionCode rootProject.ext.versionNum
         versionName rootProject.ext.versionName
     }
 
     compileOptions {
         sourceCompatibility = JavaVersion.VERSION_1_8
         targetCompatibility = JavaVersion.VERSION_1_8
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
         main.java.srcDirs = ['java']
         main.aidl.srcDirs = ['java']
         main.res.srcDir 'res'
         main.assets.srcDir 'assets'
         main.resources.srcDir 'java'
 
         test.setRoot('javatests');
         test.java.srcDir('javatests');
     }
 
     lintOptions {
         warningsAsErrors true
-        disable 'InvalidPackage', 'TrulyRandom', 'GradleDependency'
+        disable 'InvalidPackage', 'TrulyRandom', 'GradleDependency', 'ObsoleteLintCustomCheck'
     }
 
     packagingOptions {
         exclude 'META-INF/LICENSE.txt'
         exclude 'META-INF/NOTICE.txt'
     }
 }
 
 // produces a JAR containing sources

commit a045eec472f2b961b847246734086d68377cee20
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Fri Oct 6 12:21:04 2017 -0700

    Improved tests for QueryResponse (#124)
    
    Tests both read and write of parcels, does not rely on mock parcels

diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
index b0bac5b..766af91 100644
--- a/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
@@ -18,2 +18,3 @@ package com.google.bbq;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
@@ -28,51 +29,57 @@ import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
 
 /**
  * Battery of tests for the QueryResponse
  */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
 public class QueryResponseTest {
-    @Mock
-    private Parcel mockParcel;
 
-    private QueryResponse underTest;
-    private String mResponderPackage = "mResponderPackage";
-    private long mResponseId = 128L;
-    private byte[] mResponseMessage = new byte[64];
+    private static final String PACKAGE = "com.example.provider";
+    private static final long RESPONSE_ID = 1234L;
+    private static final byte[] RESPONSE_MESSAGE = new byte[] { 0, 1, 2, 3, 4 };
 
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        SecureRandom sr = new SecureRandom();
-        sr.nextBytes(mResponseMessage);
-
-        underTest = new QueryResponse(mResponderPackage, mResponseId, mResponseMessage);
-    }
+    private static final QueryResponse QUERY_RESPONSE =
+            new QueryResponse(PACKAGE, RESPONSE_ID, RESPONSE_MESSAGE);
 
     @Test
     public void testDescribeContents() throws Exception {
-        assertEquals(0, underTest.describeContents());
+        assertEquals(0, QUERY_RESPONSE.describeContents());
     }
 
     @Test
-    public void testWriteToParcel_WithResponseMessage() throws Exception {
-        underTest.writeToParcel(mockParcel, anyInt());
-        verify(mockParcel, times(1)).writeString(mResponderPackage);
-        verify(mockParcel, times(1)).writeLong(mResponseId);
-        verify(mockParcel, times(1)).writeInt(1);
-        verify(mockParcel, times(1)).writeInt(64);
-        verify(mockParcel, times(1)).writeByteArray(mResponseMessage);
+    public void testWriteAndReadParcel() throws Exception {
+        Parcel p = Parcel.obtain();
+        p.writeParcelable(QUERY_RESPONSE, 0);
+        p.setDataPosition(0);
+        QueryResponse read = p.readParcelable(QueryResponse.class.getClassLoader());
+
+        assertThat(read.responderPackage).isEqualTo(QUERY_RESPONSE.responderPackage);
+        assertThat(read.responseId).isEqualTo(QUERY_RESPONSE.responseId);
+        assertThat(read.responseMessage).isEqualTo(QUERY_RESPONSE.responseMessage);
     }
 
     @Test
-    public void testWriteToParcel_WithOutResponseMessage() throws Exception {
-        underTest = new QueryResponse(mResponderPackage, mResponseId, null);
-        underTest.writeToParcel(mockParcel, anyInt());
-        verify(mockParcel, times(1)).writeString(mResponderPackage);
-        verify(mockParcel, times(1)).writeLong(mResponseId);
-        verify(mockParcel, times(1)).writeInt(0);
-        verify(mockParcel, never()).writeByteArray(mResponseMessage);
+    public void testWriteAndReadParcel_noResponseMessage() {
+        QueryResponse queryResponse = new QueryResponse(PACKAGE, RESPONSE_ID, null);
+        Parcel p = Parcel.obtain();
+        p.writeParcelable(queryResponse, 0);
+        p.setDataPosition(0);
+        QueryResponse read = p.readParcelable(QueryResponse.class.getClassLoader());
+
+        assertThat(read.responderPackage).isEqualTo(QUERY_RESPONSE.responderPackage);
+        assertThat(read.responseId).isEqualTo(QUERY_RESPONSE.responseId);
+        assertThat(read.responseMessage).isNull();
     }
 
+    @Test
+    public void QueryResponseCreator_testNewArray() {
+        QueryResponse[] queryResponses = QueryResponse.CREATOR.newArray(10);
+        assertThat(queryResponses).hasSize(10);
+    }
 }
\ No newline at end of file

commit 632cde960a535851a6f40320b8551995ad713b30
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Fri Oct 6 12:20:17 2017 -0700

    Refactor additional properties utility methods (#122)
    
    The previous changes made were introducing too much duplicate code,
    increasing the likelihood of inconsistent future modifications and
    bugs. This change refactors the implementations into the utils class,
    and uses parameterized unit tests to check that all implementations
    are consistent, without affecting the convenience of the API.

diff --git a/protocol/java/org/openyolo/protocol/AdditionalPropertiesBuilder.java b/protocol/java/org/openyolo/protocol/AdditionalPropertiesBuilder.java
new file mode 100644
index 0000000..2214fc6
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/AdditionalPropertiesBuilder.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.util.Map;
+
+/**
+ * The contract that builders must adhere to if they build model types that include
+ * additional properties.
+ */
+public interface AdditionalPropertiesBuilder<
+        ModelT extends AdditionalPropertiesContainer,
+        BuilderT extends AdditionalPropertiesBuilder<ModelT, BuilderT>> {
+
+    /**
+     * Specifies any additional, non-standard properties associated with the credential.
+     */
+    @NonNull
+    BuilderT setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps);
+
+    /**
+     * Specifies an additional, non-standard property to include in the credential.
+     */
+    @NonNull
+    BuilderT setAdditionalProperty(@NonNull String key, @Nullable byte[] value);
+
+    /**
+     * Specifies an additional, non-standard property with a string value to include in the
+     * credential.
+     */
+    @NonNull
+    BuilderT setAdditionalPropertyAsString(@NonNull String key, @Nullable String value);
+
+    /**
+     * Creates an instance of the model type.
+     */
+    @NonNull
+    ModelT build();
+}
diff --git a/protocol/java/org/openyolo/protocol/AdditionalPropertiesContainer.java b/protocol/java/org/openyolo/protocol/AdditionalPropertiesContainer.java
new file mode 100644
index 0000000..54d2a63
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/AdditionalPropertiesContainer.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.util.Map;
+
+/**
+ * Implemented by all model types that can hold additional, non-standard properties.
+ */
+public interface AdditionalPropertiesContainer {
+
+    /**
+     * The set of additional, non-standard properties.
+     */
+    @NonNull
+    Map<String, byte[]> getAdditionalProperties();
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key. If this
+     * additional property does not exist, then `null` is returned.
+     */
+    @Nullable
+    byte[] getAdditionalProperty(String key);
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key, where the
+     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
+     * then `null` is returned.
+     */
+    @Nullable
+    String getAdditionalPropertyAsString(String key);
+}
diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 24bbd42..73069e1 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -38,455 +38,428 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a credential for use in sign-in. This provides a higher-level,
  * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
  * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credentials">
  *     OpenYOLO Specification: Credential</a>
  */
-public final class Credential implements Parcelable {
+public final class Credential implements Parcelable, AdditionalPropertiesContainer {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     /**
      * Creates a credential from its protocol buffer equivalent, in byte form.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static Credential fromProtoBytes(@NonNull byte[] credentialProtoBytes)
             throws MalformedDataException {
         validate(credentialProtoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static Credential fromProtobuf(Protobufs.Credential credential)
             throws MalformedDataException {
         return new Credential.Builder(credential).build();
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationDomain mAuthDomain;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPicture;
 
     @Nullable
     private final String mPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Credential(Builder builder) {
         mId = builder.mId;
         mAuthDomain = builder.mAuthDomain;
         mAuthMethod = builder.mAuthMethod;
         mDisplayName = builder.mDisplayName;
         mDisplayPicture = builder.mDisplayPicture;
         mPassword = builder.mPassword;
         mIdToken = builder.mIdToken;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
     public Protobufs.Credential toProtobuf() {
         Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .setAuthDomain(mAuthDomain.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPicture != null) {
             builder.setDisplayPictureUri(mDisplayPicture.toString());
         }
 
         if (mPassword != null) {
             builder.setPassword(mPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
     @NonNull
     public AuthenticationDomain getAuthenticationDomain() {
         return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPicture;
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
         return mPassword;
     }
 
     /**
      * An ID token which provides "proof of access" to the identifier for this credential, if
      * available.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
-    /**
-     * Additional, non-standard properties associated with the credential.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-            mAdditionalProps,
-            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key. If this
-     * additional property does not exist, then `null` is returned.
-     */
+    @Override
     @Nullable
     public byte[] getAdditionalProperty(String key) {
-        ByteString value = mAdditionalProps.get(key);
-        if (value == null) {
-            return null;
-        }
-
-        return value.toByteArray();
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key, where the
-     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
-     * then `null` is returned.
-     */
+    @Override
     @Nullable
     public String getAdditionalPropertyAsString(String key) {
-        return AdditionalPropertiesHelper.decodeStringValue(
-                getAdditionalProperty(key));
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
-    public static final class Builder {
+    public static final class Builder implements AdditionalPropertiesBuilder<Credential, Builder> {
 
         private String mId;
         private AuthenticationMethod mAuthMethod;
         private AuthenticationDomain mAuthDomain;
         private String mDisplayName;
         private Uri mDisplayPicture;
         private String mPassword;
         private String mIdToken;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          * @throws MalformedDataException if the given protocol buffer is invalid.
          */
         private Builder(@NonNull Protobufs.Credential proto) throws MalformedDataException {
             try {
                 // required properties
                 setIdentifier(proto.getId());
                 setAuthenticationMethod(AuthenticationMethod.fromProtobuf(proto.getAuthMethod()));
                 setAuthenticationDomain(AuthenticationDomain.fromProtobuf(proto.getAuthDomain()));
 
                 // optional properties
 
                 setIdToken(proto.getIdToken());
                 setDisplayName(proto.getDisplayName());
                 setDisplayPicture(proto.getDisplayPictureUri());
                 setPassword(proto.getPassword());
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 proto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
          * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
                     new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
             validate(identifier, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             validate(domain, notNullValue(), IllegalArgumentException.class);
             mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
         public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
             validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
             mPassword = nullifyEmptyString(password);
             return this;
         }
 
         /**
          * Specifies the ID token for the credential. If a null or empty value is provided, this
          * is equivalent to remove the ID token from the credential.
          */
         @NonNull
         public Builder setIdToken(String idToken) {
             this.mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             validate(displayPicture, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                 AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property to include in the credential.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
-            ByteString immutableValue;
-            if (value == null) {
-                immutableValue = null;
-            } else {
-                immutableValue = ByteString.copyFrom(value);
-            }
-
-            mAdditionalProps.put(key, immutableValue);
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property with a string value to include in the
-         * credential.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
-            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
+        @Override
         @NonNull
         public Credential build() {
             return new Credential(this);
         }
     }
 
     private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
                 return Credential.fromProtoBytes(encodedBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index 25e5ffd..ea9785e 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -29,5 +29,4 @@ import java.util.HashMap;
 import java.util.Map;
-import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
 import org.openyolo.protocol.internal.ClientVersionUtil;
-import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
@@ -35,217 +34,189 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
  *     OpenYOLO Specification: Credential Deletion</a>
  */
-public final class CredentialDeleteRequest {
+public final class CredentialDeleteRequest implements AdditionalPropertiesContainer {
 
     /**
      * Returns a deletion request for the given credential.
      */
     public static CredentialDeleteRequest fromCredential(Credential credential) {
         return new Builder(credential).build();
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent, in byte array
      * form.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static CredentialDeleteRequest fromProtobufBytes(@NonNull byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException("unable to parse credential deletion request", ex);
         }
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static CredentialDeleteRequest fromProtobuf(
             @NonNull Protobufs.CredentialDeleteRequest proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new Builder(proto).build();
     }
 
 
     /**
      * Extracts a credential deletion request from a request intent.
      * @throws MalformedDataException if the provided intent is null, is missing the byte array
      *     extra for the request, or the request contains invalid data.
      */
     public static CredentialDeleteRequest fromRequestIntent(
             @Nullable Intent requestIntent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_REQUEST,
                         Protobufs.CredentialDeleteRequest.parser(),
                         "deletion request missing or contains invalid data",
                         requestIntent));
     }
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be deleted.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
-    /**
-     * The additional, non-standard properties specified by the client as part of this
-     * deletion request.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key. If this
-     * additional property does not exist, then `null` is returned.
-     */
+    @Override
     @Nullable
     public byte[] getAdditionalProperty(String key) {
-        ByteString value = mAdditionalProps.get(key);
-        if (value == null) {
-            return null;
-        }
-
-        return value.toByteArray();
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key, where the
-     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
-     * then `null` is returned.
-     */
+    @Override
     @Nullable
     public String getAdditionalPropertyAsString(String key) {
-        return AdditionalPropertiesHelper.decodeStringValue(
-                getAdditionalProperty(key));
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     /**
      * Converts the request to its protocol buffer equivalent.
      */
     public Protobufs.CredentialDeleteRequest toProtobuf() {
         return Protobufs.CredentialDeleteRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Creates instances of {@link CredentialDeleteRequest}.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<CredentialDeleteRequest, Builder> {
 
         @NonNull
         private Credential mCredential;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion request, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(Protobufs.CredentialDeleteRequest proto) throws MalformedDataException {
             try {
                 setCredential(Credential.fromProtobuf(proto.getCredential()));
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * credential object.
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be deleted. Must not be null.
          */
         public Builder setCredential(@NonNull Credential credential) {
             validate(credential, notNullValue(), IllegalArgumentException.class);
 
             mCredential = credential;
             return this;
         }
 
-        /**
-         * Specifies the set of additional, non-standard properties to carry with the credential
-         * deletion request. A null map is treated as an empty map.
-         */
+        @Override
+        @NonNull
         public Builder setAdditionalProperties(
                 @Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = validateAdditionalProperties(additionalProperties);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property to include in the request.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
-            ByteString immutableValue;
-            if (value == null) {
-                immutableValue = null;
-            } else {
-                immutableValue = ByteString.copyFrom(value);
-            }
-
-            mAdditionalProps.put(key, immutableValue);
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property with a string value to include in the
-         * request.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
-            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion request, from the specified properties.
          */
+        @Override
+        @NonNull
         public CredentialDeleteRequest build() {
             return new CredentialDeleteRequest(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index a26d5a7..cd5732c 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -28,4 +28,2 @@ import java.util.Map;
 import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
@@ -33,331 +31,311 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
  *     OpenYOLO Specification: Credential Deletion</a>
  */
-public final class CredentialDeleteResult {
+public final class CredentialDeleteResult implements AdditionalPropertiesContainer {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE =
             Protobufs.CredentialDeleteResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult UNKNOWN =
             new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built deletion result that indicates that no provider was available and able to handle
      * the associated request.
      */
     public static final CredentialDeleteResult NO_PROVIDER_AVAILABLE =
             new CredentialDeleteResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
     private static final String UNABLE_TO_EXTRACT_RESULT =
             "Unable to extract or parse the credential deletion result";
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), IllegalArgumentException.class);
 
         return new CredentialDeleteResult.Builder(proto).build();
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
      * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
     public static CredentialDeleteResult fromResultIntentData(
             @Nullable Intent intent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_RESULT,
                         Protobufs.CredentialDeleteResult.parser(),
                         UNABLE_TO_EXTRACT_RESULT,
                         intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_DELETED == mResultCode;
     }
 
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
-    /**
-     * The additional, non-standard properties returned by the credential provider as part of the
-     * credential deletion result, if available.
-     */
+    @Override
+    @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
     }
 
     /**
      * Returns the additional, non-standard property identified by the specified key. If this
      * additional property does not exist, then `null` is returned.
      */
     @Nullable
     public byte[] getAdditionalProperty(String key) {
-        ByteString value = mAdditionalProps.get(key);
-        if (value == null) {
-            return null;
-        }
-
-        return value.toByteArray();
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
     }
 
     /**
      * Returns the additional, non-standard property identified by the specified key, where the
      * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
      * then `null` is returned.
      */
     @Nullable
     public String getAdditionalPropertyAsString(String key) {
-        return AdditionalPropertiesHelper.decodeStringValue(
-                getAdditionalProperty(key));
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
     public Intent toResultDataIntent() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<CredentialDeleteResult, Builder> {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
          * @throws MalformedDataException if the protocol buffer could not be parsed from the
          *     intent.
          */
         private Builder(Protobufs.CredentialDeleteResult proto) throws MalformedDataException {
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
-        /**
-         * Specifies the set of additional, non-standard properties to carry with the credential
-         * deletion result. A null map is treated as an empty map.
-         */
+        @Override
+        @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property to include in the result.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
-            ByteString immutableValue;
-            if (value == null) {
-                immutableValue = null;
-            } else {
-                immutableValue = ByteString.copyFrom(value);
-            }
-
-            mAdditionalProps.put(key, immutableValue);
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property with a string value to include in the
-         * result.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
-            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
+        @Override
+        @NonNull
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index ca423bb..3690d1f 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -49,403 +49,374 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
-public class CredentialRetrieveRequest implements Parcelable {
+public class CredentialRetrieveRequest implements Parcelable, AdditionalPropertiesContainer {
 
     @VisibleForTesting
     static final Boolean DEFAULT_REQUIRE_USER_MEDIATION_VALUE = false;
 
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest fromAuthMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest fromAuthMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
             @NonNull Protobufs.CredentialRetrieveRequest proto) throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
      * @throws MalformedDataException if the intent does not contain a retrieve request, or the
      *     contained request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
             throws MalformedDataException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
             throw new MalformedDataException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     @NonNull
     private final boolean mRequireUserMediation;
 
     private CredentialRetrieveRequest(Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
         mRequireUserMediation = builder.mRequireUserMediation;
     }
 
     /**
      * The set of authentication methods that the requester supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The set of token providers that the requester supports. These are used by the
      * credential provider and the OpenYOLO client library to attempt to acquire a "proof of access"
      * ID token for any returned credential.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * Specifies if the provider MUST have the user interact before a successful response is
      * returned.
      */
     @NonNull
     public boolean getRequireUserMediation() {
         return mRequireUserMediation;
     }
 
 
-    /**
-     * Retrieves the raw, byte-array value of the named additional parameter.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key. If this
-     * additional property does not exist, then `null` is returned.
-     */
+    @Override
     @Nullable
     public byte[] getAdditionalProperty(String key) {
-        ByteString value = mAdditionalProps.get(key);
-        if (value == null) {
-            return null;
-        }
-
-        return value.toByteArray();
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key, where the
-     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
-     * then `null` is returned.
-     */
+    @Override
     @Nullable
     public String getAdditionalPropertyAsString(String key) {
-        return AdditionalPropertiesHelper.decodeStringValue(
-                getAdditionalProperty(key));
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(mAdditionalProps)
                 .setRequireUserMediation(mRequireUserMediation)
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<CredentialRetrieveRequest, Builder> {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
         private boolean mRequireUserMediation = DEFAULT_REQUIRE_USER_MEDIATION_VALUE;
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided credential retrieve request.
          */
         public Builder(CredentialRetrieveRequest request) {
             mAuthMethods = request.mAuthMethods;
             mTokenProviders = request.mTokenProviders;
             mAdditionalProps = request.mAdditionalProps;
             mRequireUserMediation = request.mRequireUserMediation;
         }
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          * @throws MalformedDataException if the given protocol buffer is not valid.
          */
         private Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
 
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
 
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
 
                 setRequireUserMediation(requestProto.getRequireUserMediation());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies if the provider MUST require user interaction before returning a successful
          * response.
          */
         public Builder setRequireUserMediation(boolean value) {
             mRequireUserMediation = value;
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
 
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
-        /**
-         * Specifies additional, non-standard retrieve request parameters. The provided map must be
-         * non-null, and contain only non-null keys and values.
-         */
-        public Builder setAdditionalProperties(
-                @NonNull Map<String, byte[]> additionalProps) {
+        @Override
+        @NonNull
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property to include in the credential.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
-            ByteString immutableValue;
-            if (value == null) {
-                immutableValue = null;
-            } else {
-                immutableValue = ByteString.copyFrom(value);
-            }
-
-            mAdditionalProps.put(key, immutableValue);
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property with a string value to include in the
-         * credential.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
-            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
         }
 
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
+        @Override
         @NonNull
         public CredentialRetrieveRequest build() {
             return new CredentialRetrieveRequest(this);
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return CredentialRetrieveRequest.fromProtobufBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index d3215c1..1b4b899 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -29,342 +29,312 @@ import org.openyolo.protocol.Protobufs.CredentialRetrieveResult.ResultCode;
 import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
-public final class CredentialRetrieveResult {
+public final class CredentialRetrieveResult implements AdditionalPropertiesContainer {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE = ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that a credential was successfully chosen and has been returned as part of this
      * response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates that the provider returned a response that could not be
      * interpreted.
      */
     public static final CredentialRetrieveResult UNKNOWN =
             new CredentialRetrieveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built result that indicates that no provider was available and able to handle the
      * associated request.
      */
     public static final CredentialRetrieveResult NO_PROVIDER_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_CREDENTIAL_SELECTED == mResultCode;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
-    /**
-     * The additional, non-standard properties returned by the credential provider, if available.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key. If this
-     * additional property does not exist, then `null` is returned.
-     */
+    @Override
     @Nullable
     public byte[] getAdditionalProperty(String key) {
-        ByteString value = mAdditionalProps.get(key);
-        if (value == null) {
-            return null;
-        }
-
-        return value.toByteArray();
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
     }
 
-    /**
-     * Returns the additional, non-standard property identified by the specified key, where the
-     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
-     * then `null` is returned.
-     */
+    @Override
     @Nullable
     public String getAdditionalPropertyAsString(String key) {
-        return AdditionalPropertiesHelper.decodeStringValue(
-                getAdditionalProperty(key));
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<CredentialRetrieveResult, Builder> {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          * @throws MalformedDataException if the given protocol buffer was invalid.
          */
         private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setCredentialFromProto(proto.getCredential());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
                 throws MalformedDataException {
             if (null == credential
                     || Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = null;
             } else {
                 mCredential = Credential.fromProtobuf(credential);
             }
             return this;
         }
 
-        /**
-         * Specifies the set of additional, non-standard properties to return as part of this
-         * result. The keys and values of the provided map must not be null. The keys must not
-         * be empty.
-         */
+        @Override
+        @NonNull
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property to include in the result.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
-            ByteString immutableValue;
-            if (value == null) {
-                immutableValue = null;
-            } else {
-                immutableValue = ByteString.copyFrom(value);
-            }
-
-            mAdditionalProps.put(key, immutableValue);
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
             return this;
         }
 
-        /**
-         * Specifies an additional, non-standard property with a string value to include in the
-         * result.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
-            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
+        @Override
+        @NonNull
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
index 3fe7e1b..6da9b01 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
@@ -34,196 +34,217 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A request to save a given {@link Credential credential}. To make the request the client
  * encodes it in its associated protocol buffer byte array form in an activity intent
  * via the {@link ProtocolConstants#EXTRA_SAVE_REQUEST} extra.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credentials</a>
  */
-public final class CredentialSaveRequest implements Parcelable {
+public final class CredentialSaveRequest implements Parcelable, AdditionalPropertiesContainer {
 
     /**
      * Parcelable reader for {@link CredentialSaveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialSaveRequest> CREATOR = new CredentialSaveRequestCreator();
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save request from its protocol buffer byte array form.
      * @throws MalformedDataException if the given protocol buffer was invalid.
      *
      * @see #toProtocolBuffer()
      */
     public static CredentialSaveRequest fromProtoBytes(byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             Protobufs.CredentialSaveRequest request =
                     Protobufs.CredentialSaveRequest.parseFrom(protoBytes);
             return new CredentialSaveRequest.Builder(request).build();
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential save request from its protocol buffer form.
      * @throws MalformedDataException if the given protocol buffer was invalid.
      *
      * @see #toProtocolBuffer()
      */
     public static CredentialSaveRequest fromProtobuf(Protobufs.CredentialSaveRequest request)
             throws MalformedDataException {
         validate(request, notNullValue(), MalformedDataException.class);
 
         return new CredentialSaveRequest.Builder(request).build();
     }
 
     /**
      * Creates a {@link CredentialSaveRequest} from the given {@link Credential}.
      */
     public static CredentialSaveRequest fromCredential(Credential credential) {
         return new Builder(credential).build();
     }
 
     private CredentialSaveRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be saved.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
-    /**
-     * The map of additional, non-standard properties included with this request.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-            mAdditionalProperties,
-            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProperties);
+    }
+
+    @Nullable
+    @Override
+    public byte[] getAdditionalProperty(String key) {
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProperties, key);
+    }
+
+    @Nullable
+    @Override
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProperties, key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialSaveRequest toProtocolBuffer() {
         return Protobufs.CredentialSaveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProperties)
                 .build();
     }
 
     /**
      * Creates {@link CredentialSaveRequest} instances.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<CredentialSaveRequest, Builder> {
 
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Recreates a save request from its protocol buffer form.
          *
          * @see CredentialSaveRequest#toProtocolBuffer()
          */
         private Builder(@NonNull Protobufs.CredentialSaveRequest request)
                 throws MalformedDataException {
             validate(request, notNullValue(), MalformedDataException.class);
 
             try {
                 setCredential(Credential.fromProtobuf(request.getCredential()));
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 request.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of defining a save request, specifying the credential to be saved.
          *
          * @see Credential
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be saved. The provided credential must be non-null.
          *
          * @see Credential
          */
         public Builder setCredential(@NonNull Credential credential) {
             validate(credential, notNullValue(), IllegalArgumentException.class);
 
             mCredential = credential;
             return this;
         }
 
-        /**
-         * Specifies the set of additional, non-standard properties to carry with the credential
-         * save request. A null map is treated as an empty map.
-         */
+        @Override
         @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
             return this;
         }
 
+        @NonNull
+        @Override
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
+            return this;
+        }
+
+        @NonNull
+        @Override
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
+        }
+
         /**
          * Finalizes the creation of the credential save request.
          */
+        @Override
         public CredentialSaveRequest build() {
             return new CredentialSaveRequest(this);
         }
     }
 
     private static final class CredentialSaveRequestCreator
             implements Creator<CredentialSaveRequest> {
         @Override
         public CredentialSaveRequest createFromParcel(Parcel source) {
             int length = source.readInt();
             byte[] encodedRequest = new byte[length];
             source.readByteArray(encodedRequest);
 
             try {
                 return CredentialSaveRequest.fromProtoBytes(encodedRequest);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialSaveRequest[] newArray(int size) {
             return new CredentialSaveRequest[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index e1ce167..2a50e78 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -31,256 +31,278 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential save request. Contains a result code,
  * indicating whether the request was successful or not, and an optional set of additional,
  * non-standard result properties.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credential</a>
  */
-public final class CredentialSaveResult {
+public final class CredentialSaveResult implements AdditionalPropertiesContainer {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE =
             Protobufs.CredentialSaveResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential sent to the provider was saved.
      */
     public static final int CODE_SAVED =
             Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
 
     /**
      * Indicates the provider refused to save the credential, due to some policy restriction. For
      * example, a provider may refuse to update an existing credential if it is stored in a shared
      * keychain. The client SHOULD NOT request to save this credential again.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to delete the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates the user refused the request to save this credential. The client SHOULD NOT request
      * to save this credential again.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built save result for an unspecified outcome. Carries no additional properties.
      */
     public static final CredentialSaveResult UNKNOWN =
             new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built save result that indicates that no provider was available and able to handle the
      * associated request.
      */
     public static final CredentialSaveResult NO_PROVIDER_AVAILABLE =
             new CredentialSaveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built save result that indicates the credential was saved. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult SAVED =
             new CredentialSaveResult.Builder(CODE_SAVED).build();
 
     /**
      * Pre-built save result that indicates the request was malformed. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult BAD_REQUEST =
             new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to save the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final CredentialSaveResult USER_CANCELED =
             new CredentialSaveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the user. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult USER_REFUSED =
             new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the provider. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult PROVIDER_REFUSED =
             new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     private final int mResultCode;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential save result from its protocol buffer equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialSaveResult.Builder(proto).build();
     }
 
     /**
      * Creates a protocol buffer representation of the credential save result, for transmission
      * or storage.
      */
     public Protobufs.CredentialSaveResult toProtobuf() {
         Protobufs.CredentialSaveResult.Builder builder =
                 Protobufs.CredentialSaveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProperties);
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential save result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_SAVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     private CredentialSaveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProperties = builder.mAdditionalProps;
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_SAVED == mResultCode;
     }
 
 
     /**
      * The result code for the credential save operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
-    /**
-     * The additional, non-standard properties returned by the credential provider, if available.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProperties,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProperties);
+    }
+
+    @Nullable
+    @Override
+    public byte[] getAdditionalProperty(String key) {
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProperties, key);
+    }
+
+    @Nullable
+    @Override
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProperties, key);
     }
 
     /**
      * Creates {@link CredentialSaveResult} instances.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<CredentialSaveResult, Builder> {
         private int mResultCode = CODE_UNKNOWN;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result given the mandatory status
          * code.
          * @throws MalformedDataException if the given protocol buffer was not valid.
          */
         private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 proto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Seeds a credential save result from its protocol buffer equivalent.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
 
             return this;
         }
 
-        /**
-         * Specifies the set of additional, non-standard properties to carry with the credential
-         * deletion request. A null map is treated as an empty map.
-         */
+        @Override
+        @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+            return this;
+        }
+
+        @Override
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
+            return this;
+        }
 
+        @Override
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential save result.
          */
+        @Override
+        @NonNull
         public CredentialSaveResult build() {
             return new CredentialSaveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Hint.java b/protocol/java/org/openyolo/protocol/Hint.java
index 0195430..ab2997a 100644
--- a/protocol/java/org/openyolo/protocol/Hint.java
+++ b/protocol/java/org/openyolo/protocol/Hint.java
@@ -36,390 +36,411 @@ import java.util.Map;
 import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * A representation of a hint for use in account discovery or account creation. This provides a
  * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential protocol
  * buffer} that is returned by the provider.
  *
  * <p>Hints must have an {@link #getIdentifier() identifier} and an
  * an {@link #getAuthenticationMethod() authentication method}, but all other properties are
  * optional.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
-public final class Hint implements Parcelable {
+public final class Hint implements Parcelable, AdditionalPropertiesContainer {
 
     /**
      * Parcelable reader for {@link Hint} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Hint> CREATOR = new HintCreator();
 
     /**
      * Creates a hint from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static Hint fromProtobuf(Protobufs.Hint proto) throws MalformedDataException {
         return new Hint.Builder(proto).build();
     }
 
     /**
      * Creates a hint from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the protocol buffer cannot be parsed from the byte array.
      */
     public static Hint fromProtobufBytes(byte[] protoBytes) throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
         try {
             return fromProtobuf(Protobufs.Hint.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPictureUri;
 
     @Nullable
     private final String mGeneratedPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Hint(Hint.Builder builder) {
         mId = builder.mId;
         mAuthMethod = builder.mAuthMethod;
         mDisplayName = builder.mDisplayName;
         mDisplayPictureUri = builder.mDisplayPictureUri;
         mGeneratedPassword = builder.mGeneratedPassword;
         mIdToken = builder.mIdToken;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint, for transmission or storage.
      */
     public Protobufs.Hint toProtobuf() {
         Protobufs.Hint.Builder builder = Protobufs.Hint.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPictureUri != null) {
             builder.setDisplayPictureUri(mDisplayPictureUri.toString());
         }
 
         if (mGeneratedPassword != null) {
             builder.setGeneratedPassword(mGeneratedPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * Returns a {@link Credential.Builder} representation of the hint.
      */
     public Credential.Builder toCredentialBuilder(Context context) {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(context);
         return new Credential.Builder(mId, mAuthMethod, authDomain)
                 .setDisplayName(mDisplayName)
                 .setDisplayPicture(mDisplayPictureUri)
                 .setPassword(mGeneratedPassword)
                 .setIdToken(mIdToken)
                 .setAdditionalProperties(getAdditionalProperties());
     }
 
     /**
      * The hint identifier, for use in discovering an existing account within the context of the
      * authentication method and authentication domain (which is implicitly that of the requester),
      * or creating a new account.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication domain associated with the hint.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * A suggested display name for accounts created using this hint, if available.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * A suggested profile picture for accounts created using this hint. if available.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPictureUri;
     }
 
     /**
      * A suggested password for use with accounts created using this hint, if available.
      */
     @Nullable
     public String getGeneratedPassword() {
         return mGeneratedPassword;
     }
 
     /**
      * An ID token that provides "proof of access" to the hint identifier, if available.
      * When provided this can be used either as a means of authentication in its
      * own right, or as a means to bypass manual proof of access verification, such as by sending
      * an email with a verification link or an SMS with a code.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
-    /**
-     * Additional, non-standard properties associated with the hint.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
+    }
+
+    @Nullable
+    @Override
+    public byte[] getAdditionalProperty(String key) {
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
+    }
+
+    @Nullable
+    @Override
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] hintBytes = toProtobuf().toByteArray();
         dest.writeInt(hintBytes.length);
         dest.writeByteArray(hintBytes);
     }
 
     /**
      * Creates instances of {@link Hint}.
      */
-    public static final class Builder {
+    public static final class Builder implements AdditionalPropertiesBuilder<Hint, Builder> {
 
         @NonNull
         private String mId;
 
         @NonNull
         private AuthenticationMethod mAuthMethod;
 
         @Nullable
         private String mDisplayName;
 
         @Nullable
         private Uri mDisplayPictureUri;
 
         @Nullable
         private String mGeneratedPassword;
 
         @Nullable
         private String mIdToken;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull AuthenticationMethod authMethod) {
             setIdentifier(id);
             setAuthMethod(authMethod);
         }
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull String authMethod) {
             this(id, new AuthenticationMethod(authMethod));
         }
 
         /**
          * Starts the process of creating a hint using an already built hint.
          */
         public Builder(Hint hint) {
             setIdentifier(hint.mId);
             setAuthMethod(hint.mAuthMethod);
             setDisplayName(hint.mDisplayName);
             setDisplayPictureUri(hint.mDisplayPictureUri);
             setGeneratedPassword(hint.mGeneratedPassword);
             setIdToken(hint.mIdToken);
             setAdditionalPropertiesFromProto(hint.mAdditionalProps);
         }
 
         /**
          * Starts the process of creating a hint, based on the properties of the provided
          * protocol buffer representation of the credential. The protocol buffer must contain
          * valid data for a hint.
          */
         private Builder(@NonNull Protobufs.Hint proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setIdentifier(proto.getId());
                 setAuthMethod(proto.getAuthMethod().getUri());
                 setDisplayName(proto.getDisplayName());
                 setDisplayPictureUri(proto.getDisplayPictureUri());
                 setGeneratedPassword(proto.getGeneratedPassword());
                 setIdToken(proto.getIdToken());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the identifier for the hint. Must not be null or empty.
          */
         public Builder setIdentifier(@NonNull String id) {
             validate(id, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = id;
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint, in string form. Must be a valid
          * authentication method URI.
          *
          * @see AuthenticationMethod
          */
         public Builder setAuthMethod(@NonNull String authMethod) {
             validate(authMethod, isValidAuthenticationMethod(), IllegalArgumentException.class);
             mAuthMethod = new AuthenticationMethod(authMethod);
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint. Must not be null.
          */
         public Builder setAuthMethod(@NonNull AuthenticationMethod authMethod) {
             validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the display name for the hint. Empty values are treated as null.
          */
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Empty values are
          * treated as null. Non-empty values must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable String displayPictureUri) {
             setDisplayPictureUri(nullifyEmptyString(displayPictureUri) != null
                             ? Uri.parse(displayPictureUri)
                             : null);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Non-null values
          * must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable Uri displayPictureUri) {
             validate(displayPictureUri, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPictureUri = displayPictureUri;
             return this;
         }
 
         /**
          * Specifies the generated password for the hint. Empty values are treated as null.
          */
         public Builder setGeneratedPassword(@Nullable String generatedPassword) {
             mGeneratedPassword = nullifyEmptyString(generatedPassword);
             return this;
         }
 
         /**
          * Specifies the "proof of access" ID token for the hint. Empty values are treated as null.
          */
         public Builder setIdToken(@Nullable String idToken) {
             mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
-        /**
-         * Specifies any additional, non-standard properties associated with the hint.
-         */
+        @Override
+        @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
+        @Override
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
+            return this;
+        }
+
+        @Override
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
+        }
+
         private Builder setAdditionalPropertiesFromProto(
                 @Nullable Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the {@link Hint hint} instance with the specified properties.
          */
+        @Override
+        @NonNull
         public Hint build() {
             return new Hint(this);
         }
     }
 
     private static final class HintCreator implements Creator<Hint> {
 
         @Override
         public Hint createFromParcel(Parcel source) {
             int length = source.readInt();
             byte[] hintBytes = new byte[length];
             source.readByteArray(hintBytes);
             try {
                 return Hint.fromProtobufBytes(hintBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalArgumentException("Unable to parse hint from parcel", ex);
             }
         }
 
         @Override
         public Hint[] newArray(int size) {
             return new Hint[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
index 3fe4e16..efad2da 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
@@ -45,351 +45,372 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
-public class HintRetrieveRequest implements Parcelable {
+public class HintRetrieveRequest implements Parcelable, AdditionalPropertiesContainer {
 
     /**
      * Parcelable reader for {@link HintRetrieveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRetrieveRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a hint request from the given set of authentication methods.
      */
     public static HintRetrieveRequest fromAuthMethods(
             AuthenticationMethod... authenticationMethods) {
         return new HintRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a hint request from the given set of authentication methods.
      */
     public static HintRetrieveRequest fromAuthMethods(
             Set<AuthenticationMethod> authenticationMethods) {
         return new HintRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws MalformedDataException {
         validate(hintRequestProtoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Reads a hint request from its protocol buffer form.
      * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtobuf(Protobufs.HintRetrieveRequest protobuf)
             throws MalformedDataException {
         validate(protobuf, notNullValue(), MalformedDataException.class);
 
         return new HintRetrieveRequest.Builder(protobuf).build();
     }
 
     private HintRetrieveRequest(@NonNull Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mPasswordSpec = builder.mPasswordSpec;
         mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The token providers supported by the requester, with the per-provider request info
      * message.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
-    /**
-     * The map of additional, non-standard properties included with this request.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProperties,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProperties);
+    }
+
+    @Nullable
+    @Override
+    public byte[] getAdditionalProperty(String key) {
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProperties, key);
+    }
+
+    @Nullable
+    @Override
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProperties, key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(mAdditionalProperties)
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRetrieveRequest} instances.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<HintRetrieveRequest, Builder> {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          * @throws MalformedDataException if the given hint protocol buffer was not valid.
          *
          * @see HintRetrieveRequest#toProtocolBuffer()
          */
         private Builder(@NonNull Protobufs.HintRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
                 setPasswordSpecification(
                         PasswordSpecification.fromProtobuf(requestProto.getPasswordSpec()));
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(AuthenticationMethod... authenticationMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authenticationMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
             validate(authenticationMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
-        /**
-         * Specifies additional, non-standard hint request parameters. The provided map
-         * must be non-null, and contain only non-empty keys and non-null values.
-         */
+        @Override
         @NonNull
-        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
-                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+            return this;
+        }
+
+        @Override
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
+            return this;
+        }
+
+        @Override
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             validate(passwordSpec, notNullValue(), IllegalArgumentException.class);
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRetrieveRequest} with the properties specified on the builder.
          */
+        @Override
         @NonNull
         public HintRetrieveRequest build() {
             return new HintRetrieveRequest(this);
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRetrieveRequest> {
         @Override
         public HintRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return HintRetrieveRequest.fromProtoBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRetrieveRequest[] newArray(int size) {
             return new HintRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
index 9fcf225..3f9988b 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -29,283 +29,302 @@ import org.openyolo.protocol.Protobufs.HintRetrieveResult.ResultCode;
 import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
  * of the request, and the response may contain a hint.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
-public final class HintRetrieveResult {
+public final class HintRetrieveResult implements AdditionalPropertiesContainer {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN = ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE = ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the hint request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST = ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that a hint was successfully chosen and has been returned as part of this response.
      */
     public static final int CODE_HINT_SELECTED = ResultCode.HINT_SELECTED_VALUE;
 
     /**
      * Indicates that no hints are available that meet the requirements of the hint request.
      */
     public static final int CODE_NO_HINTS_AVAILABLE = ResultCode.NO_HINTS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user  canceled the selection of a hint in a manner that indicates they
      * wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that The user canceled the selection of a hint in a manner that indicates they do
      * not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED = ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built hint result for an unspecified outcome. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult UNKNOWN =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_UNKNOWN).build();
 
     /**
      * Pre-build hint result that indicates that no provider was available and able to handle the
      * associated request.
      */
     public static final HintRetrieveResult NO_PROVIDER_AVAILABLE =
             new HintRetrieveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built hint result for a bad request. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult BAD_REQUEST =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built hint result for when no hints are available. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult NO_HINTS_AVAILABLE =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_NO_HINTS_AVAILABLE).build();
 
     /**
      * Pre-built hint result for when the user requests manual authentication. Carries no hint
      * or additional properties.
      */
     public static final HintRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH)
                     .build();
 
     /**
      * Pre-built hint result for when the user canceled the selection of a hint in a manner that
      * indicates they do not wish to authenticate at this time. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult USER_CANCELED =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_USER_CANCELED).build();
 
     /**
      * Creates a hint result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto)
             throws MalformedDataException {
         return new HintRetrieveResult.Builder(proto).build();
     }
 
     /**
      * Creates a hint result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobufBytes(byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Hint mHint;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private HintRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mHint = builder.mHint;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint retrieve result, for transmission or
      * storage.
      */
     public Protobufs.HintRetrieveResult toProtobuf() {
         Protobufs.HintRetrieveResult.Builder builder =
                 Protobufs.HintRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mHint != null) {
             builder.setHint(mHint.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this hint retrieve result, that a provider should
      * return as its hint activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_HINT_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_HINT_SELECTED == mResultCode;
     }
 
     /**
      * The hint retrieve result code.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The hint returned as part of the hint result, if available.
      */
     @Nullable
     public Hint getHint() {
         return mHint;
     }
 
-    /**
-     * The additional, non-standard properties returned by the credential provider as part of the
-     * hint result, if available.
-     */
+    @Override
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+        return AdditionalPropertiesUtil.convertValuesToByteArrays(mAdditionalProps);
+    }
+
+    @Nullable
+    @Override
+    public byte[] getAdditionalProperty(String key) {
+        return AdditionalPropertiesUtil.getPropertyValue(mAdditionalProps, key);
+    }
+
+    @Nullable
+    @Override
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesUtil.getPropertyValueAsString(mAdditionalProps, key);
     }
 
     /**
      * Creates {@link HintRetrieveResult} instances.
      */
-    public static final class Builder {
+    public static final class Builder
+            implements AdditionalPropertiesBuilder<HintRetrieveResult, Builder> {
 
         private int mResultCode;
 
         @Nullable
         private Hint mHint;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a hint retrieve result, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(@NonNull Protobufs.HintRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
                 setHintFromProto(proto.getHint());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a hint retrieve result, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the returned hint, if available.
          */
         public Builder setHint(@Nullable Hint hint) {
             mHint = hint;
             return this;
         }
 
         private Builder setHintFromProto(@Nullable Protobufs.Hint hint)
                 throws MalformedDataException {
             if (null == hint || Protobufs.Hint.getDefaultInstance().equals(hint)) {
                 mHint = null;
             } else {
                 mHint = Hint.fromProtobuf(hint);
             }
 
             return this;
         }
 
-        /**
-         * Specifies the set of additional, non-standard properties to return as part of this
-         * result. A null map is treated as an empty map. For a non-null map, all keys and values
-         * must not be null, and the keys must not be empty.
-         */
-        public Builder setAdditionalProperties(Map<String, byte[]> additionalProps) {
+        @Override
+        @NonNull
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
+        @Override
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            AdditionalPropertiesUtil.setPropertyValue(mAdditionalProps, key, value);
+            return this;
+        }
+
+        @Override
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            AdditionalPropertiesUtil.setPropertyValueAsString(mAdditionalProps, key, value);
+            return this;
+        }
+
         private Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the hint retrieve result, from the specified properties.
          */
+        @Override
+        @NonNull
         public HintRetrieveResult build() {
             return new HintRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java b/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
index 8353fd1..f02e0d2 100644
--- a/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
+++ b/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
@@ -21,2 +21,3 @@ import static org.valid4j.Validation.validate;
 
+import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
@@ -25,57 +26,125 @@ import java.util.HashMap;
 import java.util.Map;
+import org.openyolo.protocol.AdditionalPropertiesHelper;
 
 /**
  * Utility methods for the conversion and manipulation of additional property maps.
  */
 public final class AdditionalPropertiesUtil {
 
     /**
      * Ensures that the provided map contains no null or empty keys, and no null values.
      * Treats a null map as an empty map.
      */
     public static Map<String, ByteString> validateAdditionalProperties(
             @Nullable Map<String, byte[]> additionalProps) {
         if (additionalProps == null) {
             return new HashMap<>();
         }
 
         validate(
                 additionalProps.keySet(),
                 everyItem(notNullOrEmptyString()),
                 IllegalArgumentException.class);
         validate(
                 additionalProps.values(),
                 everyItem(notNullValue()),
                 IllegalArgumentException.class);
 
         return CollectionConverter.convertMapValues(
                 additionalProps,
                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
     }
 
     /**
      * Ensures that the provided protocol buffer sourced map contains no null or empty keys, and
      * no null values. Treats a null map as an empty map.
      */
     public static Map<String, ByteString> validateAdditionalPropertiesFromProto(
             @Nullable Map<String, ByteString> additionalProps) {
         if (additionalProps == null) {
             return new HashMap<>();
         }
 
         validate(
                 additionalProps.keySet(),
                 everyItem(notNullOrEmptyString()),
                 IllegalArgumentException.class);
         validate(
                 additionalProps.values(),
                 everyItem(notNullValue()),
                 IllegalArgumentException.class);
 
         return additionalProps;
     }
 
+    /**
+     * Extracts an additional property byte value from a map with immutable ByteString values.
+     */
+    @Nullable
+    public static byte[] getPropertyValue(
+            Map<String, ByteString> additionalProperties,
+            String key) {
+        ByteString value = additionalProperties.get(key);
+        if (value == null) {
+            return null;
+        }
+
+        return value.toByteArray();
+    }
+
+    /**
+     * Extracts an additional property string value from a map with immutable ByteString values.
+     */
+    @Nullable
+    public static String getPropertyValueAsString(
+            Map<String, ByteString> additionalProperties,
+            String key) {
+        return AdditionalPropertiesHelper.decodeStringValue(
+                getPropertyValue(additionalProperties, key));
+    }
+
+    /**
+     * Adds or replaces a property in the specified additional properties map that uses
+     * immutable ByteString values.
+     */
+    public static void setPropertyValue(
+            @NonNull Map<String, ByteString> additionalProperties,
+            @NonNull String key,
+            @Nullable byte[] value) {
+        ByteString immutableValue;
+        if (value == null) {
+            immutableValue = null;
+        } else {
+            immutableValue = ByteString.copyFrom(value);
+        }
+
+        additionalProperties.put(key, immutableValue);
+    }
+
+    /**
+     * Adds or replaces a property in the specified additional properties map that uses
+     * immutable ByteString values.
+     */
+    public static void setPropertyValueAsString(
+            @NonNull Map<String, ByteString> additionalProperties,
+            @NonNull String key,
+            @Nullable String value) {
+        setPropertyValue(additionalProperties, key,
+                AdditionalPropertiesHelper.encodeStringValue(value));
+    }
+
+    /**
+     * Copies and converts a map of additional properties that uses immutable ByteString values
+     * to one which provides raw byte[] values.
+     */
+    public static Map<String, byte[]> convertValuesToByteArrays(
+            Map<String, ByteString> additionalProperties) {
+        return CollectionConverter.convertMapValues(
+                additionalProperties,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
     private AdditionalPropertiesUtil() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java b/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java
new file mode 100644
index 0000000..571909d
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesTest.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.assertj.core.util.Maps;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
+import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
+import org.robolectric.ParameterizedRobolectricTestRunner;
+import org.robolectric.ParameterizedRobolectricTestRunner.Parameters;
+import org.robolectric.annotation.Config;
+
+/**
+ * Tests additional property storage and retrieval, for all types that implement the
+ * {@link AdditionalPropertiesContainer} interface.
+ */
+@RunWith(ParameterizedRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class AdditionalPropertiesTest {
+
+    private final String mContainerClassName;
+
+    /**
+     * Classloader shenanigans within Robolectric mean that we can't just directly instantiate
+     * and provide the instances of AdditionalPropertiesBuilder via the @Parameters annotated
+     * method. We must ensure that the instances are only created once the test methods are
+     * actually executing, as it is only at this point that the robolectric shadows have been
+     * loaded. So, as an awkward workaround, this map holds lambdas to create the builders
+     * on-demand, and the tests are parameterized by the keys of the map.
+     */
+    private static final Map<String, Callable<AdditionalPropertiesBuilder>> buildersByContainerType =
+            ImmutableMap.<String, Callable<AdditionalPropertiesBuilder>>builder()
+                    .put("Credential",
+                            () -> new Credential.Builder(
+                                    ValidFacebookCredential.ID,
+                                    ValidFacebookCredential.AUTHENTICATION_METHOD,
+                                    ValidFacebookCredential.AUTHENTICATION_DOMAIN))
+                    .put("CredentialDeleteRequest",
+                            () -> new CredentialDeleteRequest.Builder(
+                                    ValidFacebookCredential.make()))
+                    .put("CredentialDeleteResult",
+                            () -> new CredentialDeleteResult.Builder(
+                                    CredentialDeleteResult.CODE_DELETED))
+                    .put("CredentialRetrieveRequest",
+                            () -> new CredentialRetrieveRequest.Builder(
+                                    AuthenticationMethods.EMAIL))
+                    .put("CredentialRetrieveResult",
+                            () -> new CredentialRetrieveResult.Builder(
+                                    CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE))
+                    .put("CredentialSaveRequest",
+                            () -> new CredentialSaveRequest.Builder(
+                                    ValidFacebookCredential.make()))
+                    .put("CredentialSaveResult",
+                            () -> new CredentialSaveResult.Builder(
+                                    CredentialSaveResult.CODE_SAVED))
+                    .put("Hint",
+                            () -> new Hint.Builder(
+                                    ValidFacebookCredential.ID,
+                                    ValidFacebookCredential.AUTHENTICATION_METHOD))
+                    .put("HintRetrieveRequest",
+                            () -> new HintRetrieveRequest.Builder(
+                                    AuthenticationMethods.EMAIL))
+                    .put("HintRetrieveResult",
+                            () -> new HintRetrieveResult.Builder(
+                                    HintRetrieveResult.CODE_NO_HINTS_AVAILABLE))
+            .build();
+
+    @Parameters(name = "AdditionalPropertiesTest for {0}")
+    public static Collection params() {
+        ArrayList<Object[]> params = new ArrayList<>();
+
+        for (String containerTypeName : buildersByContainerType.keySet()) {
+            params.add(new Object[] { containerTypeName });
+        }
+
+        return params;
+    }
+
+    private AdditionalPropertiesBuilder<?, ?> mBuilder;
+
+    public AdditionalPropertiesTest(String containerClassName) {
+        mContainerClassName = containerClassName;
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        mBuilder = buildersByContainerType.get(mContainerClassName).call();
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperties() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalProperties(ValidAdditionalProperties.make())
+                .build();
+        ValidAdditionalProperties.assertEquals(container.getAdditionalProperties());
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperties_withNull() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalProperties(ValidAdditionalProperties.make())
+                .setAdditionalProperties(null)
+                .build();
+
+        assertThat(container.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperties_nullKey() {
+        final Map<String, byte[]> mapWithNullKey = Maps.newHashMap(null, new byte[0]);
+        assertThatThrownBy(() -> mBuilder.setAdditionalProperties(mapWithNullKey))
+                .isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    public void testBuild_setAdditionalProperty_nullValue() {
+        final Map<String, byte[]> mapWithNullValue = Maps.newHashMap("a", null);
+        assertThatThrownBy(() -> mBuilder.setAdditionalProperties(mapWithNullValue))
+                .isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperty() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = container.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(2);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = container.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalPropertyAsString() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalPropertyAsString(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_STRING_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = container.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
+                        ADDITIONAL_PROP_STRING_VALUE));
+    }
+
+    @Test
+    public void testGetAdditionalProperty() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE))
+                .build();
+
+        assertThat(container.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testGetAdditionalProperty_withMissingKey() {
+        AdditionalPropertiesContainer container = mBuilder.build();
+        assertThat(container.getAdditionalProperty("missingKey")).isNull();
+    }
+
+    @Test
+    public void testGetAdditionalPropertyAsString() {
+        AdditionalPropertiesContainer container = mBuilder
+                .setAdditionalPropertyAsString(
+                        ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_STRING_VALUE)
+                .build();
+
+        assertThat(container.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
index 85583b3..8531db5 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
@@ -16,9 +16,2 @@ package org.openyolo.protocol;
 
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
@@ -26,5 +19,3 @@ import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 import android.content.Intent;
-import com.google.common.collect.ImmutableMap;
 import com.google.protobuf.ByteString;
-import java.util.Map;
 import org.junit.Test;
@@ -37,209 +28,125 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteRequestTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteRequest INVALID_PROTO =
             Protobufs.CredentialDeleteRequest.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
     private static final class ValidDeleteRequest {
         public static final CredentialDeleteRequest make() {
             return new CredentialDeleteRequest.Builder(ValidFacebookCredential.make())
                             .setAdditionalProperties(ValidAdditionalProperties.make())
                             .build();
         }
 
         public static void assertEquals(CredentialDeleteRequest request) {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
         }
     }
 
     @Test
     public void build() {
         CredentialDeleteRequest request = ValidDeleteRequest.make();
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullCredential_throwsIllegalArgumentException() {
         new CredentialDeleteRequest.Builder(null).build();
     }
 
-    @Test
-    public void testBuilder_setAdditionalProperty() {
-        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
-                ValidFacebookCredential.make())
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(2);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
-        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
-                ValidFacebookCredential.make())
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalPropertyAsString() {
-        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
-                ValidFacebookCredential.make())
-                .setAdditionalPropertyAsString(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_STRING_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
-                        ADDITIONAL_PROP_STRING_VALUE));
-    }
-
-    @Test
-    public void testGetAdditionalProperty() {
-        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
-                ValidFacebookCredential.make())
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
-                .build();
-
-        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testGetAdditionalProperty_withMissingKey() {
-        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
-                ValidFacebookCredential.make())
-                .build();
-        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
-    }
-
-    @Test
-    public void testGetAdditionalPropertyAsString() {
-        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
-                ValidFacebookCredential.make())
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
-                .build();
-
-        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
-    }
-
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.CredentialDeleteRequest proto = ValidDeleteRequest.make().toProtobuf();
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromProtobuf(proto);
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_nullProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
         Protobufs.CredentialDeleteRequest proto = ValidDeleteRequest.make().toProtobuf();
         CredentialDeleteRequest request =
                 CredentialDeleteRequest.fromProtobufBytes(proto.toByteArray());
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 
     @Test
     public void fromRequestIntent() throws Exception {
         byte[] protoBytes = ValidDeleteRequest.make().toProtobuf().toByteArray();
         Intent requestIntent = new Intent();
         requestIntent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, protoBytes);
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromRequestIntent(requestIntent);
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_nullIntent_throwsException() throws Exception {
         CredentialDeleteRequest.fromRequestIntent(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_missingExtra_throwsException() throws Exception {
         Intent intent = new Intent();
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, "notAByteArray");
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO_BYTES);
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO.toByteArray());
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
index d72617b..519d394 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
@@ -17,7 +17,2 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
@@ -25,8 +20,5 @@ import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 import android.content.Intent;
-import com.google.common.collect.ImmutableMap;
 import com.google.protobuf.ByteString;
-import java.util.Map;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
 import org.robolectric.RobolectricTestRunner;
@@ -35,195 +27,111 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteResult}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteResultTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteResult INVALID_PROTO =
             Protobufs.CredentialDeleteResult.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
     private static final class ValidDeleteResult {
         public static CredentialDeleteResult make() {
             return new CredentialDeleteResult.Builder(
                     CredentialDeleteResult.CODE_DELETED)
                     .setAdditionalProperties(TestConstants.ValidAdditionalProperties.make())
                     .build();
         }
 
         public static void assertEquals(CredentialDeleteResult result) {
             assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
             TestConstants.ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
         }
     }
 
-    @Test
-    public void testBuilder_setAdditionalProperty() {
-        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(2);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
-        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalPropertyAsString() {
-        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalPropertyAsString(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_STRING_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
-                        ADDITIONAL_PROP_STRING_VALUE));
-    }
-
-    @Test
-    public void testGetAdditionalProperty() {
-        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
-                .build();
-
-        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testGetAdditionalProperty_withMissingKey() {
-        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .build();
-        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
-    }
-
-    @Test
-    public void testGetAdditionalPropertyAsString() {
-        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
-                .build();
-
-        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
-    }
-
     @Test
     public void build() {
         CredentialDeleteResult result = ValidDeleteResult.make();
 
         ValidDeleteResult.assertEquals(result);
     }
 
     @Test
     public void toProtobuf_fromProtobuf_isEquivalent() throws Exception {
         Protobufs.CredentialDeleteResult protobuf = ValidDeleteResult.make().toProtobuf();
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(protobuf);
 
         ValidDeleteResult.assertEquals(result);
     }
 
     @Test
     public void toResultIntentData_fromResultIntentData_isEquivalent() throws Exception {
         Intent resultData = ValidDeleteResult.make().toResultDataIntent();
         CredentialDeleteResult result = CredentialDeleteResult.fromResultIntentData(resultData);
 
         ValidDeleteResult.assertEquals(result);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_nullIntent_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(null);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_missingExtra_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(new Intent());
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, "notAByteArray");
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO_BYTES);
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO.toByteArray());
 
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromProtobuf_invalidProtoData_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
         byte[] protoBytes = ValidDeleteResult.make().toProtobuf().toByteArray();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobufBytes(protoBytes);
         ValidDeleteResult.assertEquals(result);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 1c5a443..8f4de60 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -20,14 +20,6 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
-
 
 import android.os.Parcel;
-import com.google.common.collect.ImmutableMap;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
@@ -42,203 +34,119 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
-    @Test
-    public void testBuilder_setAdditionalProperty() {
-        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
-                AuthenticationMethods.EMAIL)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(2);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
-        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
-                AuthenticationMethods.EMAIL)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalPropertyAsString() {
-        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
-                AuthenticationMethods.EMAIL)
-                .setAdditionalPropertyAsString(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_STRING_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
-                        ADDITIONAL_PROP_STRING_VALUE));
-    }
-
-    @Test
-    public void testGetAdditionalProperty() {
-        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
-                AuthenticationMethods.EMAIL)
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
-                .build();
-
-        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testGetAdditionalProperty_withMissingKey() {
-        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
-                AuthenticationMethods.EMAIL)
-                .build();
-        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
-    }
-
-    @Test
-    public void testGetAdditionalPropertyAsString() {
-        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
-                AuthenticationMethods.EMAIL)
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
-                .build();
-
-        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
-    }
-
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         CredentialRetrieveRequest.fromProtobuf(null);
     }
 
     @Test
     public void testWriteAndRead() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .setRequireUserMediation(true)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             ValidTokenProviderMap.assertEquals(deserialized.getTokenProviders());
             ValidAdditionalProperties.assertEquals(deserialized.getAdditionalProperties());
             assertThat(deserialized.getRequireUserMediation()).isTrue();
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
             .fromAuthMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
 
     @Test
     public void toProtocolBuffer_usingDefaultBuilder_returnsExpectedValues() {
         CredentialRetrieveRequest request =
                 new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL).build();
 
         Protobufs.CredentialRetrieveRequest protoRequest = request.toProtocolBuffer();
 
         assertThat(protoRequest.getRequireUserMediation())
                 .isEqualTo(CredentialRetrieveRequest.DEFAULT_REQUIRE_USER_MEDIATION_VALUE);
     }
 
     @Test
     public void toProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
index 116f27a..11d0651 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
@@ -17,10 +17,4 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 
 import android.content.Intent;
-import com.google.common.collect.ImmutableMap;
 import java.util.Map;
@@ -33,190 +27,106 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link CredentialRetrieveResult}. */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveResultTest {
 
   private static final class ValidCredential {
     public static final String ID = "email@gogo.com";
     public static final AuthenticationMethod AUTHENTICATION_METHOD = AuthenticationMethods.EMAIL;
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTHENTICATION_DOMAIN =
         new AuthenticationDomain(AUTH_DOMAIN_STR);
     public static final Credential INSTANCE =
         new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN).build();
 
     private static void assertEqualTo(Credential credential) {
       assertThat(credential.getIdentifier()).isEqualTo(ID);
     }
 
     private static void assertEqualTo(Protobufs.Credential credential) {
       assertThat(credential.getId()).isEqualTo(ID);
     }
   }
 
   private static final class ValidCredentialSelectedResult {
     public static int RESULT_CODE = CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED;
     public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
     public static final CredentialRetrieveResult INSTANCE =
         new CredentialRetrieveResult.Builder(RESULT_CODE)
             .setCredential(ValidCredential.INSTANCE)
             .setAdditionalProperties(ADDITIONAL_PROPERTIES)
             .build();
 
     private static void assertEqualTo(Protobufs.CredentialRetrieveResult result) {
       assertThat(result.getResultCodeValue()).isEqualTo(RESULT_CODE);
       ValidCredential.assertEqualTo(result.getCredential());
       ValidProperties.assertEqualTo(result.getAdditionalPropsMap(), false /* dummy */);
     }
 
     private static void assertEqualTo(CredentialRetrieveResult result) {
       assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
       ValidCredential.assertEqualTo(result.getCredential());
       ValidProperties.assertEqualTo(result.getAdditionalProperties());
     }
   }
 
   private static final class ValidBadRequestResult {
     public static int RESULT_CODE = CredentialRetrieveResult.CODE_BAD_REQUEST;
     public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
     public static final CredentialRetrieveResult INSTANCE =
         new CredentialRetrieveResult.Builder(RESULT_CODE)
             .setAdditionalProperties(ADDITIONAL_PROPERTIES)
             .build();
 
     private static void assertEqualTo(Protobufs.CredentialRetrieveResult result) {
       assertThat(result.getResultCodeValue()).isEqualTo(RESULT_CODE);
       assertThat(result.getCredential()).isEqualTo(Protobufs.Credential.getDefaultInstance());
       ValidProperties.assertEqualTo(result.getAdditionalPropsMap(), false /* dummy */);
     }
 
     private static void assertEqualTo(CredentialRetrieveResult result) {
       assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
       assertThat(result.getCredential()).isNull();
       ValidProperties.assertEqualTo(result.getAdditionalProperties());
     }
   }
 
-  @Test
-  public void testBuilder_setAdditionalProperty() {
-    CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
-            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
-            .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-            .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-            .build();
-
-    Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-    assertThat(additionalProps.size()).isEqualTo(2);
-    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-    assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-            .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
-    assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
-            .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-  }
-
-  @Test
-  public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
-    CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
-            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
-            .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-            .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-            .build();
-
-    Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-    assertThat(additionalProps.size()).isEqualTo(1);
-    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-    assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-            .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-  }
-
-  @Test
-  public void testBuilder_setAdditionalPropertyAsString() {
-    CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
-            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
-            .setAdditionalPropertyAsString(
-                    ADDITIONAL_PROP_TEST_KEY,
-                    ADDITIONAL_PROP_STRING_VALUE)
-            .build();
-
-    Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
-    assertThat(additionalProps.size()).isEqualTo(1);
-    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-    assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-            .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
-                    ADDITIONAL_PROP_STRING_VALUE));
-  }
-
-    @Test
-    public void testGetAdditionalProperty() {
-        CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
-                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
-                .build();
-
-        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testGetAdditionalProperty_withMissingKey() {
-        CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
-                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
-                .build();
-        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
-    }
-
-    @Test
-    public void testGetAdditionalPropertyAsString() {
-        CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
-                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
-                .setAdditionalProperties(ImmutableMap.of(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
-                .build();
-
-        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
-    }
-
   @Test
   public void fromProtobufBytes_withValidCredentialSelectedResult_returnsEquivalent() throws Exception {
     byte[] encodedBytes = ValidCredentialSelectedResult.INSTANCE.toProtobuf().toByteArray();
 
     CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedBytes);
 
     ValidCredentialSelectedResult.assertEqualTo(result);
   }
 
   @Test
   public void fromProtobufBytes_withValidBadRequestResult_returnsEquivalent() throws Exception {
     byte[] encodedBytes = ValidBadRequestResult.INSTANCE.toProtobuf().toByteArray();
 
     CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedBytes);
 
     ValidBadRequestResult.assertEqualTo(result);
   }
 
   @Test
   public void toProtobuf_withValidCredentialSelectedResult_returnsEquivalent() throws Exception {
     ValidCredentialSelectedResult.assertEqualTo(
         ValidCredentialSelectedResult.INSTANCE.toProtobuf());
   }
 
   @Test
   public void toProtobuf_withValidBadRequestResult_returnsEquivalent() throws Exception {
     ValidBadRequestResult.assertEqualTo(ValidBadRequestResult.INSTANCE.toProtobuf());
   }
 
   @Test
   public void toResultDataIntent_withValidRequest_encodesIntoIntent() throws Exception {
     Intent intent = ValidBadRequestResult.INSTANCE.toResultDataIntent();
 
     byte[] encodedResult = intent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT);
     CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedResult);
     ValidBadRequestResult.assertEqualTo(result);
   }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
index f1906e0..0d50e64 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
@@ -35,140 +35,120 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link CredentialSaveRequest} */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class CredentialSaveRequestTest {
 
     private static final class ValidClientVersion {
         public static final int MAJOR = 1;
         public static final int MINOR = 2;
         public static final int PATCH = 3;
         public static final String VENDOR = "com.customVendor";
 
         public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
                 .setMajor(MAJOR)
                 .setMinor(MINOR)
                 .setPatch(PATCH)
                 .setVendor(VENDOR)
                 .build();
     }
 
     private static final class ValidRequest {
         private static final Credential CREDENTIAL = ValidFacebookCredential.make();
         private static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
         private static final CredentialSaveRequest INSTANCE =
                 new CredentialSaveRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(CredentialSaveRequest request) {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             ValidProperties.assertEqualTo(request.getAdditionalProperties());
         }
 
         public static void assertEqualTo(Protobufs.CredentialSaveRequest request) throws Exception {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
 
             final Map<String, byte[]> additionalProperties =
                     CollectionConverter.convertMapValues(
                             request.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             ValidProperties.assertEqualTo(additionalProperties);
         }
     }
 
     @Before
     public void setup() {
         ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtoBytes_withNull_throwsMalformedDataException() throws Exception {
         CredentialSaveRequest.fromProtoBytes(null /* bytes */);
     }
 
     @Test()
     public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
         final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
     public void fromProto_withValidProto_resultIsEqual() throws Exception {
         final CredentialSaveRequest request =
             CredentialSaveRequest.fromProtobuf(ValidRequest.INSTANCE.toProtocolBuffer());
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
         CredentialSaveRequest.fromProtobuf(null);
     }
 
     @Test
     public void fromCredential_withValidCredential_returnsRequestForCredential() {
         final CredentialSaveRequest request =
                 CredentialSaveRequest.fromCredential(ValidFacebookCredential.make());
 
         ValidFacebookCredential.assertEqualTo(request.getCredential());
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void parcelAndUnparcel_withValidCredential_isEqual() {
         Parcel parcel = Parcel.obtain();
         ValidRequest.INSTANCE.writeToParcel(parcel, 0);
         parcel.setDataPosition(0);
         final CredentialSaveRequest request =
                 CredentialSaveRequest.CREATOR.createFromParcel(parcel);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
     public void toProtocolBuffer_withValidCredential_containsClientVersion() throws Exception {
         final Protobufs.CredentialSaveRequest protoRequest =
                 ValidRequest.INSTANCE.toProtocolBuffer();
 
         ValidRequest.assertEqualTo(protoRequest);
     }
 
     @Test
     public void builder_withValidCredential_resultIsEqual() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL).build();
 
         assertThat(request.getCredential()).isSameAs(ValidRequest.CREDENTIAL);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builder_withNullCredential_throwsIllegalArgumentException() {
         new CredentialSaveRequest.Builder((Credential) null);
     }
-
-    public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
-        CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
-                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
-                        .setAdditionalProperties(null)
-                        .build();
-
-        assertThat(request.getAdditionalProperties()).isEmpty();
-    }
-
-    @Test
-    public void builder_setAdditionalProperties_isSuccessful() {
-        final CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
-                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
-                        .build();
-
-        ValidProperties.assertEqualTo(request.getAdditionalProperties());
-    }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
index 0130020..1b63c8b 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
@@ -32,88 +32,67 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link CredentialSaveResult} */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class CredentialSaveResultTest {
 
     private static final class ValidResult {
         public static int RESULT_CODE = CredentialSaveResult.CODE_SAVED;
         public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
         public static final CredentialSaveResult INSTANCE =
                 new CredentialSaveResult.Builder(RESULT_CODE)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(CredentialSaveResult result) {
             assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
             ValidProperties.assertEqualTo(result.getAdditionalProperties());
         }
 
         public static void assertEqualTo(Protobufs.CredentialSaveResult resultProto) {
             assertThat(resultProto.getResultCodeValue()).isEqualTo(RESULT_CODE);
 
             final Map<String, byte[]> additionalProperties =
                     CollectionConverter.convertMapValues(
                             resultProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             ValidProperties.assertEqualTo(additionalProperties);
         }
     }
 
     @Test
     public void fromProtobufBytes_withValidProto_returnsEquivalentResult() throws Exception {
         final CredentialSaveResult result =
                 CredentialSaveResult.fromProtobufBytes(
                         ValidResult.INSTANCE.toProtobuf().toByteArray());
 
         ValidResult.assertEqualTo(result);
     }
 
     @Test
     public void fromProtobuf_withValidProto_returnsEquivalentResult() throws Exception {
         final CredentialSaveResult result =
                 CredentialSaveResult.fromProtobuf(ValidResult.INSTANCE.toProtobuf());
 
         ValidResult.assertEqualTo(result);
     }
 
     @Test
     public void toProtobuf_withValidResult_returnsEquivalentResult() throws Exception {
         ValidResult.assertEqualTo(ValidResult.INSTANCE.toProtobuf());
     }
 
     @Test
     public void toResultDataIntent_withValidResult_returnsValidIntent() throws Exception {
         final Intent resultIntent = ValidResult.INSTANCE.toResultDataIntent();
 
         final byte[] encodedResult =
                 resultIntent.getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_RESULT);
         ValidResult.assertEqualTo(CredentialSaveResult.fromProtobufBytes(encodedResult));
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
         CredentialSaveResult.fromProtobuf(null);
     }
-
-    @Test
-    public void builder_setAdditionalProperties_isSuccessful() {
-        final CredentialSaveResult result =
-                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
-                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
-                        .build();
-
-        ValidResult.assertEqualTo(result);
-    }
-
-    @Test
-    public void builder_setAdditionalPropertiesWithNull_isEmptyMap() {
-        CredentialSaveResult result =
-                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
-                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
-                        .setAdditionalProperties(null)
-                        .build();
-
-        assertThat(result.getAdditionalProperties()).isEmpty();
-    }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 58404c7..7ed58c0 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -19,9 +19,3 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.assertj.core.api.Java6Assertions.linesOf;
 import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 
@@ -29,6 +23,2 @@ import android.net.Uri;
 import android.os.Parcel;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import java.util.Map;
 import org.junit.Test;
@@ -40,364 +30,289 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final String AUTH_DOMAIN_STR = "https://www.example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
     private static final String ID_TOKEN =
             "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSIsImF1ZCI"
                     + "6IlhZWi5jbGllbnQuaWQiLCJpc3MiOiJpZHAuZXhhbXBsZS5jb20iLCJlbWFpbCI"
                     + "6ImFsaWNlQGV4YW1wbGUuY29tIiwibmFtZSI6IkFsaWNlIE1jVGVzdGVyc29uIiw"
                     + "icGljdHVyZSI6Imh0dHBzOi8vcm9ib2hhc2gub3JnL2FsaWNlIn0.2-D7AZ1C7mv"
                     + "dLRf6Q7aqH8Ah4rlK1uuHPSU2HPImtyk";
 
     @Test
     public void fromProtobuf_withValidCredential_returnsEquivalentCredential() throws Exception {
         Credential credential =
                 Credential.fromProtobuf(ValidFacebookCredential.make().toProtobuf());
 
         ValidFacebookCredential.assertEqualTo(credential);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetIdToken_validInput_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         assertThat(cr.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(null)
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken("")
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
         @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
-    @Test
-    public void testBuilder_setAdditionalProperty() {
-        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(2);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
-        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
-                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
-    }
-
-    @Test
-    public void testBuilder_setAdditionalPropertyAsString() {
-        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
-                .setAdditionalPropertyAsString(
-                        ADDITIONAL_PROP_TEST_KEY,
-                        ADDITIONAL_PROP_STRING_VALUE)
-                .build();
-
-        Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
-        assertThat(additionalProps.size()).isEqualTo(1);
-        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
-        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
-                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
-                        ADDITIONAL_PROP_STRING_VALUE));
-    }
-
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
-
-    @Test
-    public void testGetAdditionalProperty() {
-        String key = "testKey";
-        byte[] value = new byte[] { 0, 1 };
-        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
-                .setAdditionalProperties(ImmutableMap.of(key, value))
-                .build();
-
-        assertThat(cr.getAdditionalProperty(key)).isEqualTo(value);
-    }
-
-    @Test
-    public void testGetAdditionalProperty_withMissingKey() {
-        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
-        assertThat(cr.getAdditionalProperty("missingKey")).isNull();
-    }
-
-    @Test
-    public void testGetAdditionalPropertyAsString() {
-        String key = "testKey";
-        byte[] value = AdditionalPropertiesHelper.encodeStringValue("testValue");
-        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
-                .setAdditionalProperties(ImmutableMap.of(key, value))
-                .build();
-
-        assertThat(cr.getAdditionalPropertyAsString(key)).isEqualTo("testValue");
-    }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index f1c5c59..8004df8 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -21,3 +21,2 @@ import com.google.common.collect.ImmutableSet;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
@@ -33,302 +32,283 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testFromAuthMethods() {
         HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods()).containsExactly(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testFromAuthMethods_noneProvided() {
         HintRetrieveRequest.fromAuthMethods();
     }
 
     @Test
     public void testFromAuthMethods_withSet() {
         HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
                 ImmutableSet.of(AuthenticationMethods.EMAIL, AuthenticationMethods.FACEBOOK));
 
         assertThat(request.getAuthenticationMethods()).containsExactly(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK);
     }
 
     @Test(expected=IllegalArgumentException.class)
     public void testFromAuthMethods_emptySet() {
         HintRetrieveRequest.fromAuthMethods(Collections.emptySet());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethodsSet() {
         new HintRetrieveRequest.Builder(Collections.emptySet());
     }
 
     @Test
     public void testBuilder_setTokenProviders() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .build();
 
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
     }
 
     @Test
     public void testBuilder_setTokenProviders_nullMap() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setTokenProviders(null)
                 .build();
 
         assertThat(request.getTokenProviders()).isEmpty();
     }
 
     @Test
     public void testBuilder_addTokenProvider_noInfo() {
         String tokenProvider = "https://my.token.provider";
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addTokenProvider(tokenProvider)
                 .build();
 
         assertThat(request.getTokenProviders()).containsKey(tokenProvider);
         assertThat(request.getTokenProviders().get(tokenProvider))
                 .isEqualTo(TokenRequestInfo.DEFAULT);
     }
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setPasswordSpecification(originalSpec)
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL);
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
             ValidTokenProviderMap.assertEquals(read.getTokenProviders());
             ValidAdditionalProperties.assertEquals(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Set<AuthenticationMethod>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testBuild_setAdditionalProperties_nullKey() {
-        HashMap<String, byte[]> additionalProps = new HashMap<>();
-        additionalProps.put(null, new byte[0]);
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAdditionalProperties(additionalProps)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = IllegalArgumentException.class)
-    public void testBuild_setAdditionalProperty_nullValue() {
-        HashMap<String, byte[]> additionalProps = new HashMap<>();
-        additionalProps.put("a", null);
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAdditionalProperties(additionalProps)
-                .build();
-    }
-
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
index 48c0ece..e247568 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
@@ -27,101 +27,90 @@ import org.robolectric.annotation.Config;
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveResultTest {
 
     private static final String ALICE_ID = "alice@example.com";
     private static final Hint HINT =
             new Hint.Builder(
                     ALICE_ID,
                     AuthenticationMethods.EMAIL)
                     .build();
 
     @Test
     public void build() {
 
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isSameAs(HINT);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void buildSetHint_nullValue() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setHint(null)
                 .build();
 
         assertThat(result.getHint()).isNull();
     }
 
     @Test
     public void fromProtobuf_withDefaultInstanceOfHint_doesNotThrowException() throws Exception {
         Protobufs.HintRetrieveResult hintRetrieveResult =
                 Protobufs.HintRetrieveResult.newBuilder().build();
 
         HintRetrieveResult.fromProtobuf(hintRetrieveResult);
     }
 
-    @Test
-    public void buildSetAdditionalProperties() {
-        HintRetrieveResult result = new HintRetrieveResult.Builder(
-                HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
-                .setAdditionalProperties(ValidAdditionalProperties.make())
-                .build();
-
-        assertThat(result.getAdditionalProperties()).hasSize(1);
-        ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
-    }
-
     @Test
     public void toProtobuf() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Protobufs.HintRetrieveResult proto = result.toProtobuf();
         assertThat(proto.getResultCodeValue()).isEqualTo(ResultCode.HINT_SELECTED_VALUE);
         assertThat(proto.hasHint());
         ValidAdditionalProperties.assertEqualsForProto(proto.getAdditionalPropsMap());
     }
 
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.HintRetrieveResult proto = Protobufs.HintRetrieveResult.newBuilder()
                 .setResultCode(ResultCode.HINT_SELECTED)
                 .setHint(Protobufs.Hint.newBuilder()
                         .setId(ALICE_ID)
                         .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf()))
                 .putAllAdditionalProps(ValidAdditionalProperties.makeForProto())
                 .build();
 
         HintRetrieveResult result = HintRetrieveResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isNotNull();
         ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
     }
 
     @Test
     public void toResultIntentData() throws Exception {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Intent intent = result.toResultDataIntent();
         assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
         byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
 
         HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
         assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(readResult.getHint()).isNotNull();
         ValidAdditionalProperties.assertEquals(readResult.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintTest.java b/protocol/javatests/org/openyolo/protocol/HintTest.java
index fc7af05..ee73ff8 100644
--- a/protocol/javatests/org/openyolo/protocol/HintTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintTest.java
@@ -33,144 +33,128 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link Hint}*/
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class HintTest {
 
     private static final String ID = "coold00d@aol.gov";
 
     Context mContext;
 
     @Before
     public void initializeMocks() throws Exception {
         mContext = TestConstants.ValidApplication.install(RuntimeEnvironment.application);
     }
 
     @Test
     public void build_withRequiredParamsOnly() {
         Hint hint = new Hint.Builder(ID, AuthenticationMethods.EMAIL).build();
 
         assertThat(hint.getIdentifier()).isEqualTo(ID);
         assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
         assertThat(hint.getDisplayName()).isNull();
         assertThat(hint.getDisplayPicture()).isNull();
         assertThat(hint.getIdToken()).isNull();
         assertThat(hint.getAdditionalProperties()).isEmpty();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullId_shouldThrowException() {
         new Hint.Builder(
                 null,// id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void build_emptyId_shouldThrowException() {
         new Hint.Builder(
                 "", // id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethod_shouldThrowException() {
         new Hint.Builder(
                 ID,
                 (AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
                 ID,
                 (String) null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void build_emptyAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
                 ID,
                 "")
                 .build();
     }
 
-    @Test
-    public void builderSetAdditionalProps() {
-        String additionalKey = "extra";
-        byte[] additionalValue = "value".getBytes();
-
-        Map<String, byte[]> additionalProps = new HashMap<>();
-        additionalProps.put(additionalKey, additionalValue);
-        Hint hint = new Hint.Builder(ValidEmailHint.make())
-                .setAdditionalProperties(additionalProps)
-                .build();
-
-        assertThat(hint.getAdditionalProperties()).hasSize(1);
-        assertThat(hint.getAdditionalProperties()).containsKey(additionalKey);
-        assertThat(hint.getAdditionalProperties().get(additionalKey)).isEqualTo(additionalValue);
-    }
-
     @Test
     public void builder_withHintContructor_isEquivalent() {
         Hint hint = new Hint.Builder(ValidEmailHint.make()).build();
 
         ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void toProtobuf_isEquivalent() {
         Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
 
         ValidEmailHint.assertEquals(proto);
     }
 
     @Test
     public void fromProtobuf_isEquivalent() throws Exception {
         Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
         Hint hint = Hint.fromProtobuf(proto);
 
         ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void fromProtobufBytes_isEquivalent() throws Exception {
         Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
         Hint hint = Hint.fromProtobufBytes(proto.toByteArray());
 
         ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void writeToAndReadFromParcel() {
         Hint hint = ValidEmailHint.make();
 
         Parcel p = Parcel.obtain();
         try {
             hint.writeToParcel(p, 0);
             p.setDataPosition(0);
             Hint readHint = Hint.CREATOR.createFromParcel(p);
 
             ValidEmailHint.assertEquals(readHint);
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void toCredentialBuilder_isEquivalent() {
         Credential credential = ValidEmailHint.make().toCredentialBuilder(mContext).build();
 
         ValidEmailHint.assertEquals(mContext, credential);
     }
 
     @Test
     public void describeContents() {
         Hint hint = ValidEmailHint.make();
         assertThat(hint.describeContents()).isEqualTo(0);
     }
 }

commit 7b7ef9fb613e59fb3d7a3a1467ceacb35a480851
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 4 14:51:06 2017 -0700

    Fix line endings on all affected files in repository (#121)
    
    ... ONCE AND FOR ALL

diff --git a/.gitattributes b/.gitattributes
index d76b58d..10e398e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,4 @@
 # always use unix line endings
 * text eol=lf
+*.jar binary -diff
+*.png binary -diff
diff --git a/api/javatests/org/openyolo/api/internal/ActivityResultTest.java b/api/javatests/org/openyolo/api/internal/ActivityResultTest.java
index 95e28e3..6524631 100644
--- a/api/javatests/org/openyolo/api/internal/ActivityResultTest.java
+++ b/api/javatests/org/openyolo/api/internal/ActivityResultTest.java
@@ -1,42 +1,42 @@
-package org.openyolo.api.internal;
-
-import android.content.Intent;
-import android.os.Parcel;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.protocol.CredentialDeleteResult;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-/**
- * Units tests for {@link ActivityResult}.
- */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public class ActivityResultTest {
-
-    @Test
-    public void parcelAndUnparcel_withValidInput_returnsEquivalent() throws Exception {
-        Parcel parcel = Parcel.obtain();
-
-        int resultCode = CredentialDeleteResult.CODE_BAD_REQUEST;
-        Intent intent = CredentialDeleteResult.BAD_REQUEST.toResultDataIntent();
-
-        // Act
-        ActivityResult givenActivityResult = ActivityResult.of(resultCode, intent);
-        givenActivityResult.writeToParcel(parcel, 0 /* flags */);
-
-        parcel.setDataPosition(0);
-        ActivityResult outputActivityResult = ActivityResult.CREATOR.createFromParcel(parcel);
-
-        // Assert
-        assertThat(outputActivityResult.getResultCode()).isEqualTo(resultCode);
-
-        CredentialDeleteResult credentialDeleteResult =
-                CredentialDeleteResult.fromResultIntentData(outputActivityResult.getData());
-        assertThat(credentialDeleteResult.getResultCode()).isEqualTo(resultCode);
-    }
-}
+package org.openyolo.api.internal;
+
+import android.content.Intent;
+import android.os.Parcel;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.CredentialDeleteResult;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+/**
+ * Units tests for {@link ActivityResult}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ActivityResultTest {
+
+    @Test
+    public void parcelAndUnparcel_withValidInput_returnsEquivalent() throws Exception {
+        Parcel parcel = Parcel.obtain();
+
+        int resultCode = CredentialDeleteResult.CODE_BAD_REQUEST;
+        Intent intent = CredentialDeleteResult.BAD_REQUEST.toResultDataIntent();
+
+        // Act
+        ActivityResult givenActivityResult = ActivityResult.of(resultCode, intent);
+        givenActivityResult.writeToParcel(parcel, 0 /* flags */);
+
+        parcel.setDataPosition(0);
+        ActivityResult outputActivityResult = ActivityResult.CREATOR.createFromParcel(parcel);
+
+        // Assert
+        assertThat(outputActivityResult.getResultCode()).isEqualTo(resultCode);
+
+        CredentialDeleteResult credentialDeleteResult =
+                CredentialDeleteResult.fromResultIntentData(outputActivityResult.getData());
+        assertThat(credentialDeleteResult.getResultCode()).isEqualTo(resultCode);
+    }
+}
diff --git a/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java b/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java
index b493ab0..3c09650 100644
--- a/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java
+++ b/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java
@@ -1,85 +1,85 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.persistence.internal;
-
-import android.content.Context;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.api.persistence.internal.SettingsFactory.BooleanSetting;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-/** Unit tests for {@link org.openyolo.api.persistence.internal.SettingsFactoryImpl} */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public final class SettingsFactoryImplTest {
-
-    private static final String NAMESPACE_A = "com.namespace.a";
-    private static final String NAMESPACE_B = "com.namespace.b";
-    private static final String BOOLEAN_KEY = "whatIsLife?";
-    private static final Context CONTEXT = RuntimeEnvironment.application;
-
-    private SettingsFactory mSettingsFactoryA;
-    private SettingsFactory mSettingsFactoryB;
-
-    @Before
-    public void setup() {
-        mSettingsFactoryA = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_A);
-        mSettingsFactoryB = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_B);
-    }
-
-    @Test
-    public void makeBooleanSetting_defaultValueFalse_returnsFalse() {
-        boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, false /* defaultValue */).get();
-        assertThat(value).isFalse();
-    }
-
-    @Test
-    public void makeBooleanSetting_defaultValueTrue_returnsTrue() {
-        boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, true /* defaultValue */).get();
-        assertThat(value).isTrue();
-    }
-
-    @Test
-    public void makeBooleansSettings_sameNamespacesSameKey_haveSameValues() {
-        final String key = "key";
-        final Boolean defaultValue = false;
-
-        BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue);
-        settingA.set(true);
-        BooleanSetting settingB = mSettingsFactoryA.makeBoolean(key, defaultValue);
-
-        assertThat(settingA.get()).isTrue();
-        assertThat(settingB.get()).isTrue();
-    }
-
-    @Test
-    public void makeBooleansSettings_differentNamespacesButSameKey_haveDifferentValues() {
-        final String key = "key";
-        final Boolean defaultValue = false;
-
-        BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue);
-        settingA.set(true);
-        BooleanSetting settingB = mSettingsFactoryB.makeBoolean(key, defaultValue);
-
-        assertThat(settingA.get()).isTrue();
-        assertThat(settingB.get()).isFalse();
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+import android.content.Context;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.persistence.internal.SettingsFactory.BooleanSetting;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+/** Unit tests for {@link org.openyolo.api.persistence.internal.SettingsFactoryImpl} */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class SettingsFactoryImplTest {
+
+    private static final String NAMESPACE_A = "com.namespace.a";
+    private static final String NAMESPACE_B = "com.namespace.b";
+    private static final String BOOLEAN_KEY = "whatIsLife?";
+    private static final Context CONTEXT = RuntimeEnvironment.application;
+
+    private SettingsFactory mSettingsFactoryA;
+    private SettingsFactory mSettingsFactoryB;
+
+    @Before
+    public void setup() {
+        mSettingsFactoryA = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_A);
+        mSettingsFactoryB = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_B);
+    }
+
+    @Test
+    public void makeBooleanSetting_defaultValueFalse_returnsFalse() {
+        boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, false /* defaultValue */).get();
+        assertThat(value).isFalse();
+    }
+
+    @Test
+    public void makeBooleanSetting_defaultValueTrue_returnsTrue() {
+        boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, true /* defaultValue */).get();
+        assertThat(value).isTrue();
+    }
+
+    @Test
+    public void makeBooleansSettings_sameNamespacesSameKey_haveSameValues() {
+        final String key = "key";
+        final Boolean defaultValue = false;
+
+        BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue);
+        settingA.set(true);
+        BooleanSetting settingB = mSettingsFactoryA.makeBoolean(key, defaultValue);
+
+        assertThat(settingA.get()).isTrue();
+        assertThat(settingB.get()).isTrue();
+    }
+
+    @Test
+    public void makeBooleansSettings_differentNamespacesButSameKey_haveDifferentValues() {
+        final String key = "key";
+        final Boolean defaultValue = false;
+
+        BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue);
+        settingA.set(true);
+        BooleanSetting settingB = mSettingsFactoryB.makeBoolean(key, defaultValue);
+
+        assertThat(settingA.get()).isTrue();
+        assertThat(settingB.get()).isFalse();
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
index a5859f7..f1906e0 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
@@ -1,174 +1,174 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.protocol;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-import android.os.Parcel;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestConstants.ValidProperties;
-import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.ClientVersionUtil;
-import org.openyolo.protocol.internal.CollectionConverter;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-
-/** Unit tests for {@link CredentialSaveRequest} */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public final class CredentialSaveRequestTest {
-
-    private static final class ValidClientVersion {
-        public static final int MAJOR = 1;
-        public static final int MINOR = 2;
-        public static final int PATCH = 3;
-        public static final String VENDOR = "com.customVendor";
-
-        public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
-                .setMajor(MAJOR)
-                .setMinor(MINOR)
-                .setPatch(PATCH)
-                .setVendor(VENDOR)
-                .build();
-    }
-
-    private static final class ValidRequest {
-        private static final Credential CREDENTIAL = ValidFacebookCredential.make();
-        private static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
-
-        private static final CredentialSaveRequest INSTANCE =
-                new CredentialSaveRequest.Builder(CREDENTIAL)
-                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
-                        .build();
-
-        public static void assertEqualTo(CredentialSaveRequest request) {
-            ValidFacebookCredential.assertEqualTo(request.getCredential());
-            ValidProperties.assertEqualTo(request.getAdditionalProperties());
-        }
-
-        public static void assertEqualTo(Protobufs.CredentialSaveRequest request) throws Exception {
-            ValidFacebookCredential.assertEqualTo(request.getCredential());
-            assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
-
-            final Map<String, byte[]> additionalProperties =
-                    CollectionConverter.convertMapValues(
-                            request.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
-
-            ValidProperties.assertEqualTo(additionalProperties);
-        }
-    }
-
-    @Before
-    public void setup() {
-        ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
-    }
-
-    @Test(expected = MalformedDataException.class)
-    public void fromProtoBytes_withNull_throwsMalformedDataException() throws Exception {
-        CredentialSaveRequest.fromProtoBytes(null /* bytes */);
-    }
-
-    @Test()
-    public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
-        final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
-
-        final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
-
-        ValidRequest.assertEqualTo(request);
-    }
-
-    @Test
-    public void fromProto_withValidProto_resultIsEqual() throws Exception {
-        final CredentialSaveRequest request =
-            CredentialSaveRequest.fromProtobuf(ValidRequest.INSTANCE.toProtocolBuffer());
-
-        ValidRequest.assertEqualTo(request);
-    }
-
-    @Test(expected = MalformedDataException.class)
-    public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
-        CredentialSaveRequest.fromProtobuf(null);
-    }
-
-    @Test
-    public void fromCredential_withValidCredential_returnsRequestForCredential() {
-        final CredentialSaveRequest request =
-                CredentialSaveRequest.fromCredential(ValidFacebookCredential.make());
-
-        ValidFacebookCredential.assertEqualTo(request.getCredential());
-        assertThat(request.getAdditionalProperties()).isEmpty();
-    }
-
-    @Test
-    public void parcelAndUnparcel_withValidCredential_isEqual() {
-        Parcel parcel = Parcel.obtain();
-        ValidRequest.INSTANCE.writeToParcel(parcel, 0);
-        parcel.setDataPosition(0);
-        final CredentialSaveRequest request =
-                CredentialSaveRequest.CREATOR.createFromParcel(parcel);
-
-        ValidRequest.assertEqualTo(request);
-    }
-
-    @Test
-    public void toProtocolBuffer_withValidCredential_containsClientVersion() throws Exception {
-        final Protobufs.CredentialSaveRequest protoRequest =
-                ValidRequest.INSTANCE.toProtocolBuffer();
-
-        ValidRequest.assertEqualTo(protoRequest);
-    }
-
-    @Test
-    public void builder_withValidCredential_resultIsEqual() {
-        final CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL).build();
-
-        assertThat(request.getCredential()).isSameAs(ValidRequest.CREDENTIAL);
-        assertThat(request.getAdditionalProperties()).isEmpty();
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void builder_withNullCredential_throwsIllegalArgumentException() {
-        new CredentialSaveRequest.Builder((Credential) null);
-    }
-
-    public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
-        CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
-                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
-                        .setAdditionalProperties(null)
-                        .build();
-
-        assertThat(request.getAdditionalProperties()).isEmpty();
-    }
-
-    @Test
-    public void builder_setAdditionalProperties_isSuccessful() {
-        final CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
-                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
-                        .build();
-
-        ValidProperties.assertEqualTo(request.getAdditionalProperties());
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.os.Parcel;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidProperties;
+import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/** Unit tests for {@link CredentialSaveRequest} */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class CredentialSaveRequestTest {
+
+    private static final class ValidClientVersion {
+        public static final int MAJOR = 1;
+        public static final int MINOR = 2;
+        public static final int PATCH = 3;
+        public static final String VENDOR = "com.customVendor";
+
+        public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
+                .setMajor(MAJOR)
+                .setMinor(MINOR)
+                .setPatch(PATCH)
+                .setVendor(VENDOR)
+                .build();
+    }
+
+    private static final class ValidRequest {
+        private static final Credential CREDENTIAL = ValidFacebookCredential.make();
+        private static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+
+        private static final CredentialSaveRequest INSTANCE =
+                new CredentialSaveRequest.Builder(CREDENTIAL)
+                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+                        .build();
+
+        public static void assertEqualTo(CredentialSaveRequest request) {
+            ValidFacebookCredential.assertEqualTo(request.getCredential());
+            ValidProperties.assertEqualTo(request.getAdditionalProperties());
+        }
+
+        public static void assertEqualTo(Protobufs.CredentialSaveRequest request) throws Exception {
+            ValidFacebookCredential.assertEqualTo(request.getCredential());
+            assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
+
+            final Map<String, byte[]> additionalProperties =
+                    CollectionConverter.convertMapValues(
+                            request.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+
+            ValidProperties.assertEqualTo(additionalProperties);
+        }
+    }
+
+    @Before
+    public void setup() {
+        ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtoBytes_withNull_throwsMalformedDataException() throws Exception {
+        CredentialSaveRequest.fromProtoBytes(null /* bytes */);
+    }
+
+    @Test()
+    public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
+        final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
+
+        final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
+
+        ValidRequest.assertEqualTo(request);
+    }
+
+    @Test
+    public void fromProto_withValidProto_resultIsEqual() throws Exception {
+        final CredentialSaveRequest request =
+            CredentialSaveRequest.fromProtobuf(ValidRequest.INSTANCE.toProtocolBuffer());
+
+        ValidRequest.assertEqualTo(request);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
+        CredentialSaveRequest.fromProtobuf(null);
+    }
+
+    @Test
+    public void fromCredential_withValidCredential_returnsRequestForCredential() {
+        final CredentialSaveRequest request =
+                CredentialSaveRequest.fromCredential(ValidFacebookCredential.make());
+
+        ValidFacebookCredential.assertEqualTo(request.getCredential());
+        assertThat(request.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void parcelAndUnparcel_withValidCredential_isEqual() {
+        Parcel parcel = Parcel.obtain();
+        ValidRequest.INSTANCE.writeToParcel(parcel, 0);
+        parcel.setDataPosition(0);
+        final CredentialSaveRequest request =
+                CredentialSaveRequest.CREATOR.createFromParcel(parcel);
+
+        ValidRequest.assertEqualTo(request);
+    }
+
+    @Test
+    public void toProtocolBuffer_withValidCredential_containsClientVersion() throws Exception {
+        final Protobufs.CredentialSaveRequest protoRequest =
+                ValidRequest.INSTANCE.toProtocolBuffer();
+
+        ValidRequest.assertEqualTo(protoRequest);
+    }
+
+    @Test
+    public void builder_withValidCredential_resultIsEqual() {
+        final CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL).build();
+
+        assertThat(request.getCredential()).isSameAs(ValidRequest.CREDENTIAL);
+        assertThat(request.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void builder_withNullCredential_throwsIllegalArgumentException() {
+        new CredentialSaveRequest.Builder((Credential) null);
+    }
+
+    public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
+        CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
+                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
+                        .setAdditionalProperties(null)
+                        .build();
+
+        assertThat(request.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void builder_setAdditionalProperties_isSuccessful() {
+        final CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
+                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
+                        .build();
+
+        ValidProperties.assertEqualTo(request.getAdditionalProperties());
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
index 0ff4540..0130020 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
@@ -1,119 +1,119 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.protocol;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-import android.content.Intent;
-import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestConstants.ValidProperties;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-
-/** Unit tests for {@link CredentialSaveResult} */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public final class CredentialSaveResultTest {
-
-    private static final class ValidResult {
-        public static int RESULT_CODE = CredentialSaveResult.CODE_SAVED;
-        public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
-
-        public static final CredentialSaveResult INSTANCE =
-                new CredentialSaveResult.Builder(RESULT_CODE)
-                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
-                        .build();
-
-        public static void assertEqualTo(CredentialSaveResult result) {
-            assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
-            ValidProperties.assertEqualTo(result.getAdditionalProperties());
-        }
-
-        public static void assertEqualTo(Protobufs.CredentialSaveResult resultProto) {
-            assertThat(resultProto.getResultCodeValue()).isEqualTo(RESULT_CODE);
-
-            final Map<String, byte[]> additionalProperties =
-                    CollectionConverter.convertMapValues(
-                            resultProto.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
-
-            ValidProperties.assertEqualTo(additionalProperties);
-        }
-    }
-
-    @Test
-    public void fromProtobufBytes_withValidProto_returnsEquivalentResult() throws Exception {
-        final CredentialSaveResult result =
-                CredentialSaveResult.fromProtobufBytes(
-                        ValidResult.INSTANCE.toProtobuf().toByteArray());
-
-        ValidResult.assertEqualTo(result);
-    }
-
-    @Test
-    public void fromProtobuf_withValidProto_returnsEquivalentResult() throws Exception {
-        final CredentialSaveResult result =
-                CredentialSaveResult.fromProtobuf(ValidResult.INSTANCE.toProtobuf());
-
-        ValidResult.assertEqualTo(result);
-    }
-
-    @Test
-    public void toProtobuf_withValidResult_returnsEquivalentResult() throws Exception {
-        ValidResult.assertEqualTo(ValidResult.INSTANCE.toProtobuf());
-    }
-
-    @Test
-    public void toResultDataIntent_withValidResult_returnsValidIntent() throws Exception {
-        final Intent resultIntent = ValidResult.INSTANCE.toResultDataIntent();
-
-        final byte[] encodedResult =
-                resultIntent.getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_RESULT);
-        ValidResult.assertEqualTo(CredentialSaveResult.fromProtobufBytes(encodedResult));
-    }
-
-    @Test(expected = MalformedDataException.class)
-    public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
-        CredentialSaveResult.fromProtobuf(null);
-    }
-
-    @Test
-    public void builder_setAdditionalProperties_isSuccessful() {
-        final CredentialSaveResult result =
-                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
-                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
-                        .build();
-
-        ValidResult.assertEqualTo(result);
-    }
-
-    @Test
-    public void builder_setAdditionalPropertiesWithNull_isEmptyMap() {
-        CredentialSaveResult result =
-                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
-                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
-                        .setAdditionalProperties(null)
-                        .build();
-
-        assertThat(result.getAdditionalProperties()).isEmpty();
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.content.Intent;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidProperties;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/** Unit tests for {@link CredentialSaveResult} */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class CredentialSaveResultTest {
+
+    private static final class ValidResult {
+        public static int RESULT_CODE = CredentialSaveResult.CODE_SAVED;
+        public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+
+        public static final CredentialSaveResult INSTANCE =
+                new CredentialSaveResult.Builder(RESULT_CODE)
+                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+                        .build();
+
+        public static void assertEqualTo(CredentialSaveResult result) {
+            assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
+            ValidProperties.assertEqualTo(result.getAdditionalProperties());
+        }
+
+        public static void assertEqualTo(Protobufs.CredentialSaveResult resultProto) {
+            assertThat(resultProto.getResultCodeValue()).isEqualTo(RESULT_CODE);
+
+            final Map<String, byte[]> additionalProperties =
+                    CollectionConverter.convertMapValues(
+                            resultProto.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+
+            ValidProperties.assertEqualTo(additionalProperties);
+        }
+    }
+
+    @Test
+    public void fromProtobufBytes_withValidProto_returnsEquivalentResult() throws Exception {
+        final CredentialSaveResult result =
+                CredentialSaveResult.fromProtobufBytes(
+                        ValidResult.INSTANCE.toProtobuf().toByteArray());
+
+        ValidResult.assertEqualTo(result);
+    }
+
+    @Test
+    public void fromProtobuf_withValidProto_returnsEquivalentResult() throws Exception {
+        final CredentialSaveResult result =
+                CredentialSaveResult.fromProtobuf(ValidResult.INSTANCE.toProtobuf());
+
+        ValidResult.assertEqualTo(result);
+    }
+
+    @Test
+    public void toProtobuf_withValidResult_returnsEquivalentResult() throws Exception {
+        ValidResult.assertEqualTo(ValidResult.INSTANCE.toProtobuf());
+    }
+
+    @Test
+    public void toResultDataIntent_withValidResult_returnsValidIntent() throws Exception {
+        final Intent resultIntent = ValidResult.INSTANCE.toResultDataIntent();
+
+        final byte[] encodedResult =
+                resultIntent.getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_RESULT);
+        ValidResult.assertEqualTo(CredentialSaveResult.fromProtobufBytes(encodedResult));
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
+        CredentialSaveResult.fromProtobuf(null);
+    }
+
+    @Test
+    public void builder_setAdditionalProperties_isSuccessful() {
+        final CredentialSaveResult result =
+                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
+                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
+                        .build();
+
+        ValidResult.assertEqualTo(result);
+    }
+
+    @Test
+    public void builder_setAdditionalPropertiesWithNull_isEmptyMap() {
+        CredentialSaveResult result =
+                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
+                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
+                        .setAdditionalProperties(null)
+                        .build();
+
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/Constants.java b/spi/javatests/java/org/openyolo/spi/Constants.java
index 47551b2..dd072fd 100644
--- a/spi/javatests/java/org/openyolo/spi/Constants.java
+++ b/spi/javatests/java/org/openyolo/spi/Constants.java
@@ -1,18 +1,18 @@
-package org.openyolo.spi;
-
-import org.openyolo.protocol.AuthenticationDomain;
-
-/** Collection of test constants. */
-public final class Constants {
-    private Constants() {}
-
-    public static final class ValidApplication {
-        private ValidApplication() {}
-
-        public static String PACKAGE_NAME = "com.super.cool.app";
-
-        private static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
-        public static AuthenticationDomain AUTHENTICATION_DOMAIN =
-                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
-    }
-}
+package org.openyolo.spi;
+
+import org.openyolo.protocol.AuthenticationDomain;
+
+/** Collection of test constants. */
+public final class Constants {
+    private Constants() {}
+
+    public static final class ValidApplication {
+        private ValidApplication() {}
+
+        public static String PACKAGE_NAME = "com.super.cool.app";
+
+        private static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
+        public static AuthenticationDomain AUTHENTICATION_DOMAIN =
+                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
+    }
+}
diff --git a/testapp/res/layout/other_test_layout.xml b/testapp/res/layout/other_test_layout.xml
index 1569047..1d82159 100644
--- a/testapp/res/layout/other_test_layout.xml
+++ b/testapp/res/layout/other_test_layout.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.v4.widget.NestedScrollView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    app:layout_behavior="@string/appbar_scrolling_view_behavior"
-    style="@style/DemoContent">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <Button
-            android:id="@+id/disable_auto_sign_in_button"
-            style="@style/Widget.AppCompat.Button.Colored"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="16dp"
-            android:layout_marginLeft="8dp"
-            android:layout_marginRight="8dp"
-            android:layout_gravity="center_horizontal"
-            android:contentDescription="@string/disable_auto_sign_in_button_content_description"
-            android:text="@string/disable_auto_sign_in_button_label"
-            android:theme="@style/GreenButtonThemeOverlay"/>
-
-    </LinearLayout>
-</android.support.v4.widget.NestedScrollView>
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.NestedScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:layout_behavior="@string/appbar_scrolling_view_behavior"
+    style="@style/DemoContent">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <Button
+            android:id="@+id/disable_auto_sign_in_button"
+            style="@style/Widget.AppCompat.Button.Colored"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="16dp"
+            android:layout_marginLeft="8dp"
+            android:layout_marginRight="8dp"
+            android:layout_gravity="center_horizontal"
+            android:contentDescription="@string/disable_auto_sign_in_button_content_description"
+            android:text="@string/disable_auto_sign_in_button_label"
+            android:theme="@style/GreenButtonThemeOverlay"/>
+
+    </LinearLayout>
+</android.support.v4.widget.NestedScrollView>

commit 24a4e3f64b03047a642ccb1d1269758c7d6e9810
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 4 14:08:15 2017 -0700

    Fix line endings in README.md (#118)

diff --git a/api/README.md b/api/README.md
index f3ba82f..ce19a03 100644
--- a/api/README.md
+++ b/api/README.md
@@ -1,215 +1,215 @@
-# OpenYOLO for Android - Programmatic Credential API
-
-<div align="center">
-  <img src="https://user-images.githubusercontent.com/445775/30930082-60d21ace-a375-11e7-90cf-cc75fe5747fd.gif"/>
-  <p><em>Example of auto sign-in</em></p>
-</div>
-
-This is an open-source client library for the OpenYOLO for Android protocol. It allows you to easily
-manipulate credentials for your application by interacting with the credential provider of the
-user's choice. This allows you to:
-
-1. Automatically sign users into your app using saved credentials.
-1. Rapidly on-board new users by bootstrapping off of existing identities.
-1. Prompt users after sign-in/sign up to save their credentials for future automatic sign in.
-
-## Installation
-[ ![Download](https://api.bintray.com/packages/openid/net.openid/openyolo-api/images/download.svg) ](https://bintray.com/openid/net.openid/openyolo-api/_latestVersion)
-
-As a pre-requisite, you will need to add the OpenYOLO Api as a dependency. Check
-[here](https://bintray.com/openid/net.openid/openyolo-api) or the above button for the latest
-version. For example, if your project uses Gradle:
-
-```groovy
-dependencies {
-    // ...
-    compile 'org.openyolo:openyolo-api:x.y.z'
-}
-```
-
-## Terminology
-
- - [Authentication Method](http://openid.net/specs/openyolo-android-ID1.html#authentication-methods):
-An authentication method is a mechanism by which a credential can be verified. It is represented as
-a URI of the form ```scheme://authority```. For example OpenYOLO defines several common types such
-as ``openyolo://email`` and ```openyolo://phone```.  When requesting a credential or hint your
-application will declare which authentication methods it supports.
- - [Authentication Domain](http://openid.net/specs/openyolo-android-ID1.html#authentication-domains):
-An authentication domain is the scope in which a credential is considered to be usable. A domain
-spans a single Android application or web address. If your authentication system does not span
-multiple domains you can safely ignore this concept as a client. However, if your application offers
-both an app and web app you can prove this relationship to credential providers to allow credentials
-to be shared between the two. ```TOOD(dxslly): Add guide for linking authentication domains.```
-
-## Usage
-
-The entry point is the ```CredentialClient``` class. It is a light weight client that can be created
-as needed and offers methods to perform all standard flows. The majority of flows follow the pattern
-of sending requests via launching Activity based intents and optionally handling their results via
-the ```onActivityResult()``` call back.
-
-A typical sequence of flows for sign-in might looks as follows:
-1. Auto Sign-In: Attempt to auto sign in the user, by retrieving a saved credential.
-1. Account Creation: If no credential was found and the user is interested in signing in, assist in
-account creation by retrieving a hint.
-1. Save valid credential: If the user was successfully signed in, save the credential for future
-retrieve calls.
-1. Delete stale credential: If a retrieved credential is no longer valid, delete the credential so
-it will not be returned in future retrieve calls.
-
-### Auto Sign-In
-
-It is recommended to always try to automatically Sign-In the user first.  This is done by crafting a
-```CredentialRetrieveRequest``` listing the Authentication Methods your application supports (e.g.
-```AuthenticationMethods.EMAIL``` if your app uses email based identifier and optionally a
-password).
-
-```java
-CredentialClient client = CredentialClient.getInstance(getContext());
-
-CredentialRetrieveRequest request  =
-    CredentialRetrieveRequest.fromAuthMethods(
-        AuthenticationMethods.EMAIL,
-        AuthenticationMethods.GOOGLE);
-Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
-startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
-```
-
-Receive the results and check if a credential was returned:
-1. If a credential was returned, attempt to sign-in using your own authentication system. If the
-credential was not valid (ie. it failed to authenticate the user), delete the credential.
-1. If no credential was returned it is recommended to try to assist the user with account creation
-unless the result code specifies the user does not wish to. Notable result codes that indicate the
-user wants to branch away from assisted account creation are:
-    - USER_CANCELED: Indicates the user does not want to authenticate at this time. It is
-      recommended to eject from the sign-in process at this point.
-    - USER_REQUESTS_MANUAL_AUTH: Indicates the user wants to authenticate manually. It is
-      recommended to drop out of these assisted/automatic flows at this point.
-
-```java
-@Override
-public void onActivityResult(int requestCode, int resultCode, Intent data) {
-    super.onActivityResult(requestCode, resultCode, data);
-    if (RC_RETRIEVE_CREDENTIAL == requestCode) {
-       CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
-       if (result.isSuccessful()) {
-           // A credential was retrieved, you may automatically sign the user in.
-           result.getCredential();
-       } else {
-           // A credential was not retrieved, you may look at the result code to determine why
-           // and decide what step to take next. For example, result code may inform you of the
-           // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
-           result.getResultCode();
-       }
-    }
-}
-```
-
-### Account Creation
-
-If the user could not be automatically signed-in, assisting with account creation is the next
-recommended step. This request is very similar to the credential retrieval request, requiring you to
-list the Authentication Methods your application supports.
-
-```java
-CredentialClient client = CredentialClient.getInstance(getContext());
-
-HintRetrieveRequest request  =
-    HintRetrieveRequest.fromAuthMethods(
-        AuthenticationMethods.EMAIL,
-        AuthenticationMethods.GOOGLE);
-Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
-startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
-```
-
-Receive the results and check if a hint was returned:
-1. If a hint was returned, it is recommended to check if an account with a matching identifier
-   already exists and intelligently switch to a log-in flow. If no existing account matches there
-   are several branches of actions your app may want to take:
-    1. If enough information is present, you may automatically create a new account for the user.
-       The amount of information required will depend on the authentication method and personal
-       requirements.
-    1. If more information is needed to create an account, it is recommended to use the given
-       information to skip manual entry and have the user finish account creation manually.
-1. If a hint was not returned, it is recommended to fallback to manual account creation unless the
-   result code specifies the user does not wish to. A result code of ```USER_CANCELED``` indicates
-   the user does not wish to authenticate at this time.
-   
-Once the account has been created you should save the credential for future retrieve calls.
-
-```java
-public void onActivityResult(int requestCode, int resultCode, Intent data) {
-    super.onActivityResult(requestCode, resultCode, data);
-    if (RC_RETRIEVE_HINT == requestCode) {
-       HintRetrieveResult result = client.getHintRetrieveResult(data);
-       if (result.isSuccessful()) {
-         // A hint was retrieved, you may be able to automatically create an account for the
-         // user, or offer the user to sign in if an existing account matches the hint.
-         result.getHint();
-       } else {
-         // A credential was not retrieved, you may look at the result code to determine why
-         // and decide what step to take next. For example, result code may inform you of the
-         // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
-         result.getResultCode();
-       }
-    }
-}
-```
-
-### Saving Valid Credentials
-
-When ever a valid credential is changed or created (e.g. a manual password change, or a new account
-is created) it is recommended that you save the new or updated credential to enable a future
-automatic sign-in experience.
-
-```java
-// Craft the valid credential.
-String identifer = "joe@gmail.com";
-AuthenticationMethod authMethod = AuthenticationMethods.EMAIL;
-AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(this);
-Credential credential = new Credential.Builder(identifier, authMethod, authDomain).build();
-
-// Or if you have created an account using a hint there is a utility method that will convert the
-// hint into a new Credential.Builder.
-Credential credential = hint.toCredentialBuilder(this).build();
-
-// Send the request. It is safe to ignore the result.
-Intent saveCredentialIntent = client.getSaveIntent(credential);
-startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
-```
-
-### Deleting Invalid Credentials
-
-If a retrieved credential turns out to be invalid it is recommended that you delete the credential.
-
-```java
-// Send the request. It is safe to ignore the result.
-Intent deleteCredentialIntent = client.getDeleteIntent(credential);
-startActivityForResult(deleteCredentialIntent, RC_DELETE_CREDENTIAL);
-```
-
-
-### Signing Out
-
-There is a common pitfall when implementing account sign-in/sign-out where an application will
-automatically sign-in a user after they have just signed out when the user's intention was likely to
-either remain signed out or switch to a new account. To resolve this, some state needs to be added
-for tracking the user's previous intent and prevent the user from being automatically signed in
-again.
-
-The ```CredentialClient.disableAutoSignIn()``` offers a simple way to handle this case. Once called
-it will require the user to mediate auto sign-in requests until a successful request is fulfilled.
-It is recommended you call this method whenever a user is signed out of your application. 
-
-```java
-public void signOutUser() {
-    // Your application's custom sign out logic.
-    // ...
-    CredentialClient client = CredentialClient.getInstance(getContext());
-    client.disableAutoSignIn();
-}
-```
-
-## Testing against providers
-
-// TODO(dxslly): Describe how to test in the wild, enumerate production implementations?
+# OpenYOLO for Android - Programmatic Credential API
+
+<div align="center">
+  <img src="https://user-images.githubusercontent.com/445775/30930082-60d21ace-a375-11e7-90cf-cc75fe5747fd.gif"/>
+  <p><em>Example of auto sign-in</em></p>
+</div>
+
+This is an open-source client library for the OpenYOLO for Android protocol. It allows you to easily
+manipulate credentials for your application by interacting with the credential provider of the
+user's choice. This allows you to:
+
+1. Automatically sign users into your app using saved credentials.
+1. Rapidly on-board new users by bootstrapping off of existing identities.
+1. Prompt users after sign-in/sign up to save their credentials for future automatic sign in.
+
+## Installation
+[ ![Download](https://api.bintray.com/packages/openid/net.openid/openyolo-api/images/download.svg) ](https://bintray.com/openid/net.openid/openyolo-api/_latestVersion)
+
+As a pre-requisite, you will need to add the OpenYOLO Api as a dependency. Check
+[here](https://bintray.com/openid/net.openid/openyolo-api) or the above button for the latest
+version. For example, if your project uses Gradle:
+
+```groovy
+dependencies {
+    // ...
+    compile 'org.openyolo:openyolo-api:x.y.z'
+}
+```
+
+## Terminology
+
+ - [Authentication Method](http://openid.net/specs/openyolo-android-ID1.html#authentication-methods):
+An authentication method is a mechanism by which a credential can be verified. It is represented as
+a URI of the form ```scheme://authority```. For example OpenYOLO defines several common types such
+as ``openyolo://email`` and ```openyolo://phone```.  When requesting a credential or hint your
+application will declare which authentication methods it supports.
+ - [Authentication Domain](http://openid.net/specs/openyolo-android-ID1.html#authentication-domains):
+An authentication domain is the scope in which a credential is considered to be usable. A domain
+spans a single Android application or web address. If your authentication system does not span
+multiple domains you can safely ignore this concept as a client. However, if your application offers
+both an app and web app you can prove this relationship to credential providers to allow credentials
+to be shared between the two. ```TOOD(dxslly): Add guide for linking authentication domains.```
+
+## Usage
+
+The entry point is the ```CredentialClient``` class. It is a light weight client that can be created
+as needed and offers methods to perform all standard flows. The majority of flows follow the pattern
+of sending requests via launching Activity based intents and optionally handling their results via
+the ```onActivityResult()``` call back.
+
+A typical sequence of flows for sign-in might looks as follows:
+1. Auto Sign-In: Attempt to auto sign in the user, by retrieving a saved credential.
+1. Account Creation: If no credential was found and the user is interested in signing in, assist in
+account creation by retrieving a hint.
+1. Save valid credential: If the user was successfully signed in, save the credential for future
+retrieve calls.
+1. Delete stale credential: If a retrieved credential is no longer valid, delete the credential so
+it will not be returned in future retrieve calls.
+
+### Auto Sign-In
+
+It is recommended to always try to automatically Sign-In the user first.  This is done by crafting a
+```CredentialRetrieveRequest``` listing the Authentication Methods your application supports (e.g.
+```AuthenticationMethods.EMAIL``` if your app uses email based identifier and optionally a
+password).
+
+```java
+CredentialClient client = CredentialClient.getInstance(getContext());
+
+CredentialRetrieveRequest request  =
+    CredentialRetrieveRequest.fromAuthMethods(
+        AuthenticationMethods.EMAIL,
+        AuthenticationMethods.GOOGLE);
+Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
+startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
+```
+
+Receive the results and check if a credential was returned:
+1. If a credential was returned, attempt to sign-in using your own authentication system. If the
+credential was not valid (ie. it failed to authenticate the user), delete the credential.
+1. If no credential was returned it is recommended to try to assist the user with account creation
+unless the result code specifies the user does not wish to. Notable result codes that indicate the
+user wants to branch away from assisted account creation are:
+    - USER_CANCELED: Indicates the user does not want to authenticate at this time. It is
+      recommended to eject from the sign-in process at this point.
+    - USER_REQUESTS_MANUAL_AUTH: Indicates the user wants to authenticate manually. It is
+      recommended to drop out of these assisted/automatic flows at this point.
+
+```java
+@Override
+public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
+    if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+       CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
+       if (result.isSuccessful()) {
+           // A credential was retrieved, you may automatically sign the user in.
+           result.getCredential();
+       } else {
+           // A credential was not retrieved, you may look at the result code to determine why
+           // and decide what step to take next. For example, result code may inform you of the
+           // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
+           result.getResultCode();
+       }
+    }
+}
+```
+
+### Account Creation
+
+If the user could not be automatically signed-in, assisting with account creation is the next
+recommended step. This request is very similar to the credential retrieval request, requiring you to
+list the Authentication Methods your application supports.
+
+```java
+CredentialClient client = CredentialClient.getInstance(getContext());
+
+HintRetrieveRequest request  =
+    HintRetrieveRequest.fromAuthMethods(
+        AuthenticationMethods.EMAIL,
+        AuthenticationMethods.GOOGLE);
+Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
+startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
+```
+
+Receive the results and check if a hint was returned:
+1. If a hint was returned, it is recommended to check if an account with a matching identifier
+   already exists and intelligently switch to a log-in flow. If no existing account matches there
+   are several branches of actions your app may want to take:
+    1. If enough information is present, you may automatically create a new account for the user.
+       The amount of information required will depend on the authentication method and personal
+       requirements.
+    1. If more information is needed to create an account, it is recommended to use the given
+       information to skip manual entry and have the user finish account creation manually.
+1. If a hint was not returned, it is recommended to fallback to manual account creation unless the
+   result code specifies the user does not wish to. A result code of ```USER_CANCELED``` indicates
+   the user does not wish to authenticate at this time.
+   
+Once the account has been created you should save the credential for future retrieve calls.
+
+```java
+public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
+    if (RC_RETRIEVE_HINT == requestCode) {
+       HintRetrieveResult result = client.getHintRetrieveResult(data);
+       if (result.isSuccessful()) {
+         // A hint was retrieved, you may be able to automatically create an account for the
+         // user, or offer the user to sign in if an existing account matches the hint.
+         result.getHint();
+       } else {
+         // A credential was not retrieved, you may look at the result code to determine why
+         // and decide what step to take next. For example, result code may inform you of the
+         // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
+         result.getResultCode();
+       }
+    }
+}
+```
+
+### Saving Valid Credentials
+
+When ever a valid credential is changed or created (e.g. a manual password change, or a new account
+is created) it is recommended that you save the new or updated credential to enable a future
+automatic sign-in experience.
+
+```java
+// Craft the valid credential.
+String identifer = "joe@gmail.com";
+AuthenticationMethod authMethod = AuthenticationMethods.EMAIL;
+AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(this);
+Credential credential = new Credential.Builder(identifier, authMethod, authDomain).build();
+
+// Or if you have created an account using a hint there is a utility method that will convert the
+// hint into a new Credential.Builder.
+Credential credential = hint.toCredentialBuilder(this).build();
+
+// Send the request. It is safe to ignore the result.
+Intent saveCredentialIntent = client.getSaveIntent(credential);
+startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
+```
+
+### Deleting Invalid Credentials
+
+If a retrieved credential turns out to be invalid it is recommended that you delete the credential.
+
+```java
+// Send the request. It is safe to ignore the result.
+Intent deleteCredentialIntent = client.getDeleteIntent(credential);
+startActivityForResult(deleteCredentialIntent, RC_DELETE_CREDENTIAL);
+```
+
+
+### Signing Out
+
+There is a common pitfall when implementing account sign-in/sign-out where an application will
+automatically sign-in a user after they have just signed out when the user's intention was likely to
+either remain signed out or switch to a new account. To resolve this, some state needs to be added
+for tracking the user's previous intent and prevent the user from being automatically signed in
+again.
+
+The ```CredentialClient.disableAutoSignIn()``` offers a simple way to handle this case. Once called
+it will require the user to mediate auto sign-in requests until a successful request is fulfilled.
+It is recommended you call this method whenever a user is signed out of your application. 
+
+```java
+public void signOutUser() {
+    // Your application's custom sign out logic.
+    // ...
+    CredentialClient client = CredentialClient.getInstance(getContext());
+    client.disableAutoSignIn();
+}
+```
+
+## Testing against providers
+
+// TODO(dxslly): Describe how to test in the wild, enumerate production implementations?

commit c99deb49fa17309c9bf2da9c19c3ad051f115149
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 4 13:42:20 2017 -0700

    Ensure that only unix-style line endings are used (#111)

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..d76b58d
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# always use unix line endings
+* text eol=lf
diff --git a/api/java/org/openyolo/api/CredentialClientOptions.java b/api/java/org/openyolo/api/CredentialClientOptions.java
index 4410198..ee5ac9c 100644
--- a/api/java/org/openyolo/api/CredentialClientOptions.java
+++ b/api/java/org/openyolo/api/CredentialClientOptions.java
@@ -1,74 +1,74 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.valid4j.Validation.validate;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-
-import org.openyolo.api.persistence.AppSettings;
-
-
-/**
- * Context object that may be used to configure a {@link CredentialClient} instance. It is
- * recommended to use the default options via {@link CredentialClient#getInstance(Context)}.
- */
-public class CredentialClientOptions {
-    private final AppSettings mAppSettings;
-
-    private CredentialClientOptions(Builder builder) {
-        mAppSettings = builder.mAppSettings;
-    }
-
-    @NonNull
-    AppSettings getDeviceState() {
-        return mAppSettings;
-    }
-
-    /**
-     * Builder for {@link CredentialClientOptions}.
-     */
-    public static final class Builder {
-        private AppSettings mAppSettings;
-
-        /**
-         * Default builder for {@link CredentialClientOptions}.
-         */
-        public Builder(@NonNull AppSettings deviceState) {
-            setDeviceState(deviceState);
-        }
-
-        /**
-         * Specifies the {@link AppSettings} implementation that will be used by the
-         * {@link CredentialClient}.
-         */
-        public Builder setDeviceState(@NonNull AppSettings appSettings) {
-            validate(appSettings, notNullValue(), NullPointerException.class);
-
-            this.mAppSettings = appSettings;
-            return this;
-        }
-
-        /**
-         * Returns a new {@link CredentialClientOptions} instance based on the configuration of this
-         * builder.
-         */
-        public CredentialClientOptions build() {
-            return new CredentialClientOptions(this);
-        }
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Validation.validate;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+
+import org.openyolo.api.persistence.AppSettings;
+
+
+/**
+ * Context object that may be used to configure a {@link CredentialClient} instance. It is
+ * recommended to use the default options via {@link CredentialClient#getInstance(Context)}.
+ */
+public class CredentialClientOptions {
+    private final AppSettings mAppSettings;
+
+    private CredentialClientOptions(Builder builder) {
+        mAppSettings = builder.mAppSettings;
+    }
+
+    @NonNull
+    AppSettings getDeviceState() {
+        return mAppSettings;
+    }
+
+    /**
+     * Builder for {@link CredentialClientOptions}.
+     */
+    public static final class Builder {
+        private AppSettings mAppSettings;
+
+        /**
+         * Default builder for {@link CredentialClientOptions}.
+         */
+        public Builder(@NonNull AppSettings deviceState) {
+            setDeviceState(deviceState);
+        }
+
+        /**
+         * Specifies the {@link AppSettings} implementation that will be used by the
+         * {@link CredentialClient}.
+         */
+        public Builder setDeviceState(@NonNull AppSettings appSettings) {
+            validate(appSettings, notNullValue(), NullPointerException.class);
+
+            this.mAppSettings = appSettings;
+            return this;
+        }
+
+        /**
+         * Returns a new {@link CredentialClientOptions} instance based on the configuration of this
+         * builder.
+         */
+        public CredentialClientOptions build() {
+            return new CredentialClientOptions(this);
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/ActivityResult.java b/api/java/org/openyolo/api/internal/ActivityResult.java
index ece9b0a..5ba28e9 100644
--- a/api/java/org/openyolo/api/internal/ActivityResult.java
+++ b/api/java/org/openyolo/api/internal/ActivityResult.java
@@ -1,82 +1,82 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.internal;
-
-import android.content.Intent;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Parcelable representation of an activity result.
- */
-public final class ActivityResult implements Parcelable {
-
-    /**
-     * Parcelable creator for {@link ActivityResult}.
-     */
-    public static final Parcelable.Creator<ActivityResult> CREATOR = new Creator();
-
-    private final int mResultCode;
-    private final Intent mData;
-
-    /**
-     * Returns a new instance of an {@link ActivityResult} from the given result code and intent
-     * data.
-     */
-    public static ActivityResult of(int resultCode, Intent data) {
-        return new ActivityResult(resultCode, data);
-    }
-
-    private ActivityResult(int resultCode, Intent data) {
-        mResultCode = resultCode;
-        mData = data;
-    }
-
-    private ActivityResult(Parcel in) {
-        mResultCode = in.readInt();
-        mData = in.readParcelable(Intent.class.getClassLoader());
-    }
-
-    public int getResultCode() {
-        return mResultCode;
-    }
-
-    public Intent getData() {
-        return mData;
-    }
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel out, int flags) {
-        out.writeInt(mResultCode);
-        out.writeParcelable(mData, flags);
-    }
-
-    private static final class Creator implements Parcelable.Creator<ActivityResult> {
-        @Override
-        public ActivityResult createFromParcel(Parcel parcel) {
-            return new ActivityResult(parcel);
-        }
-
-        @Override
-        public ActivityResult[] newArray(int size) {
-            return new ActivityResult[0];
-        }
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Parcelable representation of an activity result.
+ */
+public final class ActivityResult implements Parcelable {
+
+    /**
+     * Parcelable creator for {@link ActivityResult}.
+     */
+    public static final Parcelable.Creator<ActivityResult> CREATOR = new Creator();
+
+    private final int mResultCode;
+    private final Intent mData;
+
+    /**
+     * Returns a new instance of an {@link ActivityResult} from the given result code and intent
+     * data.
+     */
+    public static ActivityResult of(int resultCode, Intent data) {
+        return new ActivityResult(resultCode, data);
+    }
+
+    private ActivityResult(int resultCode, Intent data) {
+        mResultCode = resultCode;
+        mData = data;
+    }
+
+    private ActivityResult(Parcel in) {
+        mResultCode = in.readInt();
+        mData = in.readParcelable(Intent.class.getClassLoader());
+    }
+
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    public Intent getData() {
+        return mData;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeInt(mResultCode);
+        out.writeParcelable(mData, flags);
+    }
+
+    private static final class Creator implements Parcelable.Creator<ActivityResult> {
+        @Override
+        public ActivityResult createFromParcel(Parcel parcel) {
+            return new ActivityResult(parcel);
+        }
+
+        @Override
+        public ActivityResult[] newArray(int size) {
+            return new ActivityResult[0];
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/persistence/AppSettings.java b/api/java/org/openyolo/api/persistence/AppSettings.java
index 403bed5..db63295 100644
--- a/api/java/org/openyolo/api/persistence/AppSettings.java
+++ b/api/java/org/openyolo/api/persistence/AppSettings.java
@@ -1,31 +1,31 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.persistence;
-
-/**
- * Interface for the collection persisted settings. Settings should beper application per device.
- */
-public interface AppSettings {
-
-    /**
-     * Returns {@code true} if the current application has disabled automatically signing in.
-     */
-    boolean isAutoSignInDisabled();
-
-    /**
-     * Setter for {@link #isAutoSignInDisabled()}.
-     */
-    void setIsAutoSignInDisabled(boolean isDisabled);
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence;
+
+/**
+ * Interface for the collection persisted settings. Settings should beper application per device.
+ */
+public interface AppSettings {
+
+    /**
+     * Returns {@code true} if the current application has disabled automatically signing in.
+     */
+    boolean isAutoSignInDisabled();
+
+    /**
+     * Setter for {@link #isAutoSignInDisabled()}.
+     */
+    void setIsAutoSignInDisabled(boolean isDisabled);
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java b/api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java
index 17f559a..f5f6765 100644
--- a/api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java
+++ b/api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java
@@ -1,52 +1,52 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.persistence.internal;
-
-import android.content.Context;
-
-import org.openyolo.api.persistence.AppSettings;
-
-/**
- * The default implementation of {@link AppSettings}.
- */
-public final class AppSettingsImpl implements AppSettings {
-
-    private static final String SETTING_NAME_SPACE = "AppSettings";
-    private static final String KEY_IS_AUTO_SIGN_IN_DISABLED = "is_auto_sign_in_disabled";
-
-    private final SettingsFactory.BooleanSetting mIsAutoSignInDisabled;
-
-    /**
-     * Returns a new instance of {@link AppSettingsImpl}.
-     */
-    public static AppSettings getInstance(Context context) {
-        return new AppSettingsImpl(SettingsFactoryImpl.getInstance(context, SETTING_NAME_SPACE));
-    }
-
-    private AppSettingsImpl(SettingsFactory settingsFactory) {
-        mIsAutoSignInDisabled =
-                settingsFactory.makeBoolean(KEY_IS_AUTO_SIGN_IN_DISABLED, false /* defaultValue */);
-    }
-
-    @Override
-    public boolean isAutoSignInDisabled() {
-        return mIsAutoSignInDisabled.get();
-    }
-
-    @Override
-    public void setIsAutoSignInDisabled(boolean isDisabled) {
-        mIsAutoSignInDisabled.set(isDisabled);
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+import android.content.Context;
+
+import org.openyolo.api.persistence.AppSettings;
+
+/**
+ * The default implementation of {@link AppSettings}.
+ */
+public final class AppSettingsImpl implements AppSettings {
+
+    private static final String SETTING_NAME_SPACE = "AppSettings";
+    private static final String KEY_IS_AUTO_SIGN_IN_DISABLED = "is_auto_sign_in_disabled";
+
+    private final SettingsFactory.BooleanSetting mIsAutoSignInDisabled;
+
+    /**
+     * Returns a new instance of {@link AppSettingsImpl}.
+     */
+    public static AppSettings getInstance(Context context) {
+        return new AppSettingsImpl(SettingsFactoryImpl.getInstance(context, SETTING_NAME_SPACE));
+    }
+
+    private AppSettingsImpl(SettingsFactory settingsFactory) {
+        mIsAutoSignInDisabled =
+                settingsFactory.makeBoolean(KEY_IS_AUTO_SIGN_IN_DISABLED, false /* defaultValue */);
+    }
+
+    @Override
+    public boolean isAutoSignInDisabled() {
+        return mIsAutoSignInDisabled.get();
+    }
+
+    @Override
+    public void setIsAutoSignInDisabled(boolean isDisabled) {
+        mIsAutoSignInDisabled.set(isDisabled);
+    }
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java b/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java
index e2ca1c4..facfa85 100644
--- a/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java
+++ b/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.persistence.internal;
-
-/**
- * Factory for creating settings.
- */
-interface SettingsFactory {
-
-    /**
-     * Returns a new {@link BooleanSetting} based on the given key and default value.
-     * @param key a unique identifier that acts as the primary key of the setting.
-     * @param defaultValue the default value of the setting.
-     */
-    BooleanSetting makeBoolean(String key, boolean defaultValue);
-
-    /**
-     * A boolean setting.
-     */
-    interface BooleanSetting {
-
-        /**
-         * Returns the current value if one has been set, otherwise the default value.
-         */
-        boolean get();
-
-        /**
-         * Sets the current value of the setting to the given value.
-         */
-        void set(boolean value);
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+/**
+ * Factory for creating settings.
+ */
+interface SettingsFactory {
+
+    /**
+     * Returns a new {@link BooleanSetting} based on the given key and default value.
+     * @param key a unique identifier that acts as the primary key of the setting.
+     * @param defaultValue the default value of the setting.
+     */
+    BooleanSetting makeBoolean(String key, boolean defaultValue);
+
+    /**
+     * A boolean setting.
+     */
+    interface BooleanSetting {
+
+        /**
+         * Returns the current value if one has been set, otherwise the default value.
+         */
+        boolean get();
+
+        /**
+         * Sets the current value of the setting to the given value.
+         */
+        void set(boolean value);
+    }
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java b/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java
index b89de05..094c5af 100644
--- a/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java
+++ b/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java
@@ -1,82 +1,82 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.persistence.internal;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-/**
- * The default {@link SettingsFactory} implementation backed by {@link SharedPreferences}.
- */
-final class SettingsFactoryImpl implements SettingsFactory {
-    private final SharedPreferences mSharedPreferences;
-
-    /**
-     * Returns a new instance of the {@link SettingsFactoryImpl} for the given settings namespace.
-     */
-    public static SettingsFactoryImpl getInstance(Context context, String namespace) {
-        return new SettingsFactoryImpl(context, namespace);
-    }
-
-    private SettingsFactoryImpl(Context context, String namespace) {
-        mSharedPreferences = context.getSharedPreferences(namespace, Context.MODE_PRIVATE);
-    }
-
-    /**
-     * Returns a new {@link SettingsFactory.BooleanSetting} based on
-     * the given key and default value.
-     */
-    public BooleanSetting makeBoolean(String key, boolean defaultValue) {
-        return BooleanSettingImpl.make(mSharedPreferences, key, defaultValue);
-    }
-
-    /**
-     * The default internal implementation of a {@link SettingsFactory.BooleanSetting}.
-     */
-    private static final class BooleanSettingImpl implements BooleanSetting {
-        private final String mKey;
-        private final boolean mDefaultValue;
-        private final SharedPreferences mSharedPreferences;
-
-        private static BooleanSetting make(
-                SharedPreferences sharedPreferences,
-                String key,
-                boolean defaultValue) {
-            return new BooleanSettingImpl(sharedPreferences, key, defaultValue);
-        }
-
-        private BooleanSettingImpl(
-                SharedPreferences sharedPreferences,
-                String key,
-                boolean defaultValue) {
-            mKey = key;
-            mDefaultValue = defaultValue;
-            mSharedPreferences = sharedPreferences;
-        }
-
-        @Override
-        public boolean get() {
-            return mSharedPreferences.getBoolean(mKey, mDefaultValue);
-        }
-
-        @Override
-        public void set(boolean value) {
-            SharedPreferences.Editor editor = mSharedPreferences.edit();
-            editor.putBoolean(mKey, value);
-            editor.apply();
-        }
-    }
-
-}
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * The default {@link SettingsFactory} implementation backed by {@link SharedPreferences}.
+ */
+final class SettingsFactoryImpl implements SettingsFactory {
+    private final SharedPreferences mSharedPreferences;
+
+    /**
+     * Returns a new instance of the {@link SettingsFactoryImpl} for the given settings namespace.
+     */
+    public static SettingsFactoryImpl getInstance(Context context, String namespace) {
+        return new SettingsFactoryImpl(context, namespace);
+    }
+
+    private SettingsFactoryImpl(Context context, String namespace) {
+        mSharedPreferences = context.getSharedPreferences(namespace, Context.MODE_PRIVATE);
+    }
+
+    /**
+     * Returns a new {@link SettingsFactory.BooleanSetting} based on
+     * the given key and default value.
+     */
+    public BooleanSetting makeBoolean(String key, boolean defaultValue) {
+        return BooleanSettingImpl.make(mSharedPreferences, key, defaultValue);
+    }
+
+    /**
+     * The default internal implementation of a {@link SettingsFactory.BooleanSetting}.
+     */
+    private static final class BooleanSettingImpl implements BooleanSetting {
+        private final String mKey;
+        private final boolean mDefaultValue;
+        private final SharedPreferences mSharedPreferences;
+
+        private static BooleanSetting make(
+                SharedPreferences sharedPreferences,
+                String key,
+                boolean defaultValue) {
+            return new BooleanSettingImpl(sharedPreferences, key, defaultValue);
+        }
+
+        private BooleanSettingImpl(
+                SharedPreferences sharedPreferences,
+                String key,
+                boolean defaultValue) {
+            mKey = key;
+            mDefaultValue = defaultValue;
+            mSharedPreferences = sharedPreferences;
+        }
+
+        @Override
+        public boolean get() {
+            return mSharedPreferences.getBoolean(mKey, mDefaultValue);
+        }
+
+        @Override
+        public void set(boolean value) {
+            SharedPreferences.Editor editor = mSharedPreferences.edit();
+            editor.putBoolean(mKey, value);
+            editor.apply();
+        }
+    }
+
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/package-info.java b/api/java/org/openyolo/api/persistence/internal/package-info.java
index b68c918..cdf5666 100644
--- a/api/java/org/openyolo/api/persistence/internal/package-info.java
+++ b/api/java/org/openyolo/api/persistence/internal/package-info.java
@@ -1,20 +1,20 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Collection of classes and interfaces related to persisting state used by the OpenYOLO libraries.
- * _NOTE_: The contents of this package are _not_ part of the public API, and may change at any
- * time.
- */
-package org.openyolo.api.persistence.internal;
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Collection of classes and interfaces related to persisting state used by the OpenYOLO libraries.
+ * _NOTE_: The contents of this package are _not_ part of the public API, and may change at any
+ * time.
+ */
+package org.openyolo.api.persistence.internal;
diff --git a/api/java/org/openyolo/api/persistence/package-info.java b/api/java/org/openyolo/api/persistence/package-info.java
index d8c12fa..3c84293 100644
--- a/api/java/org/openyolo/api/persistence/package-info.java
+++ b/api/java/org/openyolo/api/persistence/package-info.java
@@ -1,18 +1,18 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Collection of interfaces related to persisting state.
- */
-package org.openyolo.api.persistence;
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Collection of interfaces related to persisting state.
+ */
+package org.openyolo.api.persistence;
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 3a6d783..66a5e3d 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -6,471 +6,477 @@ Checkstyle-Configuration: Android Style
 Description: https://source.android.com/source/code-style.html
 -->
 <module name="Checker">
   <property name="fileExtensions" value="java, properties, xml"/>
 
   <!-- Require UTF-8 encoding for all files -->
   <property name="charset" value="UTF-8"/>
 
   <!-- Default severity is error -->
   <property name="severity" value="warning"/>
 
   <!-- Warnings can be suppressed by adding them to this file -->
   <module name="SuppressionFilter">
     <property name="file" value="${checkstyle.suppressions}"/>
   </module>
 
   <module name="TreeWalker">
 
     <!--#################################################################-->
     <!--################ NAMING CHECKS ##################################-->
     <!--#################################################################-->
 
     <!-- Require package names to be all lower-case -->
     <module name="PackageName">
         <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
         <message key="name.invalidPattern"
                  value="Package name ''{0}'' must be lower-case."/>
     </module>
 
     <!-- Require standard type names -->
     <module name="TypeName">
         <message key="name.invalidPattern"
          value="Type name ''{0}'' must begin with a capital letter."/>
     </module>
 
     <!--
     Type parameters must either be a single upper-case character, or must begin
     with an upper-case character and end with "T" (e.g. DataT).
     -->
     <module name="ClassTypeParameterName">
       <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
       <message key="name.invalidPattern"
                value="Class type parameter ''{0}'' must either be a single upper-case character, or begin with an upper-case character and end with 'T'."/>
     </module>
 
     <!-- Non-public, non-static members must start with "m" -->
     <module name="MemberName">
       <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
       <property name="applyToPublic" value="false"/>
       <message key="name.invalidPattern"
                value="Member name ''{0}'' must be prefixed with m and be at least two characters long."/>
     </module>
 
     <!--
     Require method names to be at least two characters long, and start with a
     lower case letter.
     -->
     <module name="MethodName">
       <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
       <message key="name.invalidPattern"
                value="Method name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!--
     Type parameters must either be a single upper-case character, or must begin
     with an upper-case character and end with "T" (e.g. DataT).
     -->
     <module name="MethodTypeParameterName">
       <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
       <message key="name.invalidPattern"
                value="Method type parameter ''{0}'' must either be a single upper-case character or begin with an upper-case character and end with 'T'."/>
     </module>
 
     <!-- Require parameter names to be at least two characters long -->
     <module name="ParameterName">
         <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
         <message key="name.invalidPattern"
                  value="Parameter name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!--
     Require local variables to be at least two characters long,
     unless they are counters on a for loop.
     -->
     <module name="LocalVariableName">
         <property name="tokens" value="VARIABLE_DEF"/>
         <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
         <property name="allowOneCharVarInForLoop" value="true"/>
         <message key="name.invalidPattern"
                  value="Local variable name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!-- Require that constants be capitalized. -->
     <module name="ConstantName"/>
 
     <module name="LocalFinalVariableName"/>
 
     <!--
     Require that static, non-public, non-final variable names be prefixed
     with "s".
     -->
     <module name="StaticVariableName">
       <property name="format" value="^s[A-Z][a-zA-Z0-9]*$"/>
       <message key="name.invalidPattern"
                value="Static variable name ''{0}'' must be prefixed with s and be at least two characters long."/>
     </module>
 
     <!-- Capitalized abbreviations are forbidden (e.g. URL, XML, HTTP) -->
     <module name="AbbreviationAsWordInName">
         <property name="ignoreFinal" value="false"/>
         <property name="allowedAbbreviationLength" value="1"/>
     </module>
 
     <!-- Forbid unnecessary escaping. -->
     <module name="IllegalTokenText">
       <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
       <property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
       <property name="message" value="Avoid using corresponding octal or Unicode escape."/>
     </module>
 
     <!-- Forbid unnecessary unicode escapes -->
     <module name="AvoidEscapedUnicodeCharacters">
         <property name="allowEscapesForControlCharacters" value="true"/>
         <property name="allowByTailComment" value="true"/>
         <property name="allowNonPrintableEscapes" value="true"/>
     </module>
 
     <!-- Require array notation on type (e.g. int[] x, not int x[]) -->
     <module name="ArrayTypeStyle"/>
 
     <!--###################################################-->
     <!--################ IMPORTS ##########################-->
     <!--###################################################-->
 
     <!-- Star imports are forbidden. -->
     <module name="AvoidStarImport"/>
 
     <!--
     Imports should be ordered such that static imports come before normal
     imports. Within these groups (separated by an empty line), imports should
     be lexicographially sorted with no further subcategorization required.
      -->
     <module name="CustomImportOrder">
         <property name="sortImportsInGroupAlphabetically" value="true"/>
         <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
     </module>
 
     <!-- Forbid imports from sun.* -->
     <module name="IllegalImport"/>
 
     <!-- Forbid redudant imports (e.g. import java.lang.String;) -->
     <module name="RedundantImport"/>
 
     <!-- Forbid unused imports -->
     <module name="UnusedImports"/>
 
     <!-- Forbid redundant modifiers -->
     <module name="RedundantModifier"/>
 
     <!--##############################################################-->
     <!--################ STRUCTURAL / WRAPPING CHECKS ################-->
     <!--##############################################################-->
 
     <!-- Require One top-level class per file -->
     <module name="OneTopLevelClass"/>
 
     <!-- Line-wrapping in import statements is forbidden. -->
     <module name="NoLineWrap"/>
 
     <!-- Empty catch blocks are forbidden. -->
     <module name="EmptyCatchBlock">
       <property name="exceptionVariableName" value="expected|ignore"/>
     </module>
 
     <!-- Require braces for all code blocks -->
     <module name="NeedBraces"/>
 
     <!-- Require One statement per line (e.g. no "a = b; c = d;") -->
     <module name="OneStatementPerLine"/>
 
     <!-- Multiple variable declarations on one line is forbidden. -->
     <module name="MultipleVariableDeclarations"/>
 
     <!-- Require switch statements to have default clause -->
     <module name="MissingSwitchDefault"/>
 
     <!--
     Case fall-through in switch statements is forbidden, except where an
     explicit "// fall-through" comment exists.
     -->
     <module name="FallThrough">
       <property name="reliefPattern" value="fall-through"/>
     </module>
 
     <!-- Require empty lines between definitions -->
     <module name="EmptyLineSeparator">
         <property name="allowNoEmptyLineBetweenFields" value="true"/>
     </module>
 
     <!-- Wrap only permitted before dot, e.g.
     fluentInterface.doX()
         .doY()
         .doZ();
     -->
     <module name="SeparatorWrap">
       <property name="tokens" value="DOT"/>
       <property name="option" value="nl"/>
     </module>
 
     <!-- Wrap only permitted after comma, e.g.
     doThings(withA,
         withB,
         withC);
     -->
     <module name="SeparatorWrap">
         <property name="tokens" value="COMMA"/>
         <property name="option" value="EOL"/>
     </module>
 
     <!-- require line breaks before common binary operators -->
     <module name="OperatorWrap">
         <property name="option" value="NL"/>
         <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
     </module>
 
     <!--
     Require that annotations on type, method and constructor definitions be on
     a separate line.
     -->
     <module name="AnnotationLocation">
       <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
     </module>
 
     <!--
     Variable declarations may have annotations on the same line.
     -->
     <module name="AnnotationLocation">
         <property name="tokens" value="VARIABLE_DEF"/>
         <property name="allowSamelineMultipleAnnotations" value="true"/>
     </module>
 
     <!-- Forbid empty statements -->
     <module name="EmptyStatement"/>
 
     <!--#################################################################-->
     <!--################ WHITESPACE / LINE LENGTH CHECKS ################-->
     <!--#################################################################-->
 
     <!-- Forbid whitespace after prefix unary operators and accessors -->
     <module name="NoWhitespaceAfter">
       <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
     </module>
 
     <!--
     Forbid whitespace before comma, semi-colon, and postfix unary operators
     -->
     <module name="NoWhitespaceBefore"/>
 
     <!-- Require whitespace around common tokens (=, if, etc.) -->
     <module name="WhitespaceAround">
       <property name="allowEmptyConstructors" value="true"/>
       <property name="allowEmptyMethods" value="true"/>
       <property name="allowEmptyTypes" value="true"/>
       <property name="allowEmptyLoops" value="true"/>
       <message key="ws.notFollowed"
        value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
        <message key="ws.notPreceded"
        value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
     </module>
 
     <!-- Require standard whitespace around type parameters -->
     <module name="GenericWhitespace">
       <message key="ws.followed"
                value="GenericWhitespace ''{0}'' is followed by whitespace."/>
        <message key="ws.preceded"
                 value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
        <message key="ws.illegalFollow"
                 value="GenericWhitespace ''{0}'' should followed by whitespace."/>
        <message key="ws.notPreceded"
                 value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
     </module>
 
     <!-- Require Android standard indentation. -->
     <module name="Indentation">
         <property name="basicOffset" value="4"/>
         <property name="braceAdjustment" value="0"/>
         <property name="caseIndent" value="4"/>
         <property name="throwsIndent" value="8"/>
         <property name="lineWrappingIndentation" value="8"/>
         <property name="arrayInitIndent" value="4"/>
     </module>
 
     <!--
     Require that comments be placed at the same level of indentation as
     surrounding code.
     -->
     <module name="CommentsIndentation"/>
 
     <!-- 100 char per line max, unless unavoidable -->
     <module name="LineLength">
       <property name="max" value="100"/>
       <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
     </module>
 
     <!--################################################-->
     <!--################ JAVADOC CHECKS ################-->
     <!--################################################-->
 
     <!--
     Require Javadoc for public methods:
     https://source.android.com/source/code-style.html#use-javadoc-standard-comments
     -->
     <module name="JavadocMethod">
       <property name="scope" value="public"/>
       <!-- exception: property methods (getX, setX, isX) -->
       <property name="allowMissingPropertyJavadoc" value="true"/>
       <!-- exception: method overrides, test methods -->
       <property name="allowedAnnotations" value="Override, Test, Before, After"/>
 
       <!--
       Every parameter need not be documented. This is to avoid the need for
       redundant descriptions between the main description and the parameter
       descriptions.
       -->
       <property name="allowMissingParamTags" value="true"/>
       <!--
       The return value need not be documented. This is to avoid the need for
       redundant descriptions between the main description and the return value
       descriptions.
       -->
       <property name="allowMissingReturnTag" value="true"/>
       <property name="allowThrowsTagsForSubclasses" value="true"/>
       <property name="suppressLoadErrors" value="true"/>
     </module>
 
     <!-- Javadoc required for public fields (part of API) -->
     <module name="JavadocVariable">
       <property name="scope" value="public"/>
     </module>
 
     <!--
     Require descriptions for all included @param / @return / @throws /
     @deprecated tags in Javadoc comments.
     -->
     <module name="NonEmptyAtclauseDescription"/>
 
     <!--
     Require 4-character indentation of @param / @return / @throws / @deprecated
     descriptions which span more than one line.
     -->
     <module name="JavadocTagContinuationIndentation"/>
 
     <!--
     Forbid pointless Javadoc summary sentences.
     -->
     <module name="SummaryJavadocCheck">
       <property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
     </module>
 
     <!-- Require correct order of Javadoc comment tags -->
     <module name="AtclauseOrder">
         <property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
         <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
     </module>
 
     <!-- Single line Javadoc comments with a tag are forbidden. -->
     <module name="SingleLineJavadoc">
       <property name="ignoreInlineTags" value="false"/>
     </module>
 
     <!--
     Require @deprecated Javadoc tag and @Deprecated annotation to be used
     together.
     -->
     <module name="MissingDeprecated"/>
 
     <!--#################################################################-->
     <!--################ MISC. LANGUAGE CHECKS ##########################-->
     <!--#################################################################-->
 
     <!-- File name must correspond to contained class -->
     <module name="OuterTypeFilename"/>
 
     <!--
     Long constants must be suffixed with L:
     "The suffix L is preferred, because the letter l (ell) is often hard to
     distinguish from the digit 1 (one)."
     http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.1
     -->
     <module name="UpperEll"/>
 
     <!--
     Require modifier order consistent with recommends in JLS:
     http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html
     -->
     <module name="ModifierOrder"/>
 
     <!-- Finalizers are forbidden. -->
     <module name="NoFinalizer"/>
 
     <!-- overloaded methods must be grouped together -->
     <module name="OverloadMethodsDeclarationOrder"/>
 
     <!-- Require variables to be declared close to where they are used -->
     <module name="VariableDeclarationUsageDistance"/>
 
     <!-- Require that equals() and hashCode() are overridden together -->
     <module name="EqualsHashCode"/>
 
     <!-- Forbid shadowing fields or variables -->
     <module name="HiddenField">
       <!-- exception: constructor parameters -->
       <property name="ignoreConstructorParameter" value="true"/>
       <!-- exception: setter method parameters -->
       <property name="ignoreSetter" value="true"/>
     </module>
 
     <!--
     Forbid assignments in expressions, with the exception of loop conditions
     -->
     <module name="InnerAssignment"/>
 
     <!-- Require @Override on overridden methods -->
     <module name="MissingOverride"/>
 
     <!-- Forbid arbitrarily nested blocks -->
     <module name="AvoidNestedBlocks"/>
 
     <!-- Forbid the use of arbitrary numeric literals -->
     <module name="MagicNumber"/>
 
     <!-- Require boolean expressions to be simplifed -->
     <module name="SimplifyBooleanExpression"/>
 
     <!-- Require boolean returns to be simplified -->
     <module name="SimplifyBooleanReturn"/>
 
     <!-- Forbid interfaces with no methods -->
     <module name="InterfaceIsType"/>
 
   </module>
 
   <!--################################################-->
   <!--################ Non-AST checks ################-->
   <!--################################################-->
 
   <!-- Ensure the copyright header appears in every java source file -->
   <module name="RegexpHeader">
     <property name="headerFile" value="${checkstyle.java.header}"/>
     <property name="fileExtensions" value="java"/>
   </module>
 
   <!-- Report every line containing a tab character" -->
   <module name="FileTabCharacter">
     <property name="eachLine" value="true"/>
   </module>
 
   <!-- Forbid trailing whitespace -->
   <module name="RegexpSingleline">
     <property name="format" value="\s+$"/>
     <property name="message" value="Line has trailing whitespace."/>
   </module>
 
+  <!-- Forbid Windows (CRLF) or old Mac style (CR) line endings -->
+  <module name="RegexpMultiline">
+    <property name="format" value="\r"/>
+    <property name="message" value="Do not use Windows or old Mac line endings"/>
+  </module>
+
   <!-- require Javadoc for all packages -->
   <module name="JavadocPackage"/>
 
   <!-- Require a new line at the end of all files -->
   <module name="NewlineAtEndOfFile">
     <property name="lineSeparator" value="lf"/>
   </module>
 </module>
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
index 7dfec2f..3fe7e1b 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
@@ -1,229 +1,229 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.protocol;
-
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.valid4j.Validation.validate;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import com.google.protobuf.ByteString;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.ClientVersionUtil;
-import org.openyolo.protocol.internal.CollectionConverter;
-
-/**
- * A request to save a given {@link Credential credential}. To make the request the client
- * encodes it in its associated protocol buffer byte array form in an activity intent
- * via the {@link ProtocolConstants#EXTRA_SAVE_REQUEST} extra.
- *
- * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
- *     OpenYOLO specification: Saving Credentials</a>
- */
-public final class CredentialSaveRequest implements Parcelable {
-
-    /**
-     * Parcelable reader for {@link CredentialSaveRequest} instances.
-     * @see android.os.Parcelable
-     */
-    public static final Creator<CredentialSaveRequest> CREATOR = new CredentialSaveRequestCreator();
-
-    @NonNull
-    private final Credential mCredential;
-
-    @NonNull
-    private final Map<String, ByteString> mAdditionalProperties;
-
-    /**
-     * Creates a credential save request from its protocol buffer byte array form.
-     * @throws MalformedDataException if the given protocol buffer was invalid.
-     *
-     * @see #toProtocolBuffer()
-     */
-    public static CredentialSaveRequest fromProtoBytes(byte[] protoBytes)
-            throws MalformedDataException {
-        validate(protoBytes, notNullValue(), MalformedDataException.class);
-
-        try {
-            Protobufs.CredentialSaveRequest request =
-                    Protobufs.CredentialSaveRequest.parseFrom(protoBytes);
-            return new CredentialSaveRequest.Builder(request).build();
-        } catch (IOException ex) {
-            throw new MalformedDataException(ex);
-        }
-    }
-
-    /**
-     * Creates a credential save request from its protocol buffer form.
-     * @throws MalformedDataException if the given protocol buffer was invalid.
-     *
-     * @see #toProtocolBuffer()
-     */
-    public static CredentialSaveRequest fromProtobuf(Protobufs.CredentialSaveRequest request)
-            throws MalformedDataException {
-        validate(request, notNullValue(), MalformedDataException.class);
-
-        return new CredentialSaveRequest.Builder(request).build();
-    }
-
-    /**
-     * Creates a {@link CredentialSaveRequest} from the given {@link Credential}.
-     */
-    public static CredentialSaveRequest fromCredential(Credential credential) {
-        return new Builder(credential).build();
-    }
-
-    private CredentialSaveRequest(Builder builder) {
-        mCredential = builder.mCredential;
-        mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
-    }
-
-    /**
-     * The credential to be saved.
-     */
-    @NonNull
-    public Credential getCredential() {
-        return mCredential;
-    }
-
-    /**
-     * The map of additional, non-standard properties included with this request.
-     */
-    @NonNull
-    public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-            mAdditionalProperties,
-            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
-    }
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        byte[] protoBytes = toProtocolBuffer().toByteArray();
-        dest.writeInt(protoBytes.length);
-        dest.writeByteArray(protoBytes);
-    }
-
-    /**
-     * Converts the request into a protocol buffer, for storage or transmission.
-     */
-    public Protobufs.CredentialSaveRequest toProtocolBuffer() {
-        return Protobufs.CredentialSaveRequest.newBuilder()
-                .setClientVersion(ClientVersionUtil.getClientVersion())
-                .setCredential(mCredential.toProtobuf())
-                .putAllAdditionalProps(mAdditionalProperties)
-                .build();
-    }
-
-    /**
-     * Creates {@link CredentialSaveRequest} instances.
-     */
-    public static final class Builder {
-
-        private Credential mCredential;
-        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
-
-        /**
-         * Recreates a save request from its protocol buffer form.
-         *
-         * @see CredentialSaveRequest#toProtocolBuffer()
-         */
-        private Builder(@NonNull Protobufs.CredentialSaveRequest request)
-                throws MalformedDataException {
-            validate(request, notNullValue(), MalformedDataException.class);
-
-            try {
-                setCredential(Credential.fromProtobuf(request.getCredential()));
-                setAdditionalProperties(
-                        CollectionConverter.convertMapValues(
-                                request.getAdditionalPropsMap(),
-                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
-            } catch (IllegalArgumentException ex) {
-                throw new MalformedDataException(ex);
-            }
-        }
-
-        /**
-         * Starts the process of defining a save request, specifying the credential to be saved.
-         *
-         * @see Credential
-         */
-        public Builder(@NonNull Credential credential) {
-            setCredential(credential);
-        }
-
-        /**
-         * Specifies the credential to be saved. The provided credential must be non-null.
-         *
-         * @see Credential
-         */
-        public Builder setCredential(@NonNull Credential credential) {
-            validate(credential, notNullValue(), IllegalArgumentException.class);
-
-            mCredential = credential;
-            return this;
-        }
-
-        /**
-         * Specifies the set of additional, non-standard properties to carry with the credential
-         * save request. A null map is treated as an empty map.
-         */
-        @NonNull
-        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
-            mAdditionalProps =
-                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
-            return this;
-        }
-
-        /**
-         * Finalizes the creation of the credential save request.
-         */
-        public CredentialSaveRequest build() {
-            return new CredentialSaveRequest(this);
-        }
-    }
-
-    private static final class CredentialSaveRequestCreator
-            implements Creator<CredentialSaveRequest> {
-        @Override
-        public CredentialSaveRequest createFromParcel(Parcel source) {
-            int length = source.readInt();
-            byte[] encodedRequest = new byte[length];
-            source.readByteArray(encodedRequest);
-
-            try {
-                return CredentialSaveRequest.fromProtoBytes(encodedRequest);
-            } catch (MalformedDataException ex) {
-                throw new IllegalStateException("Unable to read proto from parcel", ex);
-            }
-        }
-
-        @Override
-        public CredentialSaveRequest[] newArray(int size) {
-            return new CredentialSaveRequest[0];
-        }
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Validation.validate;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * A request to save a given {@link Credential credential}. To make the request the client
+ * encodes it in its associated protocol buffer byte array form in an activity intent
+ * via the {@link ProtocolConstants#EXTRA_SAVE_REQUEST} extra.
+ *
+ * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
+ *     OpenYOLO specification: Saving Credentials</a>
+ */
+public final class CredentialSaveRequest implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link CredentialSaveRequest} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<CredentialSaveRequest> CREATOR = new CredentialSaveRequestCreator();
+
+    @NonNull
+    private final Credential mCredential;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProperties;
+
+    /**
+     * Creates a credential save request from its protocol buffer byte array form.
+     * @throws MalformedDataException if the given protocol buffer was invalid.
+     *
+     * @see #toProtocolBuffer()
+     */
+    public static CredentialSaveRequest fromProtoBytes(byte[] protoBytes)
+            throws MalformedDataException {
+        validate(protoBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            Protobufs.CredentialSaveRequest request =
+                    Protobufs.CredentialSaveRequest.parseFrom(protoBytes);
+            return new CredentialSaveRequest.Builder(request).build();
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
+    }
+
+    /**
+     * Creates a credential save request from its protocol buffer form.
+     * @throws MalformedDataException if the given protocol buffer was invalid.
+     *
+     * @see #toProtocolBuffer()
+     */
+    public static CredentialSaveRequest fromProtobuf(Protobufs.CredentialSaveRequest request)
+            throws MalformedDataException {
+        validate(request, notNullValue(), MalformedDataException.class);
+
+        return new CredentialSaveRequest.Builder(request).build();
+    }
+
+    /**
+     * Creates a {@link CredentialSaveRequest} from the given {@link Credential}.
+     */
+    public static CredentialSaveRequest fromCredential(Credential credential) {
+        return new Builder(credential).build();
+    }
+
+    private CredentialSaveRequest(Builder builder) {
+        mCredential = builder.mCredential;
+        mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
+    }
+
+    /**
+     * The credential to be saved.
+     */
+    @NonNull
+    public Credential getCredential() {
+        return mCredential;
+    }
+
+    /**
+     * The map of additional, non-standard properties included with this request.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+            mAdditionalProperties,
+            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        byte[] protoBytes = toProtocolBuffer().toByteArray();
+        dest.writeInt(protoBytes.length);
+        dest.writeByteArray(protoBytes);
+    }
+
+    /**
+     * Converts the request into a protocol buffer, for storage or transmission.
+     */
+    public Protobufs.CredentialSaveRequest toProtocolBuffer() {
+        return Protobufs.CredentialSaveRequest.newBuilder()
+                .setClientVersion(ClientVersionUtil.getClientVersion())
+                .setCredential(mCredential.toProtobuf())
+                .putAllAdditionalProps(mAdditionalProperties)
+                .build();
+    }
+
+    /**
+     * Creates {@link CredentialSaveRequest} instances.
+     */
+    public static final class Builder {
+
+        private Credential mCredential;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Recreates a save request from its protocol buffer form.
+         *
+         * @see CredentialSaveRequest#toProtocolBuffer()
+         */
+        private Builder(@NonNull Protobufs.CredentialSaveRequest request)
+                throws MalformedDataException {
+            validate(request, notNullValue(), MalformedDataException.class);
+
+            try {
+                setCredential(Credential.fromProtobuf(request.getCredential()));
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                request.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
+        }
+
+        /**
+         * Starts the process of defining a save request, specifying the credential to be saved.
+         *
+         * @see Credential
+         */
+        public Builder(@NonNull Credential credential) {
+            setCredential(credential);
+        }
+
+        /**
+         * Specifies the credential to be saved. The provided credential must be non-null.
+         *
+         * @see Credential
+         */
+        public Builder setCredential(@NonNull Credential credential) {
+            validate(credential, notNullValue(), IllegalArgumentException.class);
+
+            mCredential = credential;
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to carry with the credential
+         * save request. A null map is treated as an empty map.
+         */
+        @NonNull
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
+            return this;
+        }
+
+        /**
+         * Finalizes the creation of the credential save request.
+         */
+        public CredentialSaveRequest build() {
+            return new CredentialSaveRequest(this);
+        }
+    }
+
+    private static final class CredentialSaveRequestCreator
+            implements Creator<CredentialSaveRequest> {
+        @Override
+        public CredentialSaveRequest createFromParcel(Parcel source) {
+            int length = source.readInt();
+            byte[] encodedRequest = new byte[length];
+            source.readByteArray(encodedRequest);
+
+            try {
+                return CredentialSaveRequest.fromProtoBytes(encodedRequest);
+            } catch (MalformedDataException ex) {
+                throw new IllegalStateException("Unable to read proto from parcel", ex);
+            }
+        }
+
+        @Override
+        public CredentialSaveRequest[] newArray(int size) {
+            return new CredentialSaveRequest[0];
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index c06c8b6..e1ce167 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -1,286 +1,286 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.protocol;
-
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.valid4j.Validation.validate;
-
-import android.content.Intent;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import com.google.protobuf.ByteString;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
-
-/**
- * Result data which is sent in response to a credential save request. Contains a result code,
- * indicating whether the request was successful or not, and an optional set of additional,
- * non-standard result properties.
- *
- * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
- *     OpenYOLO specification: Saving Credential</a>
- */
-public final class CredentialSaveResult {
-
-    /**
-     * Indicates that the provider returned a response that could not be interpreted.
-     */
-    public static final int CODE_UNKNOWN =
-            Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
-
-    /**
-     * Indicates that no provider was available and able to handle the associated request.
-     */
-    public static final int CODE_NO_PROVIDER_AVAILABLE =
-            Protobufs.CredentialSaveResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
-
-    /**
-     * Indicates that the credential request sent to the provider was malformed.
-     */
-    public static final int CODE_BAD_REQUEST =
-            Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
-
-    /**
-     * Indicates that the credential sent to the provider was saved.
-     */
-    public static final int CODE_SAVED =
-            Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
-
-    /**
-     * Indicates the provider refused to save the credential, due to some policy restriction. For
-     * example, a provider may refuse to update an existing credential if it is stored in a shared
-     * keychain. The client SHOULD NOT request to save this credential again.
-     */
-    public static final int CODE_PROVIDER_REFUSED =
-            Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
-
-    /**
-     * Indicates that the user dismissed the request to save the credential, by either pressing the
-     * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
-     * that is not an explicit refusal to delete the credential. The client MAY request to save this
-     * credential again at a later time.
-     */
-    public static final int CODE_USER_CANCELED =
-            Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
-
-    /**
-     * Indicates the user refused the request to save this credential. The client SHOULD NOT request
-     * to save this credential again.
-     */
-    public static final int CODE_USER_REFUSED =
-            Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
-
-    /**
-     * Pre-built save result for an unspecified outcome. Carries no additional properties.
-     */
-    public static final CredentialSaveResult UNKNOWN =
-            new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
-
-    /**
-     * Pre-built save result that indicates that no provider was available and able to handle the
-     * associated request.
-     */
-    public static final CredentialSaveResult NO_PROVIDER_AVAILABLE =
-            new CredentialSaveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
-
-    /**
-     * Pre-built save result that indicates the credential was saved. Carries no additional
-     * properties.
-     */
-    public static final CredentialSaveResult SAVED =
-            new CredentialSaveResult.Builder(CODE_SAVED).build();
-
-    /**
-     * Pre-built save result that indicates the request was malformed. Carries no additional
-     * properties.
-     */
-    public static final CredentialSaveResult BAD_REQUEST =
-            new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
-
-    /**
-     * Indicates that the user dismissed the request to save the credential, by either pressing the
-     * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
-     * that is not an explicit refusal to save the credential. The client MAY request to save this
-     * credential again at a later time.
-     */
-    public static final CredentialSaveResult USER_CANCELED =
-            new CredentialSaveResult.Builder(CODE_USER_CANCELED).build();
-
-    /**
-     * Pre-built save result that indicates the request was refused by the user. Carries no
-     * additional properties.
-     */
-    public static final CredentialSaveResult USER_REFUSED =
-            new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
-
-    /**
-     * Pre-built save result that indicates the request was refused by the provider. Carries no
-     * additional properties.
-     */
-    public static final CredentialSaveResult PROVIDER_REFUSED =
-            new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
-
-    private final int mResultCode;
-
-    @NonNull
-    private Map<String, ByteString> mAdditionalProperties;
-
-    /**
-     * Creates a credential save result from its protocol buffer byte equivalent.
-     * @throws MalformedDataException if the result could not be parsed or validated.
-     */
-    public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
-            throws MalformedDataException {
-        validate(protobufBytes, notNullValue(), MalformedDataException.class);
-
-        try {
-            return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
-        } catch (IOException ex) {
-            throw new MalformedDataException(ex);
-        }
-    }
-
-    /**
-     * Creates a credential save result from its protocol buffer equivalent.
-     * @throws MalformedDataException if the result could not be parsed or validated.
-     */
-    public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
-            throws MalformedDataException {
-        validate(proto, notNullValue(), MalformedDataException.class);
-
-        return new CredentialSaveResult.Builder(proto).build();
-    }
-
-    /**
-     * Creates a protocol buffer representation of the credential save result, for transmission
-     * or storage.
-     */
-    public Protobufs.CredentialSaveResult toProtobuf() {
-        Protobufs.CredentialSaveResult.Builder builder =
-                Protobufs.CredentialSaveResult.newBuilder()
-                        .setResultCodeValue(mResultCode)
-                        .putAllAdditionalProps(mAdditionalProperties);
-
-        return builder.build();
-    }
-
-    /**
-     * Creates an {@link Intent} containing this credential save result, that a provider should
-     * return as its activity result.
-     */
-    public Intent toResultDataIntent() {
-        Intent intent = new Intent();
-        intent.putExtra(
-                ProtocolConstants.EXTRA_SAVE_RESULT,
-                toProtobuf().toByteArray());
-        return intent;
-    }
-
-    private CredentialSaveResult(Builder builder) {
-        mResultCode = builder.mResultCode;
-        mAdditionalProperties = builder.mAdditionalProps;
-    }
-
-    /**
-     * Returns {@code true} if the request was successful.
-     */
-    public boolean isSuccessful() {
-        return CODE_SAVED == mResultCode;
-    }
-
-
-    /**
-     * The result code for the credential save operation.
-     */
-    public int getResultCode() {
-        return mResultCode;
-    }
-
-    /**
-     * The additional, non-standard properties returned by the credential provider, if available.
-     */
-    @NonNull
-    public Map<String, byte[]> getAdditionalProperties() {
-        return CollectionConverter.convertMapValues(
-                mAdditionalProperties,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
-    }
-
-    /**
-     * Creates {@link CredentialSaveResult} instances.
-     */
-    public static final class Builder {
-        private int mResultCode = CODE_UNKNOWN;
-        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
-
-        /**
-         * Starts the process of describing a credential retrieve result given the mandatory status
-         * code.
-         * @throws MalformedDataException if the given protocol buffer was not valid.
-         */
-        private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
-            validate(proto, notNullValue(), MalformedDataException.class);
-
-            try {
-                setResultCode(proto.getResultCodeValue());
-                setAdditionalProperties(
-                        CollectionConverter.convertMapValues(
-                                proto.getAdditionalPropsMap(),
-                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
-            } catch (IllegalArgumentException ex) {
-                throw new MalformedDataException(ex);
-            }
-        }
-
-        /**
-         * Seeds a credential save result from its protocol buffer equivalent.
-         */
-        public Builder(int resultCode) {
-            setResultCode(resultCode);
-        }
-
-        /**
-         * Specifies the result code. It is recommended to use one of the standard values, though
-         * any value may be used.
-         */
-        public Builder setResultCode(int resultCode) {
-            mResultCode = resultCode;
-
-            return this;
-        }
-
-        /**
-         * Specifies the set of additional, non-standard properties to carry with the credential
-         * deletion request. A null map is treated as an empty map.
-         */
-        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
-            mAdditionalProps =
-                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
-
-            return this;
-        }
-
-        /**
-         * Finalizes the creation of the credential save result.
-         */
-        public CredentialSaveResult build() {
-            return new CredentialSaveResult(this);
-        }
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Validation.validate;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * Result data which is sent in response to a credential save request. Contains a result code,
+ * indicating whether the request was successful or not, and an optional set of additional,
+ * non-standard result properties.
+ *
+ * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
+ *     OpenYOLO specification: Saving Credential</a>
+ */
+public final class CredentialSaveResult {
+
+    /**
+     * Indicates that the provider returned a response that could not be interpreted.
+     */
+    public static final int CODE_UNKNOWN =
+            Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
+
+    /**
+     * Indicates that no provider was available and able to handle the associated request.
+     */
+    public static final int CODE_NO_PROVIDER_AVAILABLE =
+            Protobufs.CredentialSaveResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
+
+    /**
+     * Indicates that the credential request sent to the provider was malformed.
+     */
+    public static final int CODE_BAD_REQUEST =
+            Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
+
+    /**
+     * Indicates that the credential sent to the provider was saved.
+     */
+    public static final int CODE_SAVED =
+            Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
+
+    /**
+     * Indicates the provider refused to save the credential, due to some policy restriction. For
+     * example, a provider may refuse to update an existing credential if it is stored in a shared
+     * keychain. The client SHOULD NOT request to save this credential again.
+     */
+    public static final int CODE_PROVIDER_REFUSED =
+            Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
+
+    /**
+     * Indicates that the user dismissed the request to save the credential, by either pressing the
+     * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
+     * that is not an explicit refusal to delete the credential. The client MAY request to save this
+     * credential again at a later time.
+     */
+    public static final int CODE_USER_CANCELED =
+            Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
+
+    /**
+     * Indicates the user refused the request to save this credential. The client SHOULD NOT request
+     * to save this credential again.
+     */
+    public static final int CODE_USER_REFUSED =
+            Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
+
+    /**
+     * Pre-built save result for an unspecified outcome. Carries no additional properties.
+     */
+    public static final CredentialSaveResult UNKNOWN =
+            new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
+
+    /**
+     * Pre-built save result that indicates that no provider was available and able to handle the
+     * associated request.
+     */
+    public static final CredentialSaveResult NO_PROVIDER_AVAILABLE =
+            new CredentialSaveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
+
+    /**
+     * Pre-built save result that indicates the credential was saved. Carries no additional
+     * properties.
+     */
+    public static final CredentialSaveResult SAVED =
+            new CredentialSaveResult.Builder(CODE_SAVED).build();
+
+    /**
+     * Pre-built save result that indicates the request was malformed. Carries no additional
+     * properties.
+     */
+    public static final CredentialSaveResult BAD_REQUEST =
+            new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
+
+    /**
+     * Indicates that the user dismissed the request to save the credential, by either pressing the
+     * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
+     * that is not an explicit refusal to save the credential. The client MAY request to save this
+     * credential again at a later time.
+     */
+    public static final CredentialSaveResult USER_CANCELED =
+            new CredentialSaveResult.Builder(CODE_USER_CANCELED).build();
+
+    /**
+     * Pre-built save result that indicates the request was refused by the user. Carries no
+     * additional properties.
+     */
+    public static final CredentialSaveResult USER_REFUSED =
+            new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
+
+    /**
+     * Pre-built save result that indicates the request was refused by the provider. Carries no
+     * additional properties.
+     */
+    public static final CredentialSaveResult PROVIDER_REFUSED =
+            new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
+
+    private final int mResultCode;
+
+    @NonNull
+    private Map<String, ByteString> mAdditionalProperties;
+
+    /**
+     * Creates a credential save result from its protocol buffer byte equivalent.
+     * @throws MalformedDataException if the result could not be parsed or validated.
+     */
+    public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
+            throws MalformedDataException {
+        validate(protobufBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
+    }
+
+    /**
+     * Creates a credential save result from its protocol buffer equivalent.
+     * @throws MalformedDataException if the result could not be parsed or validated.
+     */
+    public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
+            throws MalformedDataException {
+        validate(proto, notNullValue(), MalformedDataException.class);
+
+        return new CredentialSaveResult.Builder(proto).build();
+    }
+
+    /**
+     * Creates a protocol buffer representation of the credential save result, for transmission
+     * or storage.
+     */
+    public Protobufs.CredentialSaveResult toProtobuf() {
+        Protobufs.CredentialSaveResult.Builder builder =
+                Protobufs.CredentialSaveResult.newBuilder()
+                        .setResultCodeValue(mResultCode)
+                        .putAllAdditionalProps(mAdditionalProperties);
+
+        return builder.build();
+    }
+
+    /**
+     * Creates an {@link Intent} containing this credential save result, that a provider should
+     * return as its activity result.
+     */
+    public Intent toResultDataIntent() {
+        Intent intent = new Intent();
+        intent.putExtra(
+                ProtocolConstants.EXTRA_SAVE_RESULT,
+                toProtobuf().toByteArray());
+        return intent;
+    }
+
+    private CredentialSaveResult(Builder builder) {
+        mResultCode = builder.mResultCode;
+        mAdditionalProperties = builder.mAdditionalProps;
+    }
+
+    /**
+     * Returns {@code true} if the request was successful.
+     */
+    public boolean isSuccessful() {
+        return CODE_SAVED == mResultCode;
+    }
+
+
+    /**
+     * The result code for the credential save operation.
+     */
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    /**
+     * The additional, non-standard properties returned by the credential provider, if available.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProperties,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Creates {@link CredentialSaveResult} instances.
+     */
+    public static final class Builder {
+        private int mResultCode = CODE_UNKNOWN;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Starts the process of describing a credential retrieve result given the mandatory status
+         * code.
+         * @throws MalformedDataException if the given protocol buffer was not valid.
+         */
+        private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
+            validate(proto, notNullValue(), MalformedDataException.class);
+
+            try {
+                setResultCode(proto.getResultCodeValue());
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                proto.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
+        }
+
+        /**
+         * Seeds a credential save result from its protocol buffer equivalent.
+         */
+        public Builder(int resultCode) {
+            setResultCode(resultCode);
+        }
+
+        /**
+         * Specifies the result code. It is recommended to use one of the standard values, though
+         * any value may be used.
+         */
+        public Builder setResultCode(int resultCode) {
+            mResultCode = resultCode;
+
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to carry with the credential
+         * deletion request. A null map is treated as an empty map.
+         */
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+
+            return this;
+        }
+
+        /**
+         * Finalizes the creation of the credential save result.
+         */
+        public CredentialSaveResult build() {
+            return new CredentialSaveResult(this);
+        }
+    }
+}
diff --git a/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java b/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
index af1b9f5..43476fa 100644
--- a/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
@@ -1,60 +1,60 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.testapp;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-import org.openyolo.api.CredentialClient;
-
-/**
- * Test page for actions that do not cleanly fit into another category.
- */
-public class OtherTestPageFragment extends TestPageFragment {
-
-    private CredentialClient mApi;
-
-    @Override
-    public String getPageTitle() {
-        return "Other";
-    }
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        mApi = CredentialClient.getInstance(getContext());
-    }
-
-    @Override
-    public View onCreateView(
-            LayoutInflater inflater,
-            ViewGroup container,
-            Bundle savedInstanceState) {
-        View view = inflater.inflate(R.layout.other_test_layout, container, false);
-        ButterKnife.bind(this, view);
-
-        return view;
-    }
-
-    @OnClick(R.id.disable_auto_sign_in_button)
-    void onDisableAutoSignIn() {
-        mApi.disableAutoSignIn();
-    }
-}
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import org.openyolo.api.CredentialClient;
+
+/**
+ * Test page for actions that do not cleanly fit into another category.
+ */
+public class OtherTestPageFragment extends TestPageFragment {
+
+    private CredentialClient mApi;
+
+    @Override
+    public String getPageTitle() {
+        return "Other";
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mApi = CredentialClient.getInstance(getContext());
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.other_test_layout, container, false);
+        ButterKnife.bind(this, view);
+
+        return view;
+    }
+
+    @OnClick(R.id.disable_auto_sign_in_button)
+    void onDisableAutoSignIn() {
+        mApi.disableAutoSignIn();
+    }
+}

commit a51fdaa70c02a4ae2437d991da5b7556e3db0597
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 4 13:20:30 2017 -0700

    Minor tweaks for AdditionalPropertiesHelper (#117)
    
    - Ensure that it cannot be constructed
    - Tests for the uncovered branch cases dealing with nulls

diff --git a/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java b/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java
index 93d1de5..6e28a24 100644
--- a/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java
+++ b/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java
@@ -20,34 +20,38 @@ import java.nio.charset.Charset;
 /**
  * Utility methods for reading and writing additional properties.
  */
 public final class AdditionalPropertiesHelper {
 
     private static final Charset UTF_8 = Charset.forName("UTF-8");
 
     /**
      * Encodes the provided string for use as an additional property, using UTF-8 encoding.
      * If the provided string is `null`, then `null will be returned.
      */
     @Nullable
     public static byte[] encodeStringValue(@Nullable String value) {
         if (value == null) {
             return null;
         }
 
         return value.getBytes(UTF_8);
     }
 
     /**
      * Decodes the provided byte array from an additional property value to a String. This
      * assumes that the byte array was originally produced by {@link #encodeStringValue(String)}
      * or equivalent code. If the provided byte array is `null`, then `null` will be returned.
      */
     @Nullable
     public static String decodeStringValue(@Nullable byte[] value) {
         if (value == null) {
             return null;
         }
 
         return new String(value, UTF_8);
     }
+
+    private AdditionalPropertiesHelper() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesHelperTest.java b/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesHelperTest.java
new file mode 100644
index 0000000..c9bb06a
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/AdditionalPropertiesHelperTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Unit tests for {@link AuthenticationDomain}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class AdditionalPropertiesHelperTest {
+
+    @Test
+    public void encodeStringValue_withNull() {
+        assertThat(AdditionalPropertiesHelper.encodeStringValue(null)).isNull();
+    }
+
+    @Test
+    public void decodeStringValue_withNull() {
+        assertThat(AdditionalPropertiesHelper.decodeStringValue(null)).isNull();
+    }
+
+    @Test
+    public void encodeAndDecode() {
+        byte[] encoded = AdditionalPropertiesHelper.encodeStringValue("testing");
+        assertThat(AdditionalPropertiesHelper.decodeStringValue(encoded)).isEqualTo("testing");
+    }
+}

commit ddd8d43247195354dabd393cb26ffc3fae7ffef3
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Wed Oct 4 11:24:41 2017 -0700

    Updated the README to reflect the beta production ready status. (#108)
    
    Fixed example gradle dependency in API README.

diff --git a/README.md b/README.md
index ac97ddc..c904865 100644
--- a/README.md
+++ b/README.md
@@ -13,23 +13,48 @@ and the standard API and Service Provider Interface (SPI).
 
-OpenYOLO is inspired by, and ultimately intended to replace, Google's
-[Smart Lock for Passwords][yolo] API, which is
-internally known as YOLO (You Only Login Once).
+<div align="center">
+  <img src="https://user-images.githubusercontent.com/445775/30930082-60d21ace-a375-11e7-90cf-cc75fe5747fd.gif"/>
+  <p><em>Example of auto sign-in</em></p>
+</div>
 
-## OpenYOLO is *not* production ready
+## Project Status
 
-OpenYOLO is currently in the *experimental* stage; both the specification and
-reference implementation are *unstable*. We do not recommend that it be used
-in production Android apps. At such a time that OpenYOLO is considered stable
-and ready for production use, an official announcement shall be made and both
-the specification and reference implementation will be promoted to v1.0.0.
+OpenYOLO has reached beta production ready stage and can be integrated into production applications.
+The following credential providers include production implementations of OpenYOLO:
 
-## OpenYOLO Specification
+| <img src="https://user-images.githubusercontent.com/445775/31100963-59c51db2-a780-11e7-87f4-e7ab2750b92a.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/31101083-0cc4fd92-a781-11e7-95fe-9f9e9fadae70.png" width="200" height="200" /> | <img src="https://user-images.githubusercontent.com/445775/31101050-eeb9966e-a780-11e7-96ae-614f765f3f12.png" width="200" height="200" /> |
+|:---:|:---:|:---:|
+| 1Password | Dashlane | Google Smart Lock |
 
-The OpenYOLO for Android specification can be found 
-[here](https://spec.openyolo.org/openyolo-android-spec.html). This is
-currently under review by the 
-[Account Chooser and OpenYOLO Working Group](http://openid.net/wg/ac/),
-with the intention for it to become an implementor's draft by Q3 2017,
-and reach full standardization by Q4 2017.
+The OpenYOLO for Android specification can be found [here](http://openid.net/specs/openyolo-android-03.html).
+This is currently under review as an implementor's draft by the
+[Account Chooser and OpenYOLO Working Group](http://openid.net/wg/ac/), with the goal for it to
+reach final specification status in the near future.
+
+## Getting Started as a Client
+
+[![Download](https://api.bintray.com/packages/openid/net.openid/openyolo-api/images/download.svg) ](https://bintray.com/openid/net.openid/openyolo-api/_latestVersion)
+
+The client library for the OpenYOLO for Android protocol lives in the ```api``` directory. It allows
+you to easily manipulate credentials for your application by interacting with the credential
+provider of the user's choice. This allows you to:
+
+1. Automatically sign users into your app using saved credentials.
+1. Rapidly on-board new users by bootstrapping off of existing identities.
+1. Prompt users after sign-in/sign up to save their credentials for future automatic sign in.
+
+<div align="center">
+  <b><a href="api">Getting Started Guide</a></b> | <b><a href="demoapps">Sample Implementation</a></b>
+</div>
+
+
+## Getting Started as a Credential Provider
+
+[ ![Download](https://api.bintray.com/packages/openid/net.openid/openyolo-spi/images/download.svg) ](https://bintray.com/openid/net.openid/openyolo-spi/_latestVersion)
+
+A getting started guide has not been written for credential providers. In its absence the protocol's
+specification as well as several sample implementations are good alternatives.
+
+<div align="center">
+  <b><a href="demoproviders">Sample Implementations</a></b> | <b><a href="testapp">Test App</a></b> | <b><a href="http://openid.net/specs/openyolo-android-03.html">Specification</a></b>
+</div>
 
-[yolo]: https://developers.google.com/identity/smartlock-passwords/android/
diff --git a/api/README.md b/api/README.md
index 091de50..f3ba82f 100644
--- a/api/README.md
+++ b/api/README.md
@@ -23,10 +23,10 @@ version. For example, if your project uses Gradle:
 ```groovy
 dependencies {
     // ...
-    compile 'com.openyolo:openyolo-api:x.y.z'
+    compile 'org.openyolo:openyolo-api:x.y.z'
 }
 ```
 
 ## Terminology
 
  - [Authentication Method](http://openid.net/specs/openyolo-android-ID1.html#authentication-methods):

commit c26f3bbef6a2bc69002acacdf156d42956bd5d1e
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 4 10:37:15 2017 -0700

    Added Additional tests for HintRetrieveRequest (#112)

diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index ee705a6..f1c5c59 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -19,2 +19,4 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 import android.os.Parcel;
+import com.google.common.collect.ImmutableSet;
+import java.util.Collections;
 import java.util.HashMap;
@@ -31,236 +33,302 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
+    @Test
+    public void testFromAuthMethods() {
+        HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
+                AuthenticationMethods.EMAIL,
+                AuthenticationMethods.FACEBOOK);
+
+        assertThat(request.getAuthenticationMethods()).containsExactly(
+                AuthenticationMethods.EMAIL,
+                AuthenticationMethods.FACEBOOK);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testFromAuthMethods_noneProvided() {
+        HintRetrieveRequest.fromAuthMethods();
+    }
+
+    @Test
+    public void testFromAuthMethods_withSet() {
+        HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(
+                ImmutableSet.of(AuthenticationMethods.EMAIL, AuthenticationMethods.FACEBOOK));
+
+        assertThat(request.getAuthenticationMethods()).containsExactly(
+                AuthenticationMethods.EMAIL,
+                AuthenticationMethods.FACEBOOK);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testFromAuthMethods_emptySet() {
+        HintRetrieveRequest.fromAuthMethods(Collections.emptySet());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testBuilder_emptyAuthMethodsSet() {
+        new HintRetrieveRequest.Builder(Collections.emptySet());
+    }
+
+    @Test
+    public void testBuilder_setTokenProviders() {
+        HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
+                .setTokenProviders(ValidTokenProviderMap.make())
+                .build();
+
+        ValidTokenProviderMap.assertEquals(request.getTokenProviders());
+    }
+
+    @Test
+    public void testBuilder_setTokenProviders_nullMap() {
+        HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
+                .setTokenProviders(null)
+                .build();
+
+        assertThat(request.getTokenProviders()).isEmpty();
+    }
+
+    @Test
+    public void testBuilder_addTokenProvider_noInfo() {
+        String tokenProvider = "https://my.token.provider";
+        HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
+                .addTokenProvider(tokenProvider)
+                .build();
+
+        assertThat(request.getTokenProviders()).containsKey(tokenProvider);
+        assertThat(request.getTokenProviders().get(tokenProvider))
+                .isEqualTo(TokenRequestInfo.DEFAULT);
+    }
+
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setPasswordSpecification(originalSpec)
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL);
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
             ValidTokenProviderMap.assertEquals(read.getTokenProviders());
             ValidAdditionalProperties.assertEquals(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Set<AuthenticationMethod>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file

commit b3565c65585c342d9992300ee96e173a87c0c6ec
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed Oct 4 10:35:50 2017 -0700

    Additional properties utility methods for CredentialRetrieveResult (#110)
    
    Part of implementation for #99.

diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index ae03bf3..856382b 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -60,385 +60,385 @@ import org.robolectric.shadows.ShadowActivity;
 /**
  * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
 
     private static final HintRetrieveRequest EMAIL_HINT_REQUEST =
             HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL);
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     @Mock
     private AppSettings mockDeviceState;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(mockDeviceState).build();
         credentialClient = new CredentialClient(mockContext, options);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void getInstance_returnsNonNull() throws Exception {
         CredentialClient test = CredentialClient.getInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getHintRetrieveIntent_noAvailableProviders_finishesWithNoAvailableProviders() {
         Intent intent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         ShadowActivity activity = startFinishWithResultActivity(intent);
 
         assertThat(activity.isFinishing()).isTrue();
         assertThat(activity.getResultCode())
                 .isEqualTo(HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE);
 
         HintRetrieveResult result =
                 credentialClient.getHintRetrieveResult(activity.getResultIntent());
         assertThat(result.getResultCode())
                 .isEqualTo(HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(null /* intent*/);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
         final Intent intent = new Intent();
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
         final Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_validResult_returnsResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(
                         CredentialSaveResult.SAVED.toResultDataIntent());
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialRetrieveResult_withErrorResult_returnsErrorResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
         assertThat(result.getCredential()).isNull();
-        assertThat(result.getAdditionalProps()).isEmpty();
+        assertThat(result.getAdditionalProperties()).isEmpty();
 
         verifyNoMoreInteractions(mockDeviceState);
     }
 
     @Test
     public void getCredentialRetrieveResult_withSuccessfulResult_returnsSuccessfulResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
-        assertThat(result.getAdditionalProps()).isEmpty();
+        assertThat(result.getAdditionalProperties()).isEmpty();
 
         verify(mockDeviceState).setIsAutoSignInDisabled(eq(false));
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
-        assertThat(result.getAdditionalProps()).isEmpty();
+        assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ShadowActivity startFinishWithResultActivity(Intent intent) {
         return Shadows.shadowOf(
                 Robolectric.buildActivity(FinishWithResultActivity.class, intent).create().get());
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 5397a57..d3215c1 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -33,288 +33,338 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE = ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that a credential was successfully chosen and has been returned as part of this
      * response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates that the provider returned a response that could not be
      * interpreted.
      */
     public static final CredentialRetrieveResult UNKNOWN =
             new CredentialRetrieveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built result that indicates that no provider was available and able to handle the
      * associated request.
      */
     public static final CredentialRetrieveResult NO_PROVIDER_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_CREDENTIAL_SELECTED == mResultCode;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
-    public Map<String, byte[]> getAdditionalProps() {
+    public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
+    /**
+     * Returns the additional, non-standard property identified by the specified key. If this
+     * additional property does not exist, then `null` is returned.
+     */
+    @Nullable
+    public byte[] getAdditionalProperty(String key) {
+        ByteString value = mAdditionalProps.get(key);
+        if (value == null) {
+            return null;
+        }
+
+        return value.toByteArray();
+    }
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key, where the
+     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
+     * then `null` is returned.
+     */
+    @Nullable
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesHelper.decodeStringValue(
+                getAdditionalProperty(key));
+    }
+
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          * @throws MalformedDataException if the given protocol buffer was invalid.
          */
         private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setCredentialFromProto(proto.getCredential());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
                 throws MalformedDataException {
             if (null == credential
                     || Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = null;
             } else {
                 mCredential = Credential.fromProtobuf(credential);
             }
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
+        /**
+         * Specifies an additional, non-standard property to include in the result.
+         */
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            ByteString immutableValue;
+            if (value == null) {
+                immutableValue = null;
+            } else {
+                immutableValue = ByteString.copyFrom(value);
+            }
+
+            mAdditionalProps.put(key, immutableValue);
+            return this;
+        }
+
+        /**
+         * Specifies an additional, non-standard property with a string value to include in the
+         * result.
+         */
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+        }
+
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
index ce42941..116f27a 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
@@ -17,4 +17,10 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 
 import android.content.Intent;
+import com.google.common.collect.ImmutableMap;
 import java.util.Map;
@@ -27,106 +33,190 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link CredentialRetrieveResult}. */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveResultTest {
 
   private static final class ValidCredential {
     public static final String ID = "email@gogo.com";
     public static final AuthenticationMethod AUTHENTICATION_METHOD = AuthenticationMethods.EMAIL;
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTHENTICATION_DOMAIN =
         new AuthenticationDomain(AUTH_DOMAIN_STR);
     public static final Credential INSTANCE =
         new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN).build();
 
     private static void assertEqualTo(Credential credential) {
       assertThat(credential.getIdentifier()).isEqualTo(ID);
     }
 
     private static void assertEqualTo(Protobufs.Credential credential) {
       assertThat(credential.getId()).isEqualTo(ID);
     }
   }
 
   private static final class ValidCredentialSelectedResult {
     public static int RESULT_CODE = CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED;
     public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
     public static final CredentialRetrieveResult INSTANCE =
         new CredentialRetrieveResult.Builder(RESULT_CODE)
             .setCredential(ValidCredential.INSTANCE)
             .setAdditionalProperties(ADDITIONAL_PROPERTIES)
             .build();
 
     private static void assertEqualTo(Protobufs.CredentialRetrieveResult result) {
       assertThat(result.getResultCodeValue()).isEqualTo(RESULT_CODE);
       ValidCredential.assertEqualTo(result.getCredential());
       ValidProperties.assertEqualTo(result.getAdditionalPropsMap(), false /* dummy */);
     }
 
     private static void assertEqualTo(CredentialRetrieveResult result) {
       assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
       ValidCredential.assertEqualTo(result.getCredential());
-      ValidProperties.assertEqualTo(result.getAdditionalProps());
+      ValidProperties.assertEqualTo(result.getAdditionalProperties());
     }
   }
 
   private static final class ValidBadRequestResult {
     public static int RESULT_CODE = CredentialRetrieveResult.CODE_BAD_REQUEST;
     public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
     public static final CredentialRetrieveResult INSTANCE =
         new CredentialRetrieveResult.Builder(RESULT_CODE)
             .setAdditionalProperties(ADDITIONAL_PROPERTIES)
             .build();
 
     private static void assertEqualTo(Protobufs.CredentialRetrieveResult result) {
       assertThat(result.getResultCodeValue()).isEqualTo(RESULT_CODE);
       assertThat(result.getCredential()).isEqualTo(Protobufs.Credential.getDefaultInstance());
       ValidProperties.assertEqualTo(result.getAdditionalPropsMap(), false /* dummy */);
     }
 
     private static void assertEqualTo(CredentialRetrieveResult result) {
       assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
       assertThat(result.getCredential()).isNull();
-      ValidProperties.assertEqualTo(result.getAdditionalProps());
+      ValidProperties.assertEqualTo(result.getAdditionalProperties());
     }
   }
 
+  @Test
+  public void testBuilder_setAdditionalProperty() {
+    CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
+            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+            .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+            .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+            .build();
+
+    Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+    assertThat(additionalProps.size()).isEqualTo(2);
+    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+    assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+            .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
+    assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
+            .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+  }
+
+  @Test
+  public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
+    CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
+            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+            .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+            .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+            .build();
+
+    Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+    assertThat(additionalProps.size()).isEqualTo(1);
+    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+    assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+            .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+  }
+
+  @Test
+  public void testBuilder_setAdditionalPropertyAsString() {
+    CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
+            CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+            .setAdditionalPropertyAsString(
+                    ADDITIONAL_PROP_TEST_KEY,
+                    ADDITIONAL_PROP_STRING_VALUE)
+            .build();
+
+    Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+    assertThat(additionalProps.size()).isEqualTo(1);
+    assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+    assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+            .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
+                    ADDITIONAL_PROP_STRING_VALUE));
+  }
+
+    @Test
+    public void testGetAdditionalProperty() {
+        CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
+                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
+                .build();
+
+        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testGetAdditionalProperty_withMissingKey() {
+        CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
+                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+                .build();
+        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
+    }
+
+    @Test
+    public void testGetAdditionalPropertyAsString() {
+        CredentialRetrieveResult cdr = new CredentialRetrieveResult.Builder(
+                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
+                .build();
+
+        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
+    }
+
   @Test
   public void fromProtobufBytes_withValidCredentialSelectedResult_returnsEquivalent() throws Exception {
     byte[] encodedBytes = ValidCredentialSelectedResult.INSTANCE.toProtobuf().toByteArray();
 
     CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedBytes);
 
     ValidCredentialSelectedResult.assertEqualTo(result);
   }
 
   @Test
   public void fromProtobufBytes_withValidBadRequestResult_returnsEquivalent() throws Exception {
     byte[] encodedBytes = ValidBadRequestResult.INSTANCE.toProtobuf().toByteArray();
 
     CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedBytes);
 
     ValidBadRequestResult.assertEqualTo(result);
   }
 
   @Test
   public void toProtobuf_withValidCredentialSelectedResult_returnsEquivalent() throws Exception {
     ValidCredentialSelectedResult.assertEqualTo(
         ValidCredentialSelectedResult.INSTANCE.toProtobuf());
   }
 
   @Test
   public void toProtobuf_withValidBadRequestResult_returnsEquivalent() throws Exception {
     ValidBadRequestResult.assertEqualTo(ValidBadRequestResult.INSTANCE.toProtobuf());
   }
 
   @Test
   public void toResultDataIntent_withValidRequest_encodesIntoIntent() throws Exception {
     Intent intent = ValidBadRequestResult.INSTANCE.toResultDataIntent();
 
     byte[] encodedResult = intent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT);
     CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedResult);
     ValidBadRequestResult.assertEqualTo(result);
   }
 }

commit 60870b0454cf546455a6a62cd2be9e23b0785c66
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Tue Oct 3 16:06:38 2017 -0700

    Use caching recommendations from Travis docs (#116)
    
    See: https://docs.travis-ci.com/user/languages/java/#Caching

diff --git a/.travis.yml b/.travis.yml
index 0a5bf55..f2b03da 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,5 +10,10 @@ script:
   - ./gradlew check jacoco assemble
   - bash <(curl -s https://codecov.io/bash)
+before_cache:
+  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
+  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
 cache:
   directories:
-    - $HOME/.m2
\ No newline at end of file
+    - $HOME/.gradle/caches/
+    - $HOME/.gradle/wrapper/
+    - $HOME/.m2

commit ccd25a1561be94b3299a2aa2073432d0aa216fbf
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Tue Oct 3 15:15:28 2017 -0700

    Fixed bug where dependencies were not present in pom files. (#114)

diff --git a/build.gradle b/build.gradle
index a561e62..64ae061 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,15 +1,15 @@
 buildscript {
     repositories {
         jcenter()
         maven { url 'https://maven.google.com' }
     }
 
     dependencies {
         classpath 'com.android.tools.build:gradle:3.0.0-beta2'
-        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
         classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }

commit 0b790c51f8f7254b6013fcf46f5e9e0f2cb822a7
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Tue Oct 3 15:07:09 2017 -0700

    Update contribution instructions (#115)
    
    This updates the instructions to reflect [the discussion on the mailing list](https://groups.google.com/forum/#!topic/oidf-account-chooser-list/iM_d86U3TWU).

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e062a84..05529fd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,6 +8,6 @@ discuss your plans over
 [GitHub Issues](https://github.com/openid/OpenYOLO-Android/issues) and the
 [mailing list](http://groups.google.com/group/oidf-account-chooser-list), and
 send in pull requests!
 
-# Signing the Agreements
+# Required legal agreements
 
@@ -16,11 +16,11 @@ that cover your contributions.  Pull requests from users who have not signed
 these agreements will not be merged.
 
-## Execute the Contributor License Agreement (CLA)
+## Execute the contributor license agreement (CLA)
 
 1. Visit http://openid.net/contribution-license-agreement/
 2. Tap *Execute OpenID Foundation Contribution License Agreement* for the
    version relevant to you (Individual or Corporate).
 3. Follow the instructions to sign the agreement.
 
-## Execute the Working Group Contribution Agreement
+## Execute the working group contribution agreement
 
@@ -30,12 +30,12 @@ towards the OpenID Connect spec itself (e.g. in comments, bug reports, feature
 requests).
 
 1. Visit http://openid.net/intellectual-property/
 2. Tap *Execute Contributor Agreement By Electronic Signature* in the box
    marked *Resources*.
 3. Follow the instructions to sign the document, state 'Account Chooser &
    OpenYOLO' as the Initial Working Group.
 
-# Making a Pull Request
+# Making a pull request
 
-## Before you Start
+## Before you start
 
@@ -45,14 +45,110 @@ You can file an [Issue](https://github.com/openid/OpenYOLO-Android/issues)
 discussing your proposal, or email the
-[list](http://groups.google.com/group/oidf-account-chooser-list).
+[list][oidf-ac-list]. Smaller bug
+fixes and tests are fine to submit without prior discussion.
 
-## Coding Standards
+## Code standards & conditions for PR acceptance
 
 The OpenYOLO Android library follows the
-[Google Coding Style](https://google.github.io/styleguide/javaguide.html) for
-the Java language. Please review your own code for adherence to the standard
-and make sure to run the `check` gradle target.
-
-## Pull Request Reviews
-
-All pull requests, even by members who have repository write access need to be
-reviewed and marked as "LGTM" before they will be merged.
\ No newline at end of file
+[AOSP Java Code Style](https://source.android.com/source/code-style). This code
+style is automatically enforced as part of the build, when you run the `check`
+task:
+
+```
+./gradlew check
+```
+Pull requests are expected to at least meet the following criteria:
+
+- The build of the `check` task must succeed. If it does not, reviewers will
+  simply reply to the PR with "Please fix the build errors", and review no
+  further until this criteria is met.
+
+- The initial submission should consist of a single commit. Review comments
+  should be addressed through additional commits on the same branch. Avoid
+  rebasing or history rewriting in your PR where possible, to preserve the
+  review history. Intermediary commits will all be discarded when the PR 
+  is accepted, as the reviewer will "squash and merge" your PR once ready.
+  
+- It is the submitters responsibility to ensure that a PR can be cleanly
+  merged into the master branch.
+
+- All code submitted must have at least 60% coverage for the affected lines.
+  Reviewers may request higher coverage, or additional tests generally, if 
+  the changes made warrant this. Generally, aim for a net increase in code
+  coverage for the project with each PR.
+  
+- Code submitted must not drop the overall coverage of the project below 80%.
+  If the code coverage is already below 80%, then contributions must increase
+  the net coverage to be accepted.
+  
+- Code changes that have implications for the specification must have an 
+  associated thread of discussion here on [list][oidf-ac-list], and consensus 
+  must have been reached that the change is worthwhile. Preferably, a separate
+  pull request should already have been merged into to the 
+  [OpenYOLO-Spec repository][spec-repo] before a code change is submitted.
+  
+- Code changes that affect the API must also be demonstrated as part of the 
+  test and sample applications.
+
+- Code changes that affect the SPI must also be demonstrated as part of the 
+  test and demo providers.
+
+- Complex changes _should_ be broken into multiple smaller pull requests for 
+  review, and these should not be directly submitted to the master branch. 
+  Instead, they must be submitted to a feature branch until the complete 
+  set of changes is made, and then merged into master upon agreement that
+  the work is complete.
+
+- As a general guideline, pull requests should not contain more than a 1000
+  line delta. Reviewers may still agree to review PRs that are larger than
+  this at their discretion, or they can request that the PR be split into
+  smaller changes for more effective review.
+
+## Responsibilities of reviewers
+
+Reviewers (members of the 
+@openid/openyolo-android-maintainers team) are expected
+to adhere to the following guidelines:
+
+- New pull requests should be allocated a reviewer within one business day of
+  initial submission.
+
+- Initial review comments on a PR should be supplied within two business days
+  of a reviewer being assigned.
+
+- Reviewers should not review code that is submitted by members of their own
+  organization, unless there is no reasonable alternative.
+
+- Reviewers must squash all PRs into a single commit on submission (use the
+  "squash and merge" option when accepting the pull request).
+
+- All comments and discussion should occur via issues, in reviews, or on the
+  [mailing list][oidf-ac-list]. Avoid direct communication outside of these, 
+  or at least summarize such direct communication in one of the official
+  avenues, in order to ensure everyone has a chance to understand the decision
+  making process.
+
+# Nonclamenture
+
+The following acronyms and terms will be common in reviews:
+
+- Fix in follow-up: a requested change from a reviewer (or a request from a
+  submitter) that can be fixed in a follow-up pull request. If such a change
+  will not be fixed in the current PR, an issue should be opened to track its
+  completion. Attempts to use such requests to back out of writing tests or
+  finishing features is generally frowned upon.
+
+- LGTM: Looks Good To Me. This is used as an indication that a reviewer is
+  overall satisfied with the change; this may come with some caveats, such as
+  comments that must be addressed before the change can be merged.
+
+- Nit: a minor issue with a pull request that _should_ be resolved as part of
+  the current review, though the reviewer is likely to accept rebuttals to
+  suggestions presented in this form, or suggestions to "fix in follow-up".
+
+- PTAL: Please Take Another Look. If you address review comments with a new
+  change, it is helpful to include this as a stand-alone comment on the PR to
+  indicate to the reviewer that you have finished addressing their comments
+  and the PR is ready for re-review.
+
+[oidf-ac-list]: http://groups.google.com/group/oidf-account-chooser-list
+[spec-repo]: https://github.com/openid/OpenYOLO-Spec

commit 1a608a1b98c8fee48c28832361908e70517db971
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 15:25:36 2017 -0700

    Additional properties utility methods for CredentialRetrieveRequest
    
    Part of implementation for #99.

diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index a055ffb..ca423bb 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -18,3 +18,2 @@ import static java.util.Collections.EMPTY_SET;
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.hasItem;
@@ -24,3 +23,2 @@ import static org.hamcrest.CoreMatchers.nullValue;
 import static org.openyolo.protocol.internal.CustomMatchers.isHttpsUriStr;
-import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
 import static org.valid4j.Validation.validate;
@@ -34,2 +32,3 @@ import android.support.annotation.VisibleForTesting;
 
+import com.google.protobuf.ByteString;
 import java.io.IOException;
@@ -41,2 +40,3 @@ import java.util.Set;
 
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
 import org.openyolo.protocol.internal.AuthenticationMethodConverters;
@@ -49,363 +49,403 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
 public class CredentialRetrieveRequest implements Parcelable {
 
     @VisibleForTesting
     static final Boolean DEFAULT_REQUIRE_USER_MEDIATION_VALUE = false;
 
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest fromAuthMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest fromAuthMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
             @NonNull Protobufs.CredentialRetrieveRequest proto) throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
      * @throws MalformedDataException if the intent does not contain a retrieve request, or the
      *     contained request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
             throws MalformedDataException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
             throw new MalformedDataException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
-    private final Map<String, byte[]> mAdditionalProps;
+    private final Map<String, ByteString> mAdditionalProps;
 
     @NonNull
     private final boolean mRequireUserMediation;
 
     private CredentialRetrieveRequest(Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
-        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalParams);
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
         mRequireUserMediation = builder.mRequireUserMediation;
     }
 
     /**
      * The set of authentication methods that the requester supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The set of token providers that the requester supports. These are used by the
      * credential provider and the OpenYOLO client library to attempt to acquire a "proof of access"
      * ID token for any returned credential.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * Specifies if the provider MUST have the user interact before a successful response is
      * returned.
      */
     @NonNull
     public boolean getRequireUserMediation() {
         return mRequireUserMediation;
     }
 
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return mAdditionalProps;
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key. If this
+     * additional property does not exist, then `null` is returned.
+     */
+    @Nullable
+    public byte[] getAdditionalProperty(String key) {
+        ByteString value = mAdditionalProps.get(key);
+        if (value == null) {
+            return null;
+        }
+
+        return value.toByteArray();
+    }
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key, where the
+     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
+     * then `null` is returned.
+     */
+    @Nullable
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesHelper.decodeStringValue(
+                getAdditionalProperty(key));
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
-                .putAllAdditionalProps(
-                        CollectionConverter.convertMapValues(
-                                mAdditionalProps,
-                                ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
+                .putAllAdditionalProps(mAdditionalProps)
                 .setRequireUserMediation(mRequireUserMediation)
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
-        private Map<String, byte[]> mAdditionalParams = new HashMap<>();
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
         private boolean mRequireUserMediation = DEFAULT_REQUIRE_USER_MEDIATION_VALUE;
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided credential retrieve request.
          */
         public Builder(CredentialRetrieveRequest request) {
             mAuthMethods = request.mAuthMethods;
             mTokenProviders = request.mTokenProviders;
-            mAdditionalParams = request.mAdditionalProps;
+            mAdditionalProps = request.mAdditionalProps;
             mRequireUserMediation = request.mRequireUserMediation;
         }
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          * @throws MalformedDataException if the given protocol buffer is not valid.
          */
         private Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
 
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
 
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
 
                 setRequireUserMediation(requestProto.getRequireUserMediation());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies if the provider MUST require user interaction before returning a successful
          * response.
          */
         public Builder setRequireUserMediation(boolean value) {
             mRequireUserMediation = value;
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
 
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
-                @NonNull Map<String, byte[]> additionalParams) {
-            validate(additionalParams, notNullValue(), IllegalArgumentException.class);
-            validate(
-                    additionalParams.keySet(),
-                    everyItem(notNullOrEmptyString()),
-                    IllegalArgumentException.class);
-            validate(
-                    additionalParams.values(),
-                    everyItem(notNullValue()),
-                    IllegalArgumentException.class);
-
-            mAdditionalParams = additionalParams;
+                @NonNull Map<String, byte[]> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+            return this;
+        }
+
+        /**
+         * Specifies an additional, non-standard property to include in the credential.
+         */
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            ByteString immutableValue;
+            if (value == null) {
+                immutableValue = null;
+            } else {
+                immutableValue = ByteString.copyFrom(value);
+            }
+
+            mAdditionalProps.put(key, immutableValue);
             return this;
         }
 
+        /**
+         * Specifies an additional, non-standard property with a string value to include in the
+         * credential.
+         */
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+        }
+
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public CredentialRetrieveRequest build() {
             return new CredentialRetrieveRequest(this);
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return CredentialRetrieveRequest.fromProtobufBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 059a9f3..1c5a443 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -20,2 +20,7 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 
@@ -23,4 +28,6 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 import android.os.Parcel;
+import com.google.common.collect.ImmutableMap;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
@@ -35,119 +42,203 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
+    @Test
+    public void testBuilder_setAdditionalProperty() {
+        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(2);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
+        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalPropertyAsString() {
+        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setAdditionalPropertyAsString(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_STRING_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
+                        ADDITIONAL_PROP_STRING_VALUE));
+    }
+
+    @Test
+    public void testGetAdditionalProperty() {
+        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
+                .build();
+
+        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testGetAdditionalProperty_withMissingKey() {
+        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .build();
+        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
+    }
+
+    @Test
+    public void testGetAdditionalPropertyAsString() {
+        CredentialRetrieveRequest cdr = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
+                .build();
+
+        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
+    }
+
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         CredentialRetrieveRequest.fromProtobuf(null);
     }
 
     @Test
     public void testWriteAndRead() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .setRequireUserMediation(true)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             ValidTokenProviderMap.assertEquals(deserialized.getTokenProviders());
             ValidAdditionalProperties.assertEquals(deserialized.getAdditionalProperties());
             assertThat(deserialized.getRequireUserMediation()).isTrue();
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
             .fromAuthMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
 
     @Test
     public void toProtocolBuffer_usingDefaultBuilder_returnsExpectedValues() {
         CredentialRetrieveRequest request =
                 new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL).build();
 
         Protobufs.CredentialRetrieveRequest protoRequest = request.toProtocolBuffer();
 
         assertThat(protoRequest.getRequireUserMediation())
                 .isEqualTo(CredentialRetrieveRequest.DEFAULT_REQUIRE_USER_MEDIATION_VALUE);
     }
 
     @Test
     public void toProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 }
\ No newline at end of file

commit 4e92daf5ee7dd3380340aa81fc22b563bae1981c
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 15:03:25 2017 -0700

    Additional property utility methods for CredentialDeleteResult
    
    Part of implementation for #99.

diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index 31f403c..a26d5a7 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -33,281 +33,331 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
  *     OpenYOLO Specification: Credential Deletion</a>
  */
 public final class CredentialDeleteResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that no provider was available and able to handle the associated request.
      */
     public static final int CODE_NO_PROVIDER_AVAILABLE =
             Protobufs.CredentialDeleteResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
 
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult UNKNOWN =
             new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built deletion result that indicates that no provider was available and able to handle
      * the associated request.
      */
     public static final CredentialDeleteResult NO_PROVIDER_AVAILABLE =
             new CredentialDeleteResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
     private static final String UNABLE_TO_EXTRACT_RESULT =
             "Unable to extract or parse the credential deletion result";
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), IllegalArgumentException.class);
 
         return new CredentialDeleteResult.Builder(proto).build();
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
      * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
     public static CredentialDeleteResult fromResultIntentData(
             @Nullable Intent intent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_RESULT,
                         Protobufs.CredentialDeleteResult.parser(),
                         UNABLE_TO_EXTRACT_RESULT,
                         intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_DELETED == mResultCode;
     }
 
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * credential deletion result, if available.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
+    /**
+     * Returns the additional, non-standard property identified by the specified key. If this
+     * additional property does not exist, then `null` is returned.
+     */
+    @Nullable
+    public byte[] getAdditionalProperty(String key) {
+        ByteString value = mAdditionalProps.get(key);
+        if (value == null) {
+            return null;
+        }
+
+        return value.toByteArray();
+    }
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key, where the
+     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
+     * then `null` is returned.
+     */
+    @Nullable
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesHelper.decodeStringValue(
+                getAdditionalProperty(key));
+    }
+
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
     public Intent toResultDataIntent() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
          * @throws MalformedDataException if the protocol buffer could not be parsed from the
          *     intent.
          */
         private Builder(Protobufs.CredentialDeleteResult proto) throws MalformedDataException {
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion result. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
+        /**
+         * Specifies an additional, non-standard property to include in the result.
+         */
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            ByteString immutableValue;
+            if (value == null) {
+                immutableValue = null;
+            } else {
+                immutableValue = ByteString.copyFrom(value);
+            }
+
+            mAdditionalProps.put(key, immutableValue);
+            return this;
+        }
+
+        /**
+         * Specifies an additional, non-standard property with a string value to include in the
+         * result.
+         */
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+        }
+
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
index 519d394..d72617b 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
@@ -17,2 +17,7 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
@@ -20,5 +25,8 @@ import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 import android.content.Intent;
+import com.google.common.collect.ImmutableMap;
 import com.google.protobuf.ByteString;
+import java.util.Map;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
 import org.robolectric.RobolectricTestRunner;
@@ -27,111 +35,195 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteResult}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteResultTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteResult INVALID_PROTO =
             Protobufs.CredentialDeleteResult.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
     private static final class ValidDeleteResult {
         public static CredentialDeleteResult make() {
             return new CredentialDeleteResult.Builder(
                     CredentialDeleteResult.CODE_DELETED)
                     .setAdditionalProperties(TestConstants.ValidAdditionalProperties.make())
                     .build();
         }
 
         public static void assertEquals(CredentialDeleteResult result) {
             assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
             TestConstants.ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
         }
     }
 
+    @Test
+    public void testBuilder_setAdditionalProperty() {
+        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(2);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
+        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalPropertyAsString() {
+        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalPropertyAsString(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_STRING_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
+                        ADDITIONAL_PROP_STRING_VALUE));
+    }
+
+    @Test
+    public void testGetAdditionalProperty() {
+        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
+                .build();
+
+        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testGetAdditionalProperty_withMissingKey() {
+        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .build();
+        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
+    }
+
+    @Test
+    public void testGetAdditionalPropertyAsString() {
+        CredentialDeleteResult cdr = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
+                .build();
+
+        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
+    }
+
     @Test
     public void build() {
         CredentialDeleteResult result = ValidDeleteResult.make();
 
         ValidDeleteResult.assertEquals(result);
     }
 
     @Test
     public void toProtobuf_fromProtobuf_isEquivalent() throws Exception {
         Protobufs.CredentialDeleteResult protobuf = ValidDeleteResult.make().toProtobuf();
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(protobuf);
 
         ValidDeleteResult.assertEquals(result);
     }
 
     @Test
     public void toResultIntentData_fromResultIntentData_isEquivalent() throws Exception {
         Intent resultData = ValidDeleteResult.make().toResultDataIntent();
         CredentialDeleteResult result = CredentialDeleteResult.fromResultIntentData(resultData);
 
         ValidDeleteResult.assertEquals(result);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_nullIntent_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(null);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_missingExtra_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(new Intent());
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, "notAByteArray");
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO_BYTES);
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO.toByteArray());
 
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromProtobuf_invalidProtoData_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
         byte[] protoBytes = ValidDeleteResult.make().toProtobuf().toByteArray();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobufBytes(protoBytes);
         ValidDeleteResult.assertEquals(result);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 }

commit 30db2399c1c646d0472e1b86221aab7004711448
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 14:42:57 2017 -0700

    Additional props utility methods for CredentialDeleteRequest
    
    Part of the implementation for #99.

diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index 5b9f148..25e5ffd 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -35,166 +35,217 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
  *     OpenYOLO Specification: Credential Deletion</a>
  */
 public final class CredentialDeleteRequest {
 
     /**
      * Returns a deletion request for the given credential.
      */
     public static CredentialDeleteRequest fromCredential(Credential credential) {
         return new Builder(credential).build();
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent, in byte array
      * form.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static CredentialDeleteRequest fromProtobufBytes(@NonNull byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException("unable to parse credential deletion request", ex);
         }
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static CredentialDeleteRequest fromProtobuf(
             @NonNull Protobufs.CredentialDeleteRequest proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new Builder(proto).build();
     }
 
 
     /**
      * Extracts a credential deletion request from a request intent.
      * @throws MalformedDataException if the provided intent is null, is missing the byte array
      *     extra for the request, or the request contains invalid data.
      */
     public static CredentialDeleteRequest fromRequestIntent(
             @Nullable Intent requestIntent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_REQUEST,
                         Protobufs.CredentialDeleteRequest.parser(),
                         "deletion request missing or contains invalid data",
                         requestIntent));
     }
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be deleted.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties specified by the client as part of this
      * deletion request.
      */
-    public Map<String, byte[]> getAdditionalProps() {
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
+    /**
+     * Returns the additional, non-standard property identified by the specified key. If this
+     * additional property does not exist, then `null` is returned.
+     */
+    @Nullable
+    public byte[] getAdditionalProperty(String key) {
+        ByteString value = mAdditionalProps.get(key);
+        if (value == null) {
+            return null;
+        }
+
+        return value.toByteArray();
+    }
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key, where the
+     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
+     * then `null` is returned.
+     */
+    @Nullable
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesHelper.decodeStringValue(
+                getAdditionalProperty(key));
+    }
+
     /**
      * Converts the request to its protocol buffer equivalent.
      */
     public Protobufs.CredentialDeleteRequest toProtobuf() {
         return Protobufs.CredentialDeleteRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Creates instances of {@link CredentialDeleteRequest}.
      */
     public static final class Builder {
 
         @NonNull
         private Credential mCredential;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion request, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(Protobufs.CredentialDeleteRequest proto) throws MalformedDataException {
             try {
                 setCredential(Credential.fromProtobuf(proto.getCredential()));
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * credential object.
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be deleted. Must not be null.
          */
         public Builder setCredential(@NonNull Credential credential) {
             validate(credential, notNullValue(), IllegalArgumentException.class);
 
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(
                 @Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = validateAdditionalProperties(additionalProperties);
             return this;
         }
 
+        /**
+         * Specifies an additional, non-standard property to include in the request.
+         */
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            ByteString immutableValue;
+            if (value == null) {
+                immutableValue = null;
+            } else {
+                immutableValue = ByteString.copyFrom(value);
+            }
+
+            mAdditionalProps.put(key, immutableValue);
+            return this;
+        }
+
+        /**
+         * Specifies an additional, non-standard property with a string value to include in the
+         * request.
+         */
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+        }
+
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion request, from the specified properties.
          */
         public CredentialDeleteRequest build() {
             return new CredentialDeleteRequest(this);
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
index ad67880..85583b3 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
@@ -16,2 +16,9 @@ package org.openyolo.protocol;
 
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
@@ -19,3 +26,5 @@ import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 import android.content.Intent;
+import com.google.common.collect.ImmutableMap;
 import com.google.protobuf.ByteString;
+import java.util.Map;
 import org.junit.Test;
@@ -28,125 +37,209 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteRequestTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteRequest INVALID_PROTO =
             Protobufs.CredentialDeleteRequest.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
     private static final class ValidDeleteRequest {
         public static final CredentialDeleteRequest make() {
             return new CredentialDeleteRequest.Builder(ValidFacebookCredential.make())
                             .setAdditionalProperties(ValidAdditionalProperties.make())
                             .build();
         }
 
         public static void assertEquals(CredentialDeleteRequest request) {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
-            ValidAdditionalProperties.assertEquals(request.getAdditionalProps());
+            ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
         }
     }
 
     @Test
     public void build() {
         CredentialDeleteRequest request = ValidDeleteRequest.make();
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullCredential_throwsIllegalArgumentException() {
         new CredentialDeleteRequest.Builder(null).build();
     }
 
+    @Test
+    public void testBuilder_setAdditionalProperty() {
+        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
+                ValidFacebookCredential.make())
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(2);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
+        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
+                ValidFacebookCredential.make())
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalPropertyAsString() {
+        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
+                ValidFacebookCredential.make())
+                .setAdditionalPropertyAsString(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_STRING_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cdr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
+                        ADDITIONAL_PROP_STRING_VALUE));
+    }
+
+    @Test
+    public void testGetAdditionalProperty() {
+        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
+                ValidFacebookCredential.make())
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_TWO_BYTE_VALUE))
+                .build();
+
+        assertThat(cdr.getAdditionalProperty(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testGetAdditionalProperty_withMissingKey() {
+        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
+                ValidFacebookCredential.make())
+                .build();
+        assertThat(cdr.getAdditionalProperty("missingKey")).isNull();
+    }
+
+    @Test
+    public void testGetAdditionalPropertyAsString() {
+        CredentialDeleteRequest cdr = new CredentialDeleteRequest.Builder(
+                ValidFacebookCredential.make())
+                .setAdditionalProperties(ImmutableMap.of(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        AdditionalPropertiesHelper.encodeStringValue(ADDITIONAL_PROP_STRING_VALUE)))
+                .build();
+
+        assertThat(cdr.getAdditionalPropertyAsString(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_STRING_VALUE);
+    }
+
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.CredentialDeleteRequest proto = ValidDeleteRequest.make().toProtobuf();
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromProtobuf(proto);
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_nullProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
         Protobufs.CredentialDeleteRequest proto = ValidDeleteRequest.make().toProtobuf();
         CredentialDeleteRequest request =
                 CredentialDeleteRequest.fromProtobufBytes(proto.toByteArray());
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 
     @Test
     public void fromRequestIntent() throws Exception {
         byte[] protoBytes = ValidDeleteRequest.make().toProtobuf().toByteArray();
         Intent requestIntent = new Intent();
         requestIntent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, protoBytes);
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromRequestIntent(requestIntent);
 
         ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_nullIntent_throwsException() throws Exception {
         CredentialDeleteRequest.fromRequestIntent(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_missingExtra_throwsException() throws Exception {
         Intent intent = new Intent();
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, "notAByteArray");
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO_BYTES);
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO.toByteArray());
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 3c9679a..58404c7 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -21,2 +21,7 @@ import static org.assertj.core.api.Java6Assertions.linesOf;
 import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ANOTHER_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_STRING_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TEST_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_TWO_BYTE_VALUE;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROP_ZERO_BYTE_VALUE;
 
@@ -35,371 +40,364 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final String AUTH_DOMAIN_STR = "https://www.example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
     private static final String ID_TOKEN =
             "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSIsImF1ZCI"
                     + "6IlhZWi5jbGllbnQuaWQiLCJpc3MiOiJpZHAuZXhhbXBsZS5jb20iLCJlbWFpbCI"
                     + "6ImFsaWNlQGV4YW1wbGUuY29tIiwibmFtZSI6IkFsaWNlIE1jVGVzdGVyc29uIiw"
                     + "icGljdHVyZSI6Imh0dHBzOi8vcm9ib2hhc2gub3JnL2FsaWNlIn0.2-D7AZ1C7mv"
                     + "dLRf6Q7aqH8Ah4rlK1uuHPSU2HPImtyk";
 
-    private static final String ADDITIONAL_PROP_TEST_KEY = "testKey";
-    private static final String ADDITIONAL_PROP_ANOTHER_KEY = "anotherKey";
-
-    private static final byte[] ADDITIONAL_PROP_TWO_BYTE_VALUE = new byte[] { 0, 1 };
-    private static final byte[] ADDITIONAL_PROP_ZERO_BYTE_VALUE = new byte[] {};
-    private static final String ADDITIONAL_PROP_STRING_VALUE = "value";
-
     @Test
     public void fromProtobuf_withValidCredential_returnsEquivalentCredential() throws Exception {
         Credential credential =
                 Credential.fromProtobuf(ValidFacebookCredential.make().toProtobuf());
 
         ValidFacebookCredential.assertEqualTo(credential);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetIdToken_validInput_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         assertThat(cr.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(null)
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken("")
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
         @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testBuilder_setAdditionalProperty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
                 .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
                 .build();
 
         Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
         assertThat(additionalProps.size()).isEqualTo(2);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
                 .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
     }
 
     @Test
     public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
                 .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
                 .build();
 
         Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
         assertThat(additionalProps.size()).isEqualTo(1);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
     }
 
     @Test
     public void testBuilder_setAdditionalPropertyAsString() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAdditionalPropertyAsString(
                         ADDITIONAL_PROP_TEST_KEY,
                         ADDITIONAL_PROP_STRING_VALUE)
                 .build();
 
         Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
         assertThat(additionalProps.size()).isEqualTo(1);
         assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
         assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
                 .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
                         ADDITIONAL_PROP_STRING_VALUE));
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 
     @Test
     public void testGetAdditionalProperty() {
         String key = "testKey";
         byte[] value = new byte[] { 0, 1 };
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAdditionalProperties(ImmutableMap.of(key, value))
                 .build();
 
         assertThat(cr.getAdditionalProperty(key)).isEqualTo(value);
     }
 
     @Test
     public void testGetAdditionalProperty_withMissingKey() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
         assertThat(cr.getAdditionalProperty("missingKey")).isNull();
     }
 
     @Test
     public void testGetAdditionalPropertyAsString() {
         String key = "testKey";
         byte[] value = AdditionalPropertiesHelper.encodeStringValue("testValue");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAdditionalProperties(ImmutableMap.of(key, value))
                 .build();
 
         assertThat(cr.getAdditionalPropertyAsString(key)).isEqualTo("testValue");
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TestConstants.java b/protocol/javatests/org/openyolo/protocol/TestConstants.java
index 4e3955b..0a7aff8 100644
--- a/protocol/javatests/org/openyolo/protocol/TestConstants.java
+++ b/protocol/javatests/org/openyolo/protocol/TestConstants.java
@@ -36,290 +36,297 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Useful constants and associated verification methods for tests.
  */
 public final class TestConstants {
 
     public static final byte[] INVALID_PROTO_BYTES =
             new byte[] { 'i', 'n', 'v', 'a', 'l', 'i', 'd' };
 
+    public static final String ADDITIONAL_PROP_TEST_KEY = "testKey";
+    public static final String ADDITIONAL_PROP_ANOTHER_KEY = "anotherKey";
+
+    public static final byte[] ADDITIONAL_PROP_TWO_BYTE_VALUE = new byte[] { 0, 1 };
+    public static final byte[] ADDITIONAL_PROP_ZERO_BYTE_VALUE = new byte[] {};
+    public static final String ADDITIONAL_PROP_STRING_VALUE = "value";
+
     public static final class ValidAdditionalProperties {
         private static final String ADDITIONAL_KEY = "extra";
         private static final byte[] ADDITIONAL_VALUE = "value".getBytes();
 
         public static Map<String, byte[]> make() {
             Map<String, byte[]> additionalProps = new HashMap<>();
             additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
             return additionalProps;
         }
 
         public static Map<String, ByteString> makeForProto() {
             return CollectionConverter.convertMapValues(
                     make(),
                     ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
         }
 
 
         public static void assertEquals(Map<String, byte[]> additionalProps) {
             assertThat(additionalProps).isNotNull();
             assertThat(additionalProps).hasSize(1);
             assertThat(additionalProps).containsKey(ADDITIONAL_KEY);
             assertThat(additionalProps.get(ADDITIONAL_KEY)).isEqualTo(ADDITIONAL_VALUE);
         }
 
         public static void assertEqualsForProto(Map<String, ByteString> additionalProps) {
             assertEquals(CollectionConverter.convertMapValues(
                     additionalProps,
                     ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
     }
 
     public static final class ValidTokenRequestInfo {
         private static final String CLIENT_ID = "XYZ.client.id";
         private static final String NONCE = "asdf";
 
         public static TokenRequestInfo make() {
             return new TokenRequestInfo.Builder()
                     .setClientId(CLIENT_ID)
                     .setNonce(NONCE)
                     .setAdditionalProperties(ValidAdditionalProperties.make())
                     .build();
         }
 
         public static void assertEquals(TokenRequestInfo info) {
             assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
             assertThat(info.getNonce()).isEqualTo(NONCE);
             ValidAdditionalProperties.assertEquals(info.getAdditionalProperties());
         }
 
         public static void assertEquals(Protobufs.TokenRequestInfo info) {
             assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
             assertThat(info.getNonce()).isEqualTo(NONCE);
             ValidAdditionalProperties.assertEqualsForProto(info.getAdditionalPropsMap());
         }
 
     }
 
     public static final class ValidTokenProviderMap {
         private static final String TOKEN_PROVIDER_1 = "https://idp1.example.com";
         private static final String TOKEN_PROVIDER_2 = "https://idp2.example.com";
 
 
         public static Map<String, TokenRequestInfo> make() {
             HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
             tokenProviders.put(TOKEN_PROVIDER_1, ValidTokenRequestInfo.make());
             tokenProviders.put(TOKEN_PROVIDER_2, null);
             return tokenProviders;
         }
 
         public static void assertEquals(Map<String, TokenRequestInfo> tokenProviders) {
             assertThat(tokenProviders).hasSize(2);
             assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_1);
             assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_2);
             ValidTokenRequestInfo.assertEquals(tokenProviders.get(TOKEN_PROVIDER_1));
             assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getClientId()).isNull();
             assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getNonce()).isNull();
             assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getAdditionalProperties()).isEmpty();
         }
     }
 
     public static final class ValidProperties {
         public static final String PROPERTY_A_NAME = "Property A";
         public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
 
         public static final String PROPERTY_B_NAME = "Property B";
         public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
 
         public static final Map<String, byte[]> MAP_INSTANCE;
 
         static {
             MAP_INSTANCE = new HashMap<>();
             MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
             MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
         }
 
         public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
             Map<String, byte[]> byteMap =
                     CollectionConverter.convertMapValues(
                             map,
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             assertEqualTo(byteMap);
         }
 
         public static void assertEqualTo(Map<String, byte[]> map) {
             assertThat(map).hasSize(2);
             assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
             assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
         }
     }
 
     public static final class ValidFacebookCredential {
         public final static String ID = "bob@facebook.com";
         public final static String ID_TOKEN = "'His name is bob' - xoxo facebook";
         public final static AuthenticationMethod AUTHENTICATION_METHOD =
                 AuthenticationMethods.FACEBOOK;
         public final static String PASSWORD = "hunter2";
         public final static String DISPLAY_NAME = "Bob";
         public final static Uri DISPLAY_PICTURE_URL =
                 Uri.parse("https://pictures.facebook.com/bob_pics.jpeg");
         public final static Map<String, byte[]> ADDITIONAL_PROPERTIES =
                 ValidProperties.MAP_INSTANCE;
         public final static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
         public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
                 new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
 
         public static Credential make() {
             return new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN)
                     .setDisplayName(DISPLAY_NAME)
                     .setDisplayPicture(DISPLAY_PICTURE_URL)
                     .setPassword(PASSWORD)
                     .setIdToken(ID_TOKEN)
                     .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                     .build();
         }
 
         public static void assertEqualTo(Credential credential) {
             assertThat(credential.getIdentifier()).isEqualTo(ID);
             assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
             assertThat(credential.getPassword()).isEqualTo(PASSWORD);
             assertThat(credential.getDisplayName()).isEqualTo(DISPLAY_NAME);
             assertThat(credential.getDisplayPicture()).isEqualTo(DISPLAY_PICTURE_URL);
             ValidProperties.assertEqualTo(credential.getAdditionalProperties());
             assertThat(credential.getAuthenticationMethod()).isEqualTo(AUTHENTICATION_METHOD);
             assertThat(credential.getAuthenticationDomain()).isEqualTo(AUTHENTICATION_DOMAIN);
         }
 
         public static void assertEqualTo(Protobufs.Credential credential) throws Exception {
             assertEqualTo(Credential.fromProtobuf(credential));
         }
     }
 
     public static final class ValidEmailHint {
         private static final String ALICE_ID = "alice@example.com";
         private static final String ALICE_NAME = "Alice";
         private static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://avatars.example.com/alice";
         private static final Uri ALICE_DISPLAY_PICTURE_URI = Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
         private static final String GENERATED_PASSWORD = "correctH0rseBatterySt4ple";
         private static final String ID_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
                 + "eyJzdWIiOiJ5b2xvIn0."
                 + "BI1g9ns0shv6PKfwlhfPKwh5XzxQyg_el_35_wZbtsI";
 
         public static Hint make() {
             return new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                     .setDisplayName(ALICE_NAME)
                     .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
                     .setGeneratedPassword(GENERATED_PASSWORD)
                     .setIdToken(ID_TOKEN)
                     .build();
         }
 
         public static void assertEquals(Context context, Credential credential) {
             assertThat(credential.getIdentifier()).isEqualTo(ALICE_ID);
             assertThat(credential.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
             assertThat(credential.getDisplayName()).isEqualTo(ALICE_NAME);
             assertThat(credential.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
             assertThat(credential.getPassword()).isEqualTo(GENERATED_PASSWORD);
             assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
             assertThat(credential.getAuthenticationDomain())
                     .isEqualTo(AuthenticationDomain.getSelfAuthDomain(context));
         }
 
         public static void assertEquals(Hint hint) {
             assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
             assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
             assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
             assertThat(hint.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
             assertThat(hint.getGeneratedPassword()).isEqualTo(GENERATED_PASSWORD);
             assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
         }
 
         public static void assertEquals(Protobufs.Hint protoHint) {
             assertThat(protoHint.getId()).isEqualTo(ALICE_ID);
             assertThat(protoHint.getAuthMethod().getUri())
                     .isEqualTo(AuthenticationMethods.EMAIL.toString());
             assertThat(protoHint.getDisplayName()).isEqualTo(ALICE_NAME);
             assertThat(protoHint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
             assertThat(protoHint.getGeneratedPassword()).isEqualTo(GENERATED_PASSWORD);
             assertThat(protoHint.getIdToken()).isEqualTo(ID_TOKEN);
         }
     }
 
     public static final class ValidApplication {
         public static final String PACKAGE_NAME = "com.example.app";
         private static final String FINGERPRINT =
                 "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                         + "7V4Lo8BdCxaA307H0HYkAw==";
         private static byte[] SIGNATURE_BYTES = new byte[]
                 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
 
         public static final class AuthDomain {
             private static final String AUTHENTICATION_DOMAIN_STRING =
                     "android://" + FINGERPRINT + "@" + PACKAGE_NAME;
 
             public static AuthenticationDomain make() {
                 return new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
             }
 
             public static void assertEquals(AuthenticationDomain domain) {
                 assertThat(domain).isEqualTo(make());
             }
         }
 
         public static Context install(Context context) throws Exception {
             PackageManager packageManager = mock(PackageManager.class);
 
             when(packageManager.getPackageInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_SIGNATURES)))
                     .thenReturn(makePackageInfo());
             doThrow(PackageManager.NameNotFoundException.class)
                     .when(packageManager).getPackageInfo(
                             not(eq(PACKAGE_NAME)),
                             eq(PackageManager.GET_SIGNATURES));
 
             context = spy(context);
             when(context.getPackageName()).thenReturn(PACKAGE_NAME);
             when(context.getPackageManager()).thenReturn(packageManager);
 
             return context;
         }
 
         private static PackageInfo makePackageInfo() {
             PackageInfo packageInfo = new PackageInfo();
             packageInfo.signatures = new Signature[1];
             packageInfo.signatures[0] = new Signature(SIGNATURE_BYTES);
 
             return packageInfo;
         }
     }
 
     public static final class ApplicationWithMultipleSignatures {
         public static final String PACKAGE_NAME = "com.example.app.multiple_signatures";
         private static byte[] SIGNATURE_BYTES = new byte[]
                 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
         public static Context install(Context context) throws Exception {
             PackageManager packageManager = mock(PackageManager.class);
 
             when(packageManager.getPackageInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_SIGNATURES)))
                     .thenReturn(makePackageInfo());
             doThrow(PackageManager.NameNotFoundException.class)
                     .when(packageManager).getPackageInfo(
                     not(eq(PACKAGE_NAME)),
                     eq(PackageManager.GET_SIGNATURES));
 
             context = spy(context);
             when(context.getPackageName()).thenReturn(PACKAGE_NAME);
             when(context.getPackageManager()).thenReturn(packageManager);
 
             return context;
         }
 
         private static PackageInfo makePackageInfo() {
             PackageInfo packageInfo = new PackageInfo();
             packageInfo.signatures = new Signature[2];
             packageInfo.signatures[0] = new Signature(SIGNATURE_BYTES);
             packageInfo.signatures[1] = new Signature(SIGNATURE_BYTES);
 
             return packageInfo;
         }
     }
 }

commit 95dd6a5960c301a72d6c7a9717094da07efec8d5
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 13:34:57 2017 -0700

    Add additional property utility methods to Credential

diff --git a/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java b/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java
new file mode 100644
index 0000000..93d1de5
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/AdditionalPropertiesHelper.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import android.support.annotation.Nullable;
+import java.nio.charset.Charset;
+
+/**
+ * Utility methods for reading and writing additional properties.
+ */
+public final class AdditionalPropertiesHelper {
+
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+    /**
+     * Encodes the provided string for use as an additional property, using UTF-8 encoding.
+     * If the provided string is `null`, then `null will be returned.
+     */
+    @Nullable
+    public static byte[] encodeStringValue(@Nullable String value) {
+        if (value == null) {
+            return null;
+        }
+
+        return value.getBytes(UTF_8);
+    }
+
+    /**
+     * Decodes the provided byte array from an additional property value to a String. This
+     * assumes that the byte array was originally produced by {@link #encodeStringValue(String)}
+     * or equivalent code. If the provided byte array is `null`, then `null` will be returned.
+     */
+    @Nullable
+    public static String decodeStringValue(@Nullable byte[] value) {
+        if (value == null) {
+            return null;
+        }
+
+        return new String(value, UTF_8);
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 9de6565..24bbd42 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -38,404 +38,455 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a credential for use in sign-in. This provides a higher-level,
  * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
  * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credentials">
  *     OpenYOLO Specification: Credential</a>
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     /**
      * Creates a credential from its protocol buffer equivalent, in byte form.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static Credential fromProtoBytes(@NonNull byte[] credentialProtoBytes)
             throws MalformedDataException {
         validate(credentialProtoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static Credential fromProtobuf(Protobufs.Credential credential)
             throws MalformedDataException {
         return new Credential.Builder(credential).build();
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationDomain mAuthDomain;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPicture;
 
     @Nullable
     private final String mPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Credential(Builder builder) {
         mId = builder.mId;
         mAuthDomain = builder.mAuthDomain;
         mAuthMethod = builder.mAuthMethod;
         mDisplayName = builder.mDisplayName;
         mDisplayPicture = builder.mDisplayPicture;
         mPassword = builder.mPassword;
         mIdToken = builder.mIdToken;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
     public Protobufs.Credential toProtobuf() {
         Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .setAuthDomain(mAuthDomain.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPicture != null) {
             builder.setDisplayPictureUri(mDisplayPicture.toString());
         }
 
         if (mPassword != null) {
             builder.setPassword(mPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
     @NonNull
     public AuthenticationDomain getAuthenticationDomain() {
         return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPicture;
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
         return mPassword;
     }
 
     /**
      * An ID token which provides "proof of access" to the identifier for this credential, if
      * available.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
             mAdditionalProps,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
+    /**
+     * Returns the additional, non-standard property identified by the specified key. If this
+     * additional property does not exist, then `null` is returned.
+     */
+    @Nullable
+    public byte[] getAdditionalProperty(String key) {
+        ByteString value = mAdditionalProps.get(key);
+        if (value == null) {
+            return null;
+        }
+
+        return value.toByteArray();
+    }
+
+    /**
+     * Returns the additional, non-standard property identified by the specified key, where the
+     * value is assumed to be a UTF-8 encoded string. If this additional property does not exist,
+     * then `null` is returned.
+     */
+    @Nullable
+    public String getAdditionalPropertyAsString(String key) {
+        return AdditionalPropertiesHelper.decodeStringValue(
+                getAdditionalProperty(key));
+    }
+
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
         private String mId;
         private AuthenticationMethod mAuthMethod;
         private AuthenticationDomain mAuthDomain;
         private String mDisplayName;
         private Uri mDisplayPicture;
         private String mPassword;
         private String mIdToken;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          * @throws MalformedDataException if the given protocol buffer is invalid.
          */
         private Builder(@NonNull Protobufs.Credential proto) throws MalformedDataException {
             try {
                 // required properties
                 setIdentifier(proto.getId());
                 setAuthenticationMethod(AuthenticationMethod.fromProtobuf(proto.getAuthMethod()));
                 setAuthenticationDomain(AuthenticationDomain.fromProtobuf(proto.getAuthDomain()));
 
                 // optional properties
 
                 setIdToken(proto.getIdToken());
                 setDisplayName(proto.getDisplayName());
                 setDisplayPicture(proto.getDisplayPictureUri());
                 setPassword(proto.getPassword());
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 proto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
          * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
                     new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
             validate(identifier, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             validate(domain, notNullValue(), IllegalArgumentException.class);
             mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
         public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
             validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
             mPassword = nullifyEmptyString(password);
             return this;
         }
 
         /**
          * Specifies the ID token for the credential. If a null or empty value is provided, this
          * is equivalent to remove the ID token from the credential.
          */
         @NonNull
         public Builder setIdToken(String idToken) {
             this.mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             validate(displayPicture, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
+        @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                 AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
             return this;
         }
 
+        /**
+         * Specifies an additional, non-standard property to include in the credential.
+         */
+        @NonNull
+        public Builder setAdditionalProperty(@NonNull String key, @Nullable byte[] value) {
+            ByteString immutableValue;
+            if (value == null) {
+                immutableValue = null;
+            } else {
+                immutableValue = ByteString.copyFrom(value);
+            }
+
+            mAdditionalProps.put(key, immutableValue);
+            return this;
+        }
+
+        /**
+         * Specifies an additional, non-standard property with a string value to include in the
+         * credential.
+         */
+        @NonNull
+        public Builder setAdditionalPropertyAsString(@NonNull String key, @Nullable String value) {
+            return setAdditionalProperty(key, AdditionalPropertiesHelper.encodeStringValue(value));
+        }
+
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
             return new Credential(this);
         }
     }
 
     private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
                 return Credential.fromProtoBytes(encodedBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 7ed58c0..3c9679a 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -19,2 +19,3 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.linesOf;
 import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
@@ -23,2 +24,6 @@ import android.net.Uri;
 import android.os.Parcel;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import java.util.Map;
 import org.junit.Test;
@@ -30,289 +35,371 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final String AUTH_DOMAIN_STR = "https://www.example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
     private static final String ID_TOKEN =
             "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSIsImF1ZCI"
                     + "6IlhZWi5jbGllbnQuaWQiLCJpc3MiOiJpZHAuZXhhbXBsZS5jb20iLCJlbWFpbCI"
                     + "6ImFsaWNlQGV4YW1wbGUuY29tIiwibmFtZSI6IkFsaWNlIE1jVGVzdGVyc29uIiw"
                     + "icGljdHVyZSI6Imh0dHBzOi8vcm9ib2hhc2gub3JnL2FsaWNlIn0.2-D7AZ1C7mv"
                     + "dLRf6Q7aqH8Ah4rlK1uuHPSU2HPImtyk";
 
+    private static final String ADDITIONAL_PROP_TEST_KEY = "testKey";
+    private static final String ADDITIONAL_PROP_ANOTHER_KEY = "anotherKey";
+
+    private static final byte[] ADDITIONAL_PROP_TWO_BYTE_VALUE = new byte[] { 0, 1 };
+    private static final byte[] ADDITIONAL_PROP_ZERO_BYTE_VALUE = new byte[] {};
+    private static final String ADDITIONAL_PROP_STRING_VALUE = "value";
+
     @Test
     public void fromProtobuf_withValidCredential_returnsEquivalentCredential() throws Exception {
         Credential credential =
                 Credential.fromProtobuf(ValidFacebookCredential.make().toProtobuf());
 
         ValidFacebookCredential.assertEqualTo(credential);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetIdToken_validInput_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         assertThat(cr.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(null)
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken("")
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
         @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
+    @Test
+    public void testBuilder_setAdditionalProperty() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_ANOTHER_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(2);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_TWO_BYTE_VALUE);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_ANOTHER_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_ANOTHER_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalProperty_overwriteExistingValue() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_TWO_BYTE_VALUE)
+                .setAdditionalProperty(ADDITIONAL_PROP_TEST_KEY, ADDITIONAL_PROP_ZERO_BYTE_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(ADDITIONAL_PROP_ZERO_BYTE_VALUE);
+    }
+
+    @Test
+    public void testBuilder_setAdditionalPropertyAsString() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setAdditionalPropertyAsString(
+                        ADDITIONAL_PROP_TEST_KEY,
+                        ADDITIONAL_PROP_STRING_VALUE)
+                .build();
+
+        Map<String, byte[]> additionalProps = cr.getAdditionalProperties();
+        assertThat(additionalProps.size()).isEqualTo(1);
+        assertThat(additionalProps.containsKey(ADDITIONAL_PROP_TEST_KEY));
+        assertThat(additionalProps.get(ADDITIONAL_PROP_TEST_KEY))
+                .isEqualTo(AdditionalPropertiesHelper.encodeStringValue(
+                        ADDITIONAL_PROP_STRING_VALUE));
+    }
+
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
+
+    @Test
+    public void testGetAdditionalProperty() {
+        String key = "testKey";
+        byte[] value = new byte[] { 0, 1 };
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setAdditionalProperties(ImmutableMap.of(key, value))
+                .build();
+
+        assertThat(cr.getAdditionalProperty(key)).isEqualTo(value);
+    }
+
+    @Test
+    public void testGetAdditionalProperty_withMissingKey() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
+        assertThat(cr.getAdditionalProperty("missingKey")).isNull();
+    }
+
+    @Test
+    public void testGetAdditionalPropertyAsString() {
+        String key = "testKey";
+        byte[] value = AdditionalPropertiesHelper.encodeStringValue("testValue");
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setAdditionalProperties(ImmutableMap.of(key, value))
+                .build();
+
+        assertThat(cr.getAdditionalPropertyAsString(key)).isEqualTo("testValue");
+    }
 }

commit e2248903e923bda6e0bb38ed7240c5cadaa6723d
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Mon Oct 2 13:45:26 2017 -0700

    Change build status badge to Travis

diff --git a/README.md b/README.md
index 5ad4a8e..ac97ddc 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
 ![OpenYOLO for Android](https://rawgit.com/openid/OpenYOLO-Android/master/openyolo_android_lockup.svg)
 
-[![Build Status](https://www.bitrise.io/app/e7b1a2bcce9d787c.svg?token=kvggLFAJ-Tx48g6I671NSg)](https://www.bitrise.io/app/e7b1a2bcce9d787c)
+[![Build Status](https://travis-ci.org/openid/OpenYOLO-Android.svg?branch=master)](https://travis-ci.org/openid/OpenYOLO-Android)
 [![codecov](https://codecov.io/gh/openid/OpenYOLO-Android/branch/master/graph/badge.svg)](https://codecov.io/gh/openid/OpenYOLO-Android)

commit 0afb57814e2bfbdaad7c93adb2ed465a2e4e418e
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 11:51:59 2017 -0700

    Upload code coverage to codecov as part of Travis build

diff --git a/.travis.yml b/.travis.yml
index cffd9cf..0a5bf55 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,5 +6,7 @@ android:
   components:
     - build-tools-26.0.1
     - android-26
-script: ./gradlew check jacoco assemble
+script:
+  - ./gradlew check jacoco assemble
+  - bash <(curl -s https://codecov.io/bash)
 cache:

commit c0eeba1969aae4bb19a799fdf882b90509e1bb52
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Mon Oct 2 13:52:43 2017 -0700

    Corrected version description for bintray configuration. (#103)

diff --git a/config/bintray.gradle b/config/bintray.gradle
index 7e3b316..f785f25 100644
--- a/config/bintray.gradle
+++ b/config/bintray.gradle
@@ -4,23 +4,23 @@ apply plugin: 'com.github.dcendents.android-maven'
 bintray {
     user = System.getenv("BINTRAY_USER")
     key = System.getenv("BINTRAY_KEY")
     pkg {
         repo = "net.openid"
         name = project.archivesBaseName
         desc = project.moduleDesc
         userOrg = "openid"
         licenses = ["Apache-2.0"]
         websiteUrl = "https://openid.github.io/OpenYOLO-Android/"
         issueTrackerUrl = "https://github.com/openid/OpenYOLO-Android/issues"
         vcsUrl = "https://github.com/openid/OpenYOLO-Android.git"
         githubRepo = 'openid/OpenYOLO-Android'
 
         version {
             name = rootProject.versionName
-            desc = "AppAuth for Android"
+            desc = "OpenYOLO for Android"
             released = rootProject.versionDate
             vcsTag = rootProject.versionName
         }
     }
     configurations = ["archives"]
 }

commit b985bd92f2d737f6088c61f4526b357bdca2b0aa
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 11:48:20 2017 -0700

    Cache maven dependencies for a faster build

diff --git a/.travis.yml b/.travis.yml
index 2014261..cffd9cf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,4 +6,7 @@ android:
   components:
     - build-tools-26.0.1
     - android-26
-script: ./gradlew check jacoco assemble
\ No newline at end of file
+script: ./gradlew check jacoco assemble
+cache:
+  directories:
+    - $HOME/.m2
\ No newline at end of file

commit da8069e8776b09adf4772f104d927813bee923d4
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Oct 2 11:11:18 2017 -0700

    Ensure that checkstyle rules are enforced by Travis

diff --git a/.travis.yml b/.travis.yml
index 6dc8546..2014261 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8 +8,2 @@ android:
     - android-26
+script: ./gradlew check jacoco assemble
\ No newline at end of file

commit 25289a6affdeb7b3daaf2926b9dcf6b1c8fd9f2b
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Mon Oct 2 11:11:32 2017 -0700

    Minor documentation fixes. (#97)

diff --git a/api/README.md b/api/README.md
index 4e03bd4..091de50 100644
--- a/api/README.md
+++ b/api/README.md
@@ -7,3 +7,3 @@
 
-This is an open-source library for the OpenYOLO for Android protocol. It allows you to easily
+This is an open-source client library for the OpenYOLO for Android protocol. It allows you to easily
 manipulate credentials for your application by interacting with the credential provider of the
@@ -16,15 +16,18 @@ user's choice. This allows you to:
 ## Installation
-As a pre-requisite, you will need to add the OpenYOLO Api as a dependency. For example, if your
-project uses Gradle:
+[ ![Download](https://api.bintray.com/packages/openid/net.openid/openyolo-api/images/download.svg) ](https://bintray.com/openid/net.openid/openyolo-api/_latestVersion)
+
+As a pre-requisite, you will need to add the OpenYOLO Api as a dependency. Check
+[here](https://bintray.com/openid/net.openid/openyolo-api) or the above button for the latest
+version. For example, if your project uses Gradle:
 
 ```groovy
 dependencies {
     // ...
-    compile 'com.openyolo:api:xxx'
+    compile 'com.openyolo:openyolo-api:x.y.z'
 }
 ```
 
 ## Terminology
 
- - [Authentication Method](https://spec.openyolo.org/openyolo-android-spec.html#authentication-methods):
+ - [Authentication Method](http://openid.net/specs/openyolo-android-ID1.html#authentication-methods):
 An authentication method is a mechanism by which a credential can be verified. It is represented as
@@ -33,3 +36,3 @@ as ``openyolo://email`` and ```openyolo://phone```.  When requesting a credentia
 application will declare which authentication methods it supports.
- - [Authentication Domain](https://spec.openyolo.org/openyolo-android-spec.html#authentication-domains):
+ - [Authentication Domain](http://openid.net/specs/openyolo-android-ID1.html#authentication-domains):
 An authentication domain is the scope in which a credential is considered to be usable. A domain

commit 56de15100495ae7563167beae66ae5f7b2ee1dc2
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Mon Oct 2 11:06:05 2017 -0700

    Add Travis CI config (#98)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6dc8546
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+# Travis documentation for Android project builds:
+# https://docs.travis-ci.com/user/languages/android
+
+language: android
+android:
+  components:
+    - build-tools-26.0.1
+    - android-26

commit 37faf5bd4cfc99760f8e61f6a0010917a324177f
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Fri Sep 29 14:02:30 2017 -0700

    Added Google specific overrides for the ProviderPickerActivity. (#94)

diff --git a/api/java/org/openyolo/api/internal/ProviderPickerActivity.java b/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
index 52508c2..dd7c8a7 100644
--- a/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
@@ -44,2 +44,3 @@ import java.util.List;
 import org.openyolo.api.R;
+import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.CredentialDeleteResult;
@@ -50,230 +51,246 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * Activity which presents the given list of providers and their associated intent operations.
  * The user can select one of these providers, which fires the associated intent, or cancel the
  * whole operation.
  */
 public final class ProviderPickerActivity extends Activity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES_ID = "titleRes";
     private static final String EXTRA_USER_CANCELED_RESULT = "userCanceledResult";
     private static final String LOG_TAG = "ProviderPicker";
 
     private static final ActivityResult RETRIEVE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialRetrieveResult.CODE_USER_CANCELED,
                     CredentialRetrieveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult SAVE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialSaveResult.CODE_USER_CANCELED,
                     CredentialSaveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult HINT_USER_CANCELED_RESULT =
             ActivityResult.of(
                     HintRetrieveResult.CODE_USER_CANCELED,
                     HintRetrieveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult DELETE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialDeleteResult.CODE_USER_CANCELED,
                     CredentialDeleteResult.USER_CANCELED.toResultDataIntent());
 
     private View mPickerContainer;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.provider_picker_layout);
         getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
 
         mPickerContainer = findViewById(R.id.picker_container);
 
         // Setup title
         TextView titleView = findViewById(R.id.picker_title);
         @StringRes int titleResId = getIntent().getIntExtra(EXTRA_TITLE_RES_ID, 0);
         String title = getResources().getString(titleResId);
         titleView.setText(title);
 
         // Setup provider list
         ListView providerView = findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
     @Override
     public boolean dispatchTouchEvent(MotionEvent event) {
 
         // finishWithUserCanceled() if the user tapped outside the picker
         if (MotionEvent.ACTION_DOWN == event.getAction()) {
             Rect visibilityRect = new Rect();
             mPickerContainer.getGlobalVisibleRect(visibilityRect);
             boolean tappedOutsidePicker =
                     !visibilityRect.contains((int) event.getRawX(), (int) event.getRawY());
             if (tappedOutsidePicker) {
                 finishWithUserCanceled();
             }
         }
 
         return super.dispatchTouchEvent(event);
     }
 
     @Override
     public void onBackPressed() {
         finishWithUserCanceled();
     }
 
     private void finishWithUserCanceled() {
         ActivityResult activityResult = getIntent().getParcelableExtra(EXTRA_USER_CANCELED_RESULT);
 
         if (null != activityResult) {
             setResult(activityResult.getResultCode(), activityResult.getData());
         }
 
         finish();
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes,
             @Nullable ActivityResult userCanceledResult) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES_ID, titleRes);
         intent.putExtra(EXTRA_USER_CANCELED_RESULT, userCanceledResult);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
 
         return createIntent(
                 context,
                 retrieveIntents,
                 R.string.retrieve_picker_prompt,
                 RETRIEVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
 
         return createIntent(
                 context,
                 retrieveIntents,
                 R.string.save_picker_prompt,
                 SAVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
 
         return createIntent(
                 context,
                 hintIntents,
                 R.string.hint_picker_prompt,
                 HINT_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for display a list of providers to which a credential deletion request
      * should be sent.
      */
     public static Intent createDeleteIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> deleteIntents) {
 
         return createIntent(
                 context,
                 deleteIntents,
                 R.string.delete_picker_prompt,
                 DELETE_USER_CANCELED_RESULT);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
-                    mProviderIcons.add(info.loadIcon(pm));
-                    mProviderNames.add(pm.getApplicationLabel(info).toString());
+
+                    // NOTE(dxslly): Google's provider implementation lives inside the Google Play
+                    // Services APK which has a different application label and icon than user's
+                    // expect. To avoid confusion, a special case is made to provide the correct
+                    // branding. Ideally this should be solved at the protocol level (e.g. optional
+                    // metadata specified in the manifest that can override these defaults for
+                    // trusted providers).
+                    AuthenticationDomain authDomain =
+                            AuthenticationDomain.fromPackageName(getContext(), packageName);
+                    if (KnownProviders.GOOGLE_PROVIDER.equals(authDomain)) {
+                        mProviderIcons.add(getDrawable(R.drawable.google_g_standard_color));
+                        mProviderNames.add(
+                                getString(R.string.provider_picker_google_provider_name));
+                    } else {
+                        mProviderIcons.add(info.loadIcon(pm));
+                        mProviderNames.add(pm.getApplicationLabel(info).toString());
+                    }
+
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = itemView.findViewById(R.id.provider_name);
             View providerUnsafe = itemView.findViewById(R.id.unsafe_provider_warning);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
     }
 }
diff --git a/api/res/drawable-hdpi/google_g_standard_color.png b/api/res/drawable-hdpi/google_g_standard_color.png
new file mode 100644
index 0000000..ce9215b
Binary files /dev/null and b/api/res/drawable-hdpi/google_g_standard_color.png differ
diff --git a/api/res/drawable-mdpi/google_g_standard_color.png b/api/res/drawable-mdpi/google_g_standard_color.png
new file mode 100644
index 0000000..4702fba
Binary files /dev/null and b/api/res/drawable-mdpi/google_g_standard_color.png differ
diff --git a/api/res/drawable-xhdpi/google_g_standard_color.png b/api/res/drawable-xhdpi/google_g_standard_color.png
new file mode 100644
index 0000000..94ce6e8
Binary files /dev/null and b/api/res/drawable-xhdpi/google_g_standard_color.png differ
diff --git a/api/res/drawable-xxhdpi/google_g_standard_color.png b/api/res/drawable-xxhdpi/google_g_standard_color.png
new file mode 100644
index 0000000..156a807
Binary files /dev/null and b/api/res/drawable-xxhdpi/google_g_standard_color.png differ
diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
index 7f442ae..b6ad130 100644
--- a/api/res/values/strings.xml
+++ b/api/res/values/strings.xml
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <string name="provider_picker_activity_label">Credential provider picker</string>
+    <string name="provider_picker_google_provider_name" translatable="false">Google Smart Lock</string>
 
     <string name="possibly_unsafe">Possibly unsafe</string>
 
     <string name="retrieve_picker_prompt">Use account from:</string>
     <string name="save_picker_prompt">Save your account with:</string>
     <string name="hint_picker_prompt">Use account details stored in:</string>
     <string name="delete_picker_prompt">Delete credential from:</string>
 </resources>
\ No newline at end of file

commit 5ce21b5724a220d06f454a182ef83a77b65c25d3
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 27 13:37:54 2017 -0700

    README formating fix

diff --git a/api/README.md b/api/README.md
index ff0710a..4e03bd4 100644
--- a/api/README.md
+++ b/api/README.md
@@ -1,6 +1,6 @@
 # OpenYOLO for Android - Programmatic Credential API
 
 <div align="center">
   <img src="https://user-images.githubusercontent.com/445775/30930082-60d21ace-a375-11e7-90cf-cc75fe5747fd.gif"/>
-  <em>Example of auto sign-in</em>
+  <p><em>Example of auto sign-in</em></p>
 </div>

commit 8ac73fa1cf839739815e58c53b0e6a2d980daf02
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 27 13:07:06 2017 -0700

    Added gif example of auto sign in

diff --git a/api/README.md b/api/README.md
index 20be524..ff0710a 100644
--- a/api/README.md
+++ b/api/README.md
@@ -2,2 +2,7 @@
 
+<div align="center">
+  <img src="https://user-images.githubusercontent.com/445775/30930082-60d21ace-a375-11e7-90cf-cc75fe5747fd.gif"/>
+  <em>Example of auto sign-in</em>
+</div>
+
 This is an open-source library for the OpenYOLO for Android protocol. It allows you to easily

commit e7f3f81b8b879b6787bd4372c75ef436de1b827b
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 27 09:36:45 2017 -0700

    Moved KnownProviders into the internal package. (#93)

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 5fb15cb..1d7cda1 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -44,2 +44,3 @@ import org.openyolo.api.internal.CredentialRetrieveActivity;
 import org.openyolo.api.internal.FinishWithResultActivity;
+import org.openyolo.api.internal.KnownProviders;
 import org.openyolo.api.internal.ProviderPickerActivity;
diff --git a/api/java/org/openyolo/api/KnownProviders.java b/api/java/org/openyolo/api/internal/KnownProviders.java
similarity index 97%
rename from api/java/org/openyolo/api/KnownProviders.java
rename to api/java/org/openyolo/api/internal/KnownProviders.java
index 5b66c97..45c1831 100644
--- a/api/java/org/openyolo/api/KnownProviders.java
+++ b/api/java/org/openyolo/api/internal/KnownProviders.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api;
+package org.openyolo.api.internal;
 
@@ -26,170 +26,170 @@ import org.openyolo.protocol.AuthenticationDomain;
 /**
  * Manages a list of known providers, identified by their package name and a hash of their
  * signing certificate. This class will attempt to dynamically retrieve a list of known providers
  * from openyolo.org if possible, otherwise it will fall back to the list of known providers at
  * compile time.
  */
 public class KnownProviders {
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.dashlane.com">Dashlane</a>.
      */
     public static final AuthenticationDomain DASHLANE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
                     + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
                     + "@com.dashlane");
 
     /**
      * The known package name and certificate hash for Google's
      * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
      * Smart Lock for Passwords</a>.
      */
     public static final AuthenticationDomain GOOGLE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
                     + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
                     + "@com.google.android.gms");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://keepersecurity.com/">Keeper</a>.
      */
     public static final AuthenticationDomain KEEPER_PROVIDER =
             new AuthenticationDomain("android://"
                     + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
                     + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
                     + "@com.callpod.android_apps.keeper");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.lastpass.com/">LastPass</a>.
      */
     public static final AuthenticationDomain LASTPASS_PROVIDER =
             new AuthenticationDomain("android://"
                     + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
                     + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
                     + "@com.lastpass.lpandroid");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://1password.com/">1Password</a>.
      */
     public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
             new AuthenticationDomain("android://"
                     + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
                     + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
                     + "@com.agilebits.onepassword");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.roboform.com/">Roboform</a>.
      */
     public static final AuthenticationDomain ROBOFORM_PROVIDER =
             new AuthenticationDomain("android://"
                     + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
                     + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
                     + "@com.siber.roboform");
 
     /**
      * The list of known providers at the time this library was compiled.
      */
     public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
             Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
                     DASHLANE_PROVIDER,
                     GOOGLE_PROVIDER,
                     KEEPER_PROVIDER,
                     LASTPASS_PROVIDER,
                     ONEPASSWORD_PROVIDER,
                     ROBOFORM_PROVIDER
             )));
 
     private static final AtomicReference<KnownProviders> INSTANCE_REF =
             new AtomicReference<>();
 
     /**
      * Retrieves the singleton instance of the known provider list.
      */
     public static KnownProviders getInstance(Context context) {
         KnownProviders providers = new KnownProviders(context);
         if (!INSTANCE_REF.compareAndSet(null, providers)) {
             providers = INSTANCE_REF.get();
         }
 
         return providers;
     }
 
     /**
      * FOR TESTING ONLY - Overrides the KnownProvider instance. It is *strongly discouraged*
      * to use this method in anything other than unit tests, as it can compromise the security
      * of your app and the user's credentials.
      */
     @VisibleForTesting
-    static void setApplicationBoundInstance(KnownProviders instance) {
+    public static void setApplicationBoundInstance(KnownProviders instance) {
         INSTANCE_REF.set(instance);
     }
 
     /**
      * FOR TESTING ONLY - Clears the current instance of KnownProvider.
      */
     @VisibleForTesting
-    static void clearApplicationBoundInstance() {
+    public static void clearApplicationBoundInstance() {
         INSTANCE_REF.set(null);
     }
 
     private final Context mApplicationContext;
     private Set<AuthenticationDomain> mKnownProviders;
 
     private KnownProviders(Context context) {
         mApplicationContext = context.getApplicationContext();
 
         // TODO: implement dynamic retrieval of known providers from
         // https://www.openyolo.org/known-providers
         // and fall back to the static list only if this fails
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     public Set<AuthenticationDomain> getKnownProviders() {
         return new HashSet<>(mKnownProviders);
     }
 
     /**
      * Determines whether the application with the specified package name (if installed) is
      * on the known provider list.
      */
     public boolean isKnown(String packageName) {
         AuthenticationDomain authDomain =
                 AuthenticationDomain.fromPackageName(mApplicationContext, packageName);
         if (null == authDomain) {
             return false;
         }
 
         return mKnownProviders.contains(authDomain);
     }
 
     /**
      * Reset the list of known providers to the default provider set. If possible, this will be
      * dynamically updated with a list retrieved from openyolo.org.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void resetKnownProvidersToDefault() {
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     /**
      * Adds a provider to the known provider list.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void addKnownProvider(AuthenticationDomain provider) {
         HashSet<AuthenticationDomain> knownProviders = new HashSet<>(mKnownProviders);
         knownProviders.add(provider);
         mKnownProviders = Collections.unmodifiableSet(knownProviders);
     }
 }
diff --git a/api/java/org/openyolo/api/internal/ProviderPickerActivity.java b/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
index e280eea..52508c2 100644
--- a/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
@@ -43,3 +43,2 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.api.KnownProviders;
 import org.openyolo.api.R;
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 60adca7..ae03bf3 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -42,2 +42,3 @@ import org.mockito.MockitoAnnotations;
 import org.openyolo.api.internal.FinishWithResultActivity;
+import org.openyolo.api.internal.KnownProviders;
 import org.openyolo.api.persistence.AppSettings;
diff --git a/api/javatests/org/openyolo/api/KnownProvidersTest.java b/api/javatests/org/openyolo/api/internal/KnownProvidersTest.java
similarity index 99%
rename from api/javatests/org/openyolo/api/KnownProvidersTest.java
rename to api/javatests/org/openyolo/api/internal/KnownProvidersTest.java
index d324ece..ee17296 100644
--- a/api/javatests/org/openyolo/api/KnownProvidersTest.java
+++ b/api/javatests/org/openyolo/api/internal/KnownProvidersTest.java
@@ -17,3 +17,3 @@
 
-package org.openyolo.api;
+package org.openyolo.api.internal;
 

commit 8e3d22f9db18b7b3cbfe3080f456d3c24220b5c8
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue Sep 26 15:10:52 2017 -0700

    Documentation pass on API module. (#91)

diff --git a/api/README.md b/api/README.md
new file mode 100644
index 0000000..20be524
--- /dev/null
+++ b/api/README.md
@@ -0,0 +1,207 @@
+# OpenYOLO for Android - Programmatic Credential API
+
+This is an open-source library for the OpenYOLO for Android protocol. It allows you to easily
+manipulate credentials for your application by interacting with the credential provider of the
+user's choice. This allows you to:
+
+1. Automatically sign users into your app using saved credentials.
+1. Rapidly on-board new users by bootstrapping off of existing identities.
+1. Prompt users after sign-in/sign up to save their credentials for future automatic sign in.
+
+## Installation
+As a pre-requisite, you will need to add the OpenYOLO Api as a dependency. For example, if your
+project uses Gradle:
+
+```groovy
+dependencies {
+    // ...
+    compile 'com.openyolo:api:xxx'
+}
+```
+
+## Terminology
+
+ - [Authentication Method](https://spec.openyolo.org/openyolo-android-spec.html#authentication-methods):
+An authentication method is a mechanism by which a credential can be verified. It is represented as
+a URI of the form ```scheme://authority```. For example OpenYOLO defines several common types such
+as ``openyolo://email`` and ```openyolo://phone```.  When requesting a credential or hint your
+application will declare which authentication methods it supports.
+ - [Authentication Domain](https://spec.openyolo.org/openyolo-android-spec.html#authentication-domains):
+An authentication domain is the scope in which a credential is considered to be usable. A domain
+spans a single Android application or web address. If your authentication system does not span
+multiple domains you can safely ignore this concept as a client. However, if your application offers
+both an app and web app you can prove this relationship to credential providers to allow credentials
+to be shared between the two. ```TOOD(dxslly): Add guide for linking authentication domains.```
+
+## Usage
+
+The entry point is the ```CredentialClient``` class. It is a light weight client that can be created
+as needed and offers methods to perform all standard flows. The majority of flows follow the pattern
+of sending requests via launching Activity based intents and optionally handling their results via
+the ```onActivityResult()``` call back.
+
+A typical sequence of flows for sign-in might looks as follows:
+1. Auto Sign-In: Attempt to auto sign in the user, by retrieving a saved credential.
+1. Account Creation: If no credential was found and the user is interested in signing in, assist in
+account creation by retrieving a hint.
+1. Save valid credential: If the user was successfully signed in, save the credential for future
+retrieve calls.
+1. Delete stale credential: If a retrieved credential is no longer valid, delete the credential so
+it will not be returned in future retrieve calls.
+
+### Auto Sign-In
+
+It is recommended to always try to automatically Sign-In the user first.  This is done by crafting a
+```CredentialRetrieveRequest``` listing the Authentication Methods your application supports (e.g.
+```AuthenticationMethods.EMAIL``` if your app uses email based identifier and optionally a
+password).
+
+```java
+CredentialClient client = CredentialClient.getInstance(getContext());
+
+CredentialRetrieveRequest request  =
+    CredentialRetrieveRequest.fromAuthMethods(
+        AuthenticationMethods.EMAIL,
+        AuthenticationMethods.GOOGLE);
+Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
+startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
+```
+
+Receive the results and check if a credential was returned:
+1. If a credential was returned, attempt to sign-in using your own authentication system. If the
+credential was not valid (ie. it failed to authenticate the user), delete the credential.
+1. If no credential was returned it is recommended to try to assist the user with account creation
+unless the result code specifies the user does not wish to. Notable result codes that indicate the
+user wants to branch away from assisted account creation are:
+    - USER_CANCELED: Indicates the user does not want to authenticate at this time. It is
+      recommended to eject from the sign-in process at this point.
+    - USER_REQUESTS_MANUAL_AUTH: Indicates the user wants to authenticate manually. It is
+      recommended to drop out of these assisted/automatic flows at this point.
+
+```java
+@Override
+public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
+    if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+       CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
+       if (result.isSuccessful()) {
+           // A credential was retrieved, you may automatically sign the user in.
+           result.getCredential();
+       } else {
+           // A credential was not retrieved, you may look at the result code to determine why
+           // and decide what step to take next. For example, result code may inform you of the
+           // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
+           result.getResultCode();
+       }
+    }
+}
+```
+
+### Account Creation
+
+If the user could not be automatically signed-in, assisting with account creation is the next
+recommended step. This request is very similar to the credential retrieval request, requiring you to
+list the Authentication Methods your application supports.
+
+```java
+CredentialClient client = CredentialClient.getInstance(getContext());
+
+HintRetrieveRequest request  =
+    HintRetrieveRequest.fromAuthMethods(
+        AuthenticationMethods.EMAIL,
+        AuthenticationMethods.GOOGLE);
+Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
+startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
+```
+
+Receive the results and check if a hint was returned:
+1. If a hint was returned, it is recommended to check if an account with a matching identifier
+   already exists and intelligently switch to a log-in flow. If no existing account matches there
+   are several branches of actions your app may want to take:
+    1. If enough information is present, you may automatically create a new account for the user.
+       The amount of information required will depend on the authentication method and personal
+       requirements.
+    1. If more information is needed to create an account, it is recommended to use the given
+       information to skip manual entry and have the user finish account creation manually.
+1. If a hint was not returned, it is recommended to fallback to manual account creation unless the
+   result code specifies the user does not wish to. A result code of ```USER_CANCELED``` indicates
+   the user does not wish to authenticate at this time.
+   
+Once the account has been created you should save the credential for future retrieve calls.
+
+```java
+public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
+    if (RC_RETRIEVE_HINT == requestCode) {
+       HintRetrieveResult result = client.getHintRetrieveResult(data);
+       if (result.isSuccessful()) {
+         // A hint was retrieved, you may be able to automatically create an account for the
+         // user, or offer the user to sign in if an existing account matches the hint.
+         result.getHint();
+       } else {
+         // A credential was not retrieved, you may look at the result code to determine why
+         // and decide what step to take next. For example, result code may inform you of the
+         // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
+         result.getResultCode();
+       }
+    }
+}
+```
+
+### Saving Valid Credentials
+
+When ever a valid credential is changed or created (e.g. a manual password change, or a new account
+is created) it is recommended that you save the new or updated credential to enable a future
+automatic sign-in experience.
+
+```java
+// Craft the valid credential.
+String identifer = "joe@gmail.com";
+AuthenticationMethod authMethod = AuthenticationMethods.EMAIL;
+AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(this);
+Credential credential = new Credential.Builder(identifier, authMethod, authDomain).build();
+
+// Or if you have created an account using a hint there is a utility method that will convert the
+// hint into a new Credential.Builder.
+Credential credential = hint.toCredentialBuilder(this).build();
+
+// Send the request. It is safe to ignore the result.
+Intent saveCredentialIntent = client.getSaveIntent(credential);
+startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
+```
+
+### Deleting Invalid Credentials
+
+If a retrieved credential turns out to be invalid it is recommended that you delete the credential.
+
+```java
+// Send the request. It is safe to ignore the result.
+Intent deleteCredentialIntent = client.getDeleteIntent(credential);
+startActivityForResult(deleteCredentialIntent, RC_DELETE_CREDENTIAL);
+```
+
+
+### Signing Out
+
+There is a common pitfall when implementing account sign-in/sign-out where an application will
+automatically sign-in a user after they have just signed out when the user's intention was likely to
+either remain signed out or switch to a new account. To resolve this, some state needs to be added
+for tracking the user's previous intent and prevent the user from being automatically signed in
+again.
+
+The ```CredentialClient.disableAutoSignIn()``` offers a simple way to handle this case. Once called
+it will require the user to mediate auto sign-in requests until a successful request is fulfilled.
+It is recommended you call this method whenever a user is signed out of your application. 
+
+```java
+public void signOutUser() {
+    // Your application's custom sign out logic.
+    // ...
+    CredentialClient client = CredentialClient.getInstance(getContext());
+    client.disableAutoSignIn();
+}
+```
+
+## Testing against providers
+
+// TODO(dxslly): Describe how to test in the wild, enumerate production implementations?
diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 2d0b80d..5fb15cb 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -57,475 +57,659 @@ import org.openyolo.protocol.HintRetrieveResult;
 import org.openyolo.protocol.MalformedDataException;
 
 
 /**
  * The primary way of interacting with OpenYOLO credential providers. The client is light weight
  * allowing new instances to be created as needed.
  *
  * Requests are executed by starting an Activity based intent and its result returned via
  * {@link android.app.Activity#onActivityResult(int, int, Intent)}. For each request/response pair
  * there exist two client methods:
  * 1) Takes a given request and returns the Activity Intent which sends the request.
  * 2) Takes an Intent returned via {@link android.app.Activity#onActivityResult(int, int, Intent)}
  *    and returns the associated result.
  *
- * For example using the hint flow:
+ * For example using the retrieve credential flow:
  * <pre>{@code
- * CredentialClient client = CredentialClient.getInstance(this);
- * HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
- *
- * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
- * startActivityForResult(retrieveHintIntent, RC_HINT);
+ * CredentialClient client = CredentialClient.getInstance(getContext());
  * // ...
  *
+ * CredentialRetrieveRequest request  =
+ *     CredentialRetrieveRequest.fromAuthMethods(
+ *         AuthenticationMethods.EMAIL,
+ *         AuthenticationMethods.GOOGLE);
+ * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
+ * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
+ *
+ * // ...
  * @Override
  * public void onActivityResult(int requestCode, int resultCode, Intent data) {
  *     super.onActivityResult(requestCode, resultCode, data);
+ *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+ *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
+ *        // handle result ...
+ *     }
+ * }
+ * }</pre>
  *
- *     HintRetrieveResult result = client.getHintRetrieveResult(data);
- * }}</pre>
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#operations">
  *     OpenYOLO Specification: Operations</a>
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private final Context mApplicationContext;
     private final AppSettings mDeviceState;
 
     /**
      * Returns a new credential client instance configured with the default options.
      */
     public static CredentialClient getInstance(@NonNull Context context) {
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(AppSettingsImpl.getInstance(context)).build();
 
         return getInstance(context, options);
     }
 
     /**
      * Returns a new credential client instance configured with the given
      * {@link CredentialClientOptions}.
      */
     public static CredentialClient getInstance(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         return new CredentialClient(context, options);
     }
 
     @VisibleForTesting
     CredentialClient(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         validate(context, notNullValue(), NullPointerException.class);
         validate(options, notNullValue(), NullPointerException.class);
 
         mApplicationContext = context.getApplicationContext();
         mDeviceState = options.getDeviceState();
     }
 
     /**
-     * Provides an Activity intent to request any available credentials from the credential
-     * providers on the device.
+     * Provides an Activity intent to request any available {@link Credential credentials} from the
+     * credential providers on the device.
      *
      * Launch the returned intent via
      * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
      * {@link #getCredentialRetrieveResult(Intent)} using the Intent data received in the associated
      * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
      *
      * <pre>{@code
      * CredentialClient client = CredentialClient.getInstance(getContext());
      * // ...
      *
      * CredentialRetrieveRequest request  =
-     *     CredentialRetrieveRequest.of(AuthenticationMethods.EMAIL, AuthenticationMethods.GOOGLE);
+     *     CredentialRetrieveRequest.fromAuthMethods(
+     *         AuthenticationMethods.EMAIL,
+     *         AuthenticationMethods.GOOGLE);
      * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
      * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
      *
      * // ...
      * @Override
      * public void onActivityResult(int requestCode, int resultCode, Intent data) {
      *     super.onActivityResult(requestCode, resultCode, data);
      *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
      *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
      *        // handle result ...
      *     }
      * }
      * }</pre>
      *
      * @see #getCredentialRetrieveResult(Intent)
      */
+    @NonNull
     public Intent getCredentialRetrieveIntent(CredentialRetrieveRequest request) {
         if (mDeviceState.isAutoSignInDisabled()) {
             request = new CredentialRetrieveRequest.Builder(request)
                     .setRequireUserMediation(true)
                     .build();
         }
 
         return CredentialRetrieveActivity.createIntent(mApplicationContext, request);
     }
 
     /**
-     * Provides an intent to request a login hint. This will target the user's preferred credential
-     * provider, if this can be determined.
+     * Provides an Activity intent to request any available {@link org.openyolo.protocol.Hint hints}
+     * from the credential providers on the device.
+     *
+     * Launch the returned intent via
+     * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
+     * {@link #getHintRetrieveResult(Intent)} using the Intent data received in the associated
+     * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     * // ...
+     *
+     * HintRetrieveRequest request  =
+     *     HintRetrieveRequest.fromAuthMethods(
+     *         AuthenticationMethods.EMAIL,
+     *         AuthenticationMethods.GOOGLE);
+     * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
+     * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_HINT);
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_RETRIEVE_HINT == requestCode) {
+     *        HintRetrieveResult result = client.getHintRetrieveResult(data);
+     *        // handle result ...
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getHintRetrieveResult(Intent)
      */
+    @NonNull
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE,
                     HintRetrieveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
-     * Provides an intent to save the provided credential. If no compatible credential providers
-     * exist on the device, {@code null} will be returned. The intent should be started with a
-     * call to
-     * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
+     * Creates a {@link CredentialSaveRequest request} from the given credential.
+     *
+     * @see #getSaveIntent(Credential)
+     */
+    @NonNull
+    public Intent getSaveIntent(final Credential credential) {
+        return getSaveIntent(CredentialSaveRequest.fromCredential(credential));
+    }
+
+    /**
+     * Provides an Activity intent to save the provided credential.
+     *
+     * Launch the returned intent via
+     * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
+     * {@link #getCredentialSaveResult(Intent)} using the Intent data received in the associated
+     * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     * Credential credential = <Valid Credential>;
+     * // ...
      *
-     * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
-     * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
+     * CredentialSaveRequest request  = CredentialSaveRequest.fromCredential(credential);
+     * Intent saveCredentialIntent = client.getSaveIntent(request);
+     * startActivityForResult(saveCredentialIntent, RC_SAVE_CREDENTIAL);
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_SAVE_CREDENTIAL == requestCode) {
+     *        CredentialSaveResult result = client.getCredentialSaveResult(data);
+     *        // handle result ...
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getCredentialSaveResult(Intent)
      */
+    @NonNull
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     CredentialSaveResult.CODE_NO_PROVIDER_AVAILABLE,
                     CredentialSaveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
-     * Provides an intent to delete a credential. If no compatible credential providers exist
-     * on the device, {@code null} will be returned. The intent should be started with a call
-     * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
+     * Creates a {@link CredentialDeleteRequest request} from the given credential.
+     *
+     * @see #getDeleteIntent(CredentialDeleteRequest)
+     */
+    @NonNull
+    public Intent getDeleteIntent(@NonNull Credential credential) {
+        require(credential, notNullValue());
+
+        return getDeleteIntent(CredentialDeleteRequest.fromCredential(credential));
+    }
+
+    /**
+     * Provides an Activity intent to delete the given {@link Credential credential} from the
+     * credential provider on the device.
+     *
+     * Launch the returned intent via
+     * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
+     * {@link #getDeleteResult(Intent)} using the Intent data received in the associated
+     * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     * Credential credential = <Credential that is no longer valid>;
+     * // ...
+     *
+     * Intent deleteCredentialIntent = client.getDeleteIntent(request);
+     * startActivityForResult(deleteCredentialIntent, RC_DELETE_CREDENTIAL);
      *
-     * <p>Upon completion of the request, the result data will be returned in the Intent passed
-     * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
-     * can be extracted by calling {@link #getDeleteResult(Intent)}.
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_DELETE_CREDENTIAL == requestCode) {
+     *         result = client.getDeleteResult(data);
+     *        // handle result ...
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getDeleteResult(Intent)
      */
-    public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
-        require(credentialToDelete, notNullValue());
+    @NonNull
+    public Intent getDeleteIntent(@NonNull CredentialDeleteRequest request) {
+        require(request, notNullValue());
+
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             ActivityResult result = ActivityResult.of(
                     CredentialDeleteResult.CODE_NO_PROVIDER_AVAILABLE,
                     CredentialDeleteResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
 
             return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
-        CredentialDeleteRequest request =
-                new CredentialDeleteRequest.Builder(credentialToDelete).build();
-
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
-     * Extracts a credential from the data returned via
-     * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
-     * after a credential retrieve intent completes.
+     * Returns the result of a {@link CredentialRetrieveResult}.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+     *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
+     *        if (result.isSuccessful()) {
+     *          // A credential was retrieved, you may automatically sign the user in.
+     *          result.getCredential();
+     *        } else {
+     *          // A credential was not retrieved, you may look at the result code to determine why
+     *          // and decide what step to take next. For example, result code may inform you of the
+     *          // user's intent such as CredentialRetrieveResult.CODE_USER_CANCELED.
+     *          result.getResultCode();
+     *        }
+     *     }
+     * }
+     * }</pre>
+     *
+     *
+     * @see #getCredentialRetrieveIntent(CredentialRetrieveRequest)
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
-            return createDefaultCredentialRetrieveResult();
+            return CredentialRetrieveResult.UNKNOWN;
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
-            return createDefaultCredentialRetrieveResult();
+            return CredentialRetrieveResult.UNKNOWN;
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
-            return createDefaultCredentialRetrieveResult();
+            return CredentialRetrieveResult.UNKNOWN;
         }
 
         try {
             CredentialRetrieveResult result =
                     CredentialRetrieveResult.fromProtobufBytes(resultBytes);
 
             // Once a successfully retrieve result has been handled, re-enable auto sign-in.
             if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
                 mDeviceState.setIsAutoSignInDisabled(false);
             }
 
             return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
-            return createDefaultCredentialRetrieveResult();
+            return CredentialRetrieveResult.UNKNOWN;
         }
     }
 
     /**
-     * Extracts the result of a hint retrieve request from the intent data returned by a provider.
+     * Returns the result of a {@link HintRetrieveResult}.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_RETRIEVE_HINT == requestCode) {
+     *        HintRetrieveResult result = client.getHintRetrieveResult(data);
+     *        if (result.isSuccessful()) {
+     *          // A hint was retrieved, you may be able to automatically create an account for the
+     *          // user, or offer the user to sign in if an existing account matches the hint.
+     *          result.getHint();
+     *        } else {
+     *          // A credential was not retrieved, you may look at the result code to determine why
+     *          // and decide what step to take next. For example, result code may inform you of the
+     *          // user's intent such as HintRetrieveResult.CODE_USER_CANCELED.
+     *          result.getResultCode();
+     *        }
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getHintRetrieveIntent(HintRetrieveRequest)
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
-            return createDefaultHintRetrieveResult();
+            return HintRetrieveResult.UNKNOWN;
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
-            return createDefaultHintRetrieveResult();
+            return HintRetrieveResult.UNKNOWN;
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
-            return createDefaultHintRetrieveResult();
+            return HintRetrieveResult.UNKNOWN;
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
-            return createDefaultHintRetrieveResult();
+            return HintRetrieveResult.UNKNOWN;
         }
     }
 
     /**
-     * Extracts the result of a credential save request from the intent data returned by a provider.
+     * Returns the result of a {@link CredentialSaveRequest}.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_SAVE_CREDENTIAL == requestCode) {
+     *        CredentialSaveResult result = client.getCredentialSaveResult(data);
+     *        // Most people will not need to check the result of a save request. Simply fire and
+     *        // forget.
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getSaveIntent(CredentialSaveRequest)
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
-            return createDefaultCredentialSaveResult();
+            return CredentialSaveResult.UNKNOWN;
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
-            return createDefaultCredentialSaveResult();
+            return CredentialSaveResult.UNKNOWN;
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
-            return createDefaultCredentialSaveResult();
+            return CredentialSaveResult.UNKNOWN;
         }
     }
 
     /**
-     * Disables automatically signing a user until a successful response is given to
-     * {@link CredentialClient#getCredentialRetrieveResult(Intent)}.
-     */
-    public void disableAutoSignIn() {
-        mDeviceState.setIsAutoSignInDisabled(true);
-    }
-
-    @NonNull
-    private static CredentialSaveResult createDefaultCredentialSaveResult() {
-        return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
-                .build();
-    }
-
-    /**
-     * Extracts the result of a credential deletion request from the intent data returned by
-     * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
-     * is returned.
+     * Returns the result of a {@link CredentialDeleteRequest}.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_DELETE_CREDENTIAL == requestCode) {
+     *        CredentialSaveResult result = client.getCredentialSaveResult(data);
+     *        // Most people will not need to check the result of a delete request. Simply fire and
+     *        // forget.
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getDeleteIntent(CredentialDeleteRequest)
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
-    @NonNull
-    private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
-        return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
-                .build();
-    }
-
-    @NonNull
-    private static HintRetrieveResult createDefaultHintRetrieveResult() {
-        return HintRetrieveResult.UNKNOWN;
+    /**
+     * Disables automatically signing in a user until a successful response is given to
+     * {@link CredentialClient#getCredentialRetrieveResult(Intent)}. Instead a user is required to
+     * interact with the providers (e.g. click the credential they would like to sign in) before a
+     * credential is returned.
+     *
+     * This feature allows clients to easily avoid a common case where a user signs out and is then
+     * automatically signed back in. By calling this method when a user is signed out no additional
+     * logic to track the user's intention is required.
+     * <pre>{@code
+     *
+     * // ...
+     * public void signOutUser() {
+     *     // Your application's custom sign out logic.
+     *     // ...
+     *     CredentialClient client = CredentialClient.getInstance(getContext());
+     *     client.disableAutoSignIn();
+     * }
+     * }</pre>
+     */
+    public void disableAutoSignIn() {
+        mDeviceState.setIsAutoSignInDisabled(true);
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 }
diff --git a/api/java/org/openyolo/api/CredentialClientOptions.java b/api/java/org/openyolo/api/CredentialClientOptions.java
index c42175b..4410198 100644
--- a/api/java/org/openyolo/api/CredentialClientOptions.java
+++ b/api/java/org/openyolo/api/CredentialClientOptions.java
@@ -19,2 +19,3 @@ import static org.valid4j.Validation.validate;
 
+import android.content.Context;
 import android.support.annotation.NonNull;
@@ -22,6 +23,7 @@ import android.support.annotation.NonNull;
 import org.openyolo.api.persistence.AppSettings;
 
 
 /**
- * Context object that may be used to configure a {@link CredentialClient} instance.
+ * Context object that may be used to configure a {@link CredentialClient} instance. It is
+ * recommended to use the default options via {@link CredentialClient#getInstance(Context)}.
  */
diff --git a/api/java/org/openyolo/api/ResultCallback.java b/api/java/org/openyolo/api/ResultCallback.java
deleted file mode 100644
index a5ca480..0000000
--- a/api/java/org/openyolo/api/ResultCallback.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api;
-
-/**
- * A callback handler for asynchronous call completion.
- * @param <ResultT> The type of value returned when the operation completes normally.
- * @param <ErrorT> The type of value returned when the operation fails unexpectedly.
- */
-public interface ResultCallback<ResultT, ErrorT> {
-    /**
-     * Handles the result. If {@code error} has a non-null value, the operation failed.
-     */
-    void onComplete(ResultT result, ErrorT error);
-}
diff --git a/api/java/org/openyolo/api/RetrieveCallback.java b/api/java/org/openyolo/api/RetrieveCallback.java
deleted file mode 100644
index 8a1d606..0000000
--- a/api/java/org/openyolo/api/RetrieveCallback.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api;
-
-import org.openyolo.protocol.RetrieveBbqResponse;
-
-/**
- * Asynchronous callback type for credential retrieval.
- */
-public interface RetrieveCallback extends ResultCallback<RetrieveBbqResponse, Throwable> {}
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index b322513..60adca7 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -59,385 +59,385 @@ import org.robolectric.shadows.ShadowActivity;
 /**
  * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
 
     private static final HintRetrieveRequest EMAIL_HINT_REQUEST =
-            HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
+            HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL);
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     @Mock
     private AppSettings mockDeviceState;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(mockDeviceState).build();
         credentialClient = new CredentialClient(mockContext, options);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void getInstance_returnsNonNull() throws Exception {
         CredentialClient test = CredentialClient.getInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getHintRetrieveIntent_noAvailableProviders_finishesWithNoAvailableProviders() {
         Intent intent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         ShadowActivity activity = startFinishWithResultActivity(intent);
 
         assertThat(activity.isFinishing()).isTrue();
         assertThat(activity.getResultCode())
                 .isEqualTo(HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE);
 
         HintRetrieveResult result =
                 credentialClient.getHintRetrieveResult(activity.getResultIntent());
         assertThat(result.getResultCode())
                 .isEqualTo(HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(null /* intent*/);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
         final Intent intent = new Intent();
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
         final Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_validResult_returnsResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(
                         CredentialSaveResult.SAVED.toResultDataIntent());
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialRetrieveResult_withErrorResult_returnsErrorResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verifyNoMoreInteractions(mockDeviceState);
     }
 
     @Test
     public void getCredentialRetrieveResult_withSuccessfulResult_returnsSuccessfulResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verify(mockDeviceState).setIsAutoSignInDisabled(eq(false));
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ShadowActivity startFinishWithResultActivity(Intent intent) {
         return Shadows.shadowOf(
                 Robolectric.buildActivity(FinishWithResultActivity.class, intent).create().get());
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index 2acec0b..d40e598 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -50,445 +50,445 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
     private static final int MIN_PASSWORD_LENGTH = 4;
 
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
     public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
     public final ObservableBoolean showError = new ObservableBoolean(false);
 
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
     private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
         mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
         mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
             mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
      * Initiates an OpenYOLO credential retrieval request.
      */
     private void tryRetrieveExistingCredential() {
         setShowLoading(R.string.existing_account_search_prompt);
         Intent intent =
                 mCredentialClient.getCredentialRetrieveIntent(
                         CredentialRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL));
         mNavigator.get().startOpenYoloRetrieve(intent);
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
                 boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
                         credential.getPassword());
                 if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.of(AuthenticationMethods.EMAIL));
+                HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL));
 
         if (hintIntent != null) {
             setShowLoading(R.string.requesting_hint_prompt);
             mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
                         hint.getDisplayPicture());
                 String hintPassword = hint.getGeneratedPassword();
 
 
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
                 boolean authenticated = false;
 
                 if (hintPassword != null) {
                     authenticated = mUserDataSource.createPasswordAccount(
                             hintEmail, displayName, displayPicture, hintPassword);
 
                     if (authenticated) {
                         // account created, attempt to save it back to the OpenYOLO provider
                         trySaveCredential(hint.toCredentialBuilder(mApplication).build());
                     }
                 }
 
                 if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
 
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
     public void signInButtonClicked(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
         if (userPassword.length() < MIN_PASSWORD_LENGTH) {
             passwordError.set(getResourceString(R.string.error_password_too_short));
             return;
         } else {
             emailError.set("");
         }
 
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
                     null, // name
                     null, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 showError.set(true);
             }
         }
     }
 
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
             mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
         mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
         mNavigator.get().goToMain();
     }
 
     private void setShowLoading(@StringRes int loadingLabelId) {
         setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
     private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
         showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
         showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index bf6a540..5b9f148 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -35,159 +35,166 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
  *     OpenYOLO Specification: Credential Deletion</a>
  */
 public final class CredentialDeleteRequest {
 
+    /**
+     * Returns a deletion request for the given credential.
+     */
+    public static CredentialDeleteRequest fromCredential(Credential credential) {
+        return new Builder(credential).build();
+    }
+
     /**
      * Creates a credential deletion request from its protocol buffer equivalent, in byte array
      * form.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static CredentialDeleteRequest fromProtobufBytes(@NonNull byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException("unable to parse credential deletion request", ex);
         }
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     public static CredentialDeleteRequest fromProtobuf(
             @NonNull Protobufs.CredentialDeleteRequest proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new Builder(proto).build();
     }
 
 
     /**
      * Extracts a credential deletion request from a request intent.
      * @throws MalformedDataException if the provided intent is null, is missing the byte array
      *     extra for the request, or the request contains invalid data.
      */
     public static CredentialDeleteRequest fromRequestIntent(
             @Nullable Intent requestIntent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_REQUEST,
                         Protobufs.CredentialDeleteRequest.parser(),
                         "deletion request missing or contains invalid data",
                         requestIntent));
     }
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be deleted.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties specified by the client as part of this
      * deletion request.
      */
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Converts the request to its protocol buffer equivalent.
      */
     public Protobufs.CredentialDeleteRequest toProtobuf() {
         return Protobufs.CredentialDeleteRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Creates instances of {@link CredentialDeleteRequest}.
      */
     public static final class Builder {
 
         @NonNull
         private Credential mCredential;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion request, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(Protobufs.CredentialDeleteRequest proto) throws MalformedDataException {
             try {
                 setCredential(Credential.fromProtobuf(proto.getCredential()));
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * credential object.
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be deleted. Must not be null.
          */
         public Builder setCredential(@NonNull Credential credential) {
             validate(credential, notNullValue(), IllegalArgumentException.class);
 
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(
                 @Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion request, from the specified properties.
          */
         public CredentialDeleteRequest build() {
             return new CredentialDeleteRequest(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
index fe290b3..3fe4e16 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
@@ -45,349 +45,351 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
 public class HintRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRetrieveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRetrieveRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a hint request from the given set of authentication methods.
      */
-    public static HintRetrieveRequest of(AuthenticationMethod... authenticationMethods) {
+    public static HintRetrieveRequest fromAuthMethods(
+            AuthenticationMethod... authenticationMethods) {
         return new HintRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a hint request from the given set of authentication methods.
      */
-    public static HintRetrieveRequest of(Set<AuthenticationMethod> authenticationMethods) {
+    public static HintRetrieveRequest fromAuthMethods(
+            Set<AuthenticationMethod> authenticationMethods) {
         return new HintRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws MalformedDataException {
         validate(hintRequestProtoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Reads a hint request from its protocol buffer form.
      * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtobuf(Protobufs.HintRetrieveRequest protobuf)
             throws MalformedDataException {
         validate(protobuf, notNullValue(), MalformedDataException.class);
 
         return new HintRetrieveRequest.Builder(protobuf).build();
     }
 
     private HintRetrieveRequest(@NonNull Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mPasswordSpec = builder.mPasswordSpec;
         mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The token providers supported by the requester, with the per-provider request info
      * message.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(mAdditionalProperties)
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          * @throws MalformedDataException if the given hint protocol buffer was not valid.
          *
          * @see HintRetrieveRequest#toProtocolBuffer()
          */
         private Builder(@NonNull Protobufs.HintRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
                 setPasswordSpecification(
                         PasswordSpecification.fromProtobuf(requestProto.getPasswordSpec()));
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(AuthenticationMethod... authenticationMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authenticationMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
             validate(authenticationMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             validate(passwordSpec, notNullValue(), IllegalArgumentException.class);
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRetrieveRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRetrieveRequest build() {
             return new HintRetrieveRequest(this);
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRetrieveRequest> {
         @Override
         public HintRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return HintRetrieveRequest.fromProtoBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRetrieveRequest[] newArray(int size) {
             return new HintRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index 382e1f3..ee705a6 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -31,236 +31,236 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setPasswordSpecification(originalSpec)
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
-            HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
+            HintRetrieveRequest request = HintRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL);
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
             ValidTokenProviderMap.assertEquals(read.getTokenProviders());
             ValidAdditionalProperties.assertEquals(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Set<AuthenticationMethod>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file

commit 8d292c5f14693825ecfc501083a277c24e11835a
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue Sep 26 10:19:36 2017 -0700

    Replaced Hint#getDisplayPictureUri() with Hint#getDisplayPicture() to (#92)
    
    match Credential#getDisplayPicture()

diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index 0fceb07..2acec0b 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -50,445 +50,445 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
     private static final int MIN_PASSWORD_LENGTH = 4;
 
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
     public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
     public final ObservableBoolean showError = new ObservableBoolean(false);
 
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
     private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
         mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
         mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
             mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
      * Initiates an OpenYOLO credential retrieval request.
      */
     private void tryRetrieveExistingCredential() {
         setShowLoading(R.string.existing_account_search_prompt);
         Intent intent =
                 mCredentialClient.getCredentialRetrieveIntent(
                         CredentialRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL));
         mNavigator.get().startOpenYoloRetrieve(intent);
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
                 boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
                         credential.getPassword());
                 if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.of(AuthenticationMethods.EMAIL));
 
         if (hintIntent != null) {
             setShowLoading(R.string.requesting_hint_prompt);
             mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
-                        hint.getDisplayPictureUri());
+                        hint.getDisplayPicture());
                 String hintPassword = hint.getGeneratedPassword();
 
 
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
                 boolean authenticated = false;
 
                 if (hintPassword != null) {
                     authenticated = mUserDataSource.createPasswordAccount(
                             hintEmail, displayName, displayPicture, hintPassword);
 
                     if (authenticated) {
                         // account created, attempt to save it back to the OpenYOLO provider
                         trySaveCredential(hint.toCredentialBuilder(mApplication).build());
                     }
                 }
 
                 if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
 
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
     public void signInButtonClicked(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
         if (userPassword.length() < MIN_PASSWORD_LENGTH) {
             passwordError.set(getResourceString(R.string.error_password_too_short));
             return;
         } else {
             emailError.set("");
         }
 
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
                     null, // name
                     null, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 showError.set(true);
             }
         }
     }
 
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
             mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
         mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
         mNavigator.get().goToMain();
     }
 
     private void setShowLoading(@StringRes int loadingLabelId) {
         setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
     private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
         showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
         showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
index 692d34b..607ea31 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
@@ -31,85 +31,85 @@ import org.openyolo.protocol.Hint;
 /**
  * RecyclerView holder for displaying account options to the user in a credential or hint picker.
  */
 public final class AccountViewHolder extends RecyclerView.ViewHolder {
 
     private ImageView mProfileIcon;
     private TextView mPrimaryLabel;
     private TextView mSecondaryLabel;
 
     AccountViewHolder(View itemView) {
         super(itemView);
 
         mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
         mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
         mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
     }
 
     void bind(final Credential credential, ClickHandler<Credential> clickHandler) {
         bind(
                 credential.getIdentifier(),
                 credential.getAuthenticationMethod(),
                 credential.getDisplayName(),
                 credential.getDisplayPicture(),
                 credential,
                 clickHandler);
     }
 
     void bind(final Hint hint, ClickHandler<Hint> clickHandler) {
         bind(
                 hint.getIdentifier(),
                 hint.getAuthenticationMethod(),
                 hint.getDisplayName(),
-                hint.getDisplayPictureUri(),
+                hint.getDisplayPicture(),
                 hint,
                 clickHandler);
     }
 
     <T> void bind(
             @NonNull String id,
             @NonNull AuthenticationMethod authMethod,
             @Nullable String displayName,
             @Nullable Uri profilePictureUri,
             @NonNull final T sourceObject,
             @NonNull final ClickHandler<T> clickHandler) {
 
         int iconId;
         if (AuthenticationMethods.EMAIL.equals(authMethod)) {
             iconId = R.drawable.email;
         } else if (AuthenticationMethods.PHONE.equals(authMethod)) {
             iconId = R.drawable.phone;
         } else {
             iconId = R.drawable.person;
         }
 
         if (profilePictureUri != null) {
             GlideApp.with(mProfileIcon.getContext())
                     .load(profilePictureUri)
                     .fitCenter()
                     .fallback(iconId)
                     .into(mProfileIcon);
         } else {
             mProfileIcon.setImageResource(iconId);
         }
 
         if (displayName != null) {
             mPrimaryLabel.setText(displayName);
             mSecondaryLabel.setText(id);
             mSecondaryLabel.setVisibility(View.VISIBLE);
         } else {
             mPrimaryLabel.setText(id);
             mSecondaryLabel.setVisibility(View.GONE);
         }
 
         itemView.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 clickHandler.onClick(sourceObject);
             }
         });
     }
 
     interface ClickHandler<T> {
         void onClick(T clicked);
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Hint.java b/protocol/java/org/openyolo/protocol/Hint.java
index 5722eed..0195430 100644
--- a/protocol/java/org/openyolo/protocol/Hint.java
+++ b/protocol/java/org/openyolo/protocol/Hint.java
@@ -40,386 +40,386 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a hint for use in account discovery or account creation. This provides a
  * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential protocol
  * buffer} that is returned by the provider.
  *
  * <p>Hints must have an {@link #getIdentifier() identifier} and an
  * an {@link #getAuthenticationMethod() authentication method}, but all other properties are
  * optional.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
 public final class Hint implements Parcelable {
 
     /**
      * Parcelable reader for {@link Hint} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Hint> CREATOR = new HintCreator();
 
     /**
      * Creates a hint from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static Hint fromProtobuf(Protobufs.Hint proto) throws MalformedDataException {
         return new Hint.Builder(proto).build();
     }
 
     /**
      * Creates a hint from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the protocol buffer cannot be parsed from the byte array.
      */
     public static Hint fromProtobufBytes(byte[] protoBytes) throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
         try {
             return fromProtobuf(Protobufs.Hint.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPictureUri;
 
     @Nullable
     private final String mGeneratedPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Hint(Hint.Builder builder) {
         mId = builder.mId;
         mAuthMethod = builder.mAuthMethod;
         mDisplayName = builder.mDisplayName;
         mDisplayPictureUri = builder.mDisplayPictureUri;
         mGeneratedPassword = builder.mGeneratedPassword;
         mIdToken = builder.mIdToken;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint, for transmission or storage.
      */
     public Protobufs.Hint toProtobuf() {
         Protobufs.Hint.Builder builder = Protobufs.Hint.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPictureUri != null) {
             builder.setDisplayPictureUri(mDisplayPictureUri.toString());
         }
 
         if (mGeneratedPassword != null) {
             builder.setGeneratedPassword(mGeneratedPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * Returns a {@link Credential.Builder} representation of the hint.
      */
     public Credential.Builder toCredentialBuilder(Context context) {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(context);
         return new Credential.Builder(mId, mAuthMethod, authDomain)
                 .setDisplayName(mDisplayName)
                 .setDisplayPicture(mDisplayPictureUri)
                 .setPassword(mGeneratedPassword)
                 .setIdToken(mIdToken)
                 .setAdditionalProperties(getAdditionalProperties());
     }
 
     /**
      * The hint identifier, for use in discovering an existing account within the context of the
      * authentication method and authentication domain (which is implicitly that of the requester),
      * or creating a new account.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication domain associated with the hint.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * A suggested display name for accounts created using this hint, if available.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * A suggested profile picture for accounts created using this hint. if available.
      */
     @Nullable
-    public Uri getDisplayPictureUri() {
+    public Uri getDisplayPicture() {
         return mDisplayPictureUri;
     }
 
     /**
      * A suggested password for use with accounts created using this hint, if available.
      */
     @Nullable
     public String getGeneratedPassword() {
         return mGeneratedPassword;
     }
 
     /**
      * An ID token that provides "proof of access" to the hint identifier, if available.
      * When provided this can be used either as a means of authentication in its
      * own right, or as a means to bypass manual proof of access verification, such as by sending
      * an email with a verification link or an SMS with a code.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the hint.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] hintBytes = toProtobuf().toByteArray();
         dest.writeInt(hintBytes.length);
         dest.writeByteArray(hintBytes);
     }
 
     /**
      * Creates instances of {@link Hint}.
      */
     public static final class Builder {
 
         @NonNull
         private String mId;
 
         @NonNull
         private AuthenticationMethod mAuthMethod;
 
         @Nullable
         private String mDisplayName;
 
         @Nullable
         private Uri mDisplayPictureUri;
 
         @Nullable
         private String mGeneratedPassword;
 
         @Nullable
         private String mIdToken;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull AuthenticationMethod authMethod) {
             setIdentifier(id);
             setAuthMethod(authMethod);
         }
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull String authMethod) {
             this(id, new AuthenticationMethod(authMethod));
         }
 
         /**
          * Starts the process of creating a hint using an already built hint.
          */
         public Builder(Hint hint) {
             setIdentifier(hint.mId);
             setAuthMethod(hint.mAuthMethod);
             setDisplayName(hint.mDisplayName);
             setDisplayPictureUri(hint.mDisplayPictureUri);
             setGeneratedPassword(hint.mGeneratedPassword);
             setIdToken(hint.mIdToken);
             setAdditionalPropertiesFromProto(hint.mAdditionalProps);
         }
 
         /**
          * Starts the process of creating a hint, based on the properties of the provided
          * protocol buffer representation of the credential. The protocol buffer must contain
          * valid data for a hint.
          */
         private Builder(@NonNull Protobufs.Hint proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setIdentifier(proto.getId());
                 setAuthMethod(proto.getAuthMethod().getUri());
                 setDisplayName(proto.getDisplayName());
                 setDisplayPictureUri(proto.getDisplayPictureUri());
                 setGeneratedPassword(proto.getGeneratedPassword());
                 setIdToken(proto.getIdToken());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the identifier for the hint. Must not be null or empty.
          */
         public Builder setIdentifier(@NonNull String id) {
             validate(id, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = id;
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint, in string form. Must be a valid
          * authentication method URI.
          *
          * @see AuthenticationMethod
          */
         public Builder setAuthMethod(@NonNull String authMethod) {
             validate(authMethod, isValidAuthenticationMethod(), IllegalArgumentException.class);
             mAuthMethod = new AuthenticationMethod(authMethod);
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint. Must not be null.
          */
         public Builder setAuthMethod(@NonNull AuthenticationMethod authMethod) {
             validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the display name for the hint. Empty values are treated as null.
          */
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Empty values are
          * treated as null. Non-empty values must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable String displayPictureUri) {
             setDisplayPictureUri(nullifyEmptyString(displayPictureUri) != null
                             ? Uri.parse(displayPictureUri)
                             : null);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Non-null values
          * must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable Uri displayPictureUri) {
             validate(displayPictureUri, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPictureUri = displayPictureUri;
             return this;
         }
 
         /**
          * Specifies the generated password for the hint. Empty values are treated as null.
          */
         public Builder setGeneratedPassword(@Nullable String generatedPassword) {
             mGeneratedPassword = nullifyEmptyString(generatedPassword);
             return this;
         }
 
         /**
          * Specifies the "proof of access" ID token for the hint. Empty values are treated as null.
          */
         public Builder setIdToken(@Nullable String idToken) {
             mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the hint.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 @Nullable Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the {@link Hint hint} instance with the specified properties.
          */
         public Hint build() {
             return new Hint(this);
         }
     }
 
     private static final class HintCreator implements Creator<Hint> {
 
         @Override
         public Hint createFromParcel(Parcel source) {
             int length = source.readInt();
             byte[] hintBytes = new byte[length];
             source.readByteArray(hintBytes);
             try {
                 return Hint.fromProtobufBytes(hintBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalArgumentException("Unable to parse hint from parcel", ex);
             }
         }
 
         @Override
         public Hint[] newArray(int size) {
             return new Hint[size];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintTest.java b/protocol/javatests/org/openyolo/protocol/HintTest.java
index c644853..fc7af05 100644
--- a/protocol/javatests/org/openyolo/protocol/HintTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintTest.java
@@ -33,144 +33,144 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link Hint}*/
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class HintTest {
 
     private static final String ID = "coold00d@aol.gov";
 
     Context mContext;
 
     @Before
     public void initializeMocks() throws Exception {
         mContext = TestConstants.ValidApplication.install(RuntimeEnvironment.application);
     }
 
     @Test
     public void build_withRequiredParamsOnly() {
         Hint hint = new Hint.Builder(ID, AuthenticationMethods.EMAIL).build();
 
         assertThat(hint.getIdentifier()).isEqualTo(ID);
         assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
         assertThat(hint.getDisplayName()).isNull();
-        assertThat(hint.getDisplayPictureUri()).isNull();
+        assertThat(hint.getDisplayPicture()).isNull();
         assertThat(hint.getIdToken()).isNull();
         assertThat(hint.getAdditionalProperties()).isEmpty();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullId_shouldThrowException() {
         new Hint.Builder(
                 null,// id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void build_emptyId_shouldThrowException() {
         new Hint.Builder(
                 "", // id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethod_shouldThrowException() {
         new Hint.Builder(
                 ID,
                 (AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
                 ID,
                 (String) null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void build_emptyAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
                 ID,
                 "")
                 .build();
     }
 
     @Test
     public void builderSetAdditionalProps() {
         String additionalKey = "extra";
         byte[] additionalValue = "value".getBytes();
 
         Map<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(additionalKey, additionalValue);
         Hint hint = new Hint.Builder(ValidEmailHint.make())
                 .setAdditionalProperties(additionalProps)
                 .build();
 
         assertThat(hint.getAdditionalProperties()).hasSize(1);
         assertThat(hint.getAdditionalProperties()).containsKey(additionalKey);
         assertThat(hint.getAdditionalProperties().get(additionalKey)).isEqualTo(additionalValue);
     }
 
     @Test
     public void builder_withHintContructor_isEquivalent() {
         Hint hint = new Hint.Builder(ValidEmailHint.make()).build();
 
         ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void toProtobuf_isEquivalent() {
         Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
 
         ValidEmailHint.assertEquals(proto);
     }
 
     @Test
     public void fromProtobuf_isEquivalent() throws Exception {
         Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
         Hint hint = Hint.fromProtobuf(proto);
 
         ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void fromProtobufBytes_isEquivalent() throws Exception {
         Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
         Hint hint = Hint.fromProtobufBytes(proto.toByteArray());
 
         ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void writeToAndReadFromParcel() {
         Hint hint = ValidEmailHint.make();
 
         Parcel p = Parcel.obtain();
         try {
             hint.writeToParcel(p, 0);
             p.setDataPosition(0);
             Hint readHint = Hint.CREATOR.createFromParcel(p);
 
             ValidEmailHint.assertEquals(readHint);
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void toCredentialBuilder_isEquivalent() {
         Credential credential = ValidEmailHint.make().toCredentialBuilder(mContext).build();
 
         ValidEmailHint.assertEquals(mContext, credential);
     }
 
     @Test
     public void describeContents() {
         Hint hint = ValidEmailHint.make();
         assertThat(hint.describeContents()).isEqualTo(0);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TestConstants.java b/protocol/javatests/org/openyolo/protocol/TestConstants.java
index 370b081..4e3955b 100644
--- a/protocol/javatests/org/openyolo/protocol/TestConstants.java
+++ b/protocol/javatests/org/openyolo/protocol/TestConstants.java
@@ -36,290 +36,290 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Useful constants and associated verification methods for tests.
  */
 public final class TestConstants {
 
     public static final byte[] INVALID_PROTO_BYTES =
             new byte[] { 'i', 'n', 'v', 'a', 'l', 'i', 'd' };
 
     public static final class ValidAdditionalProperties {
         private static final String ADDITIONAL_KEY = "extra";
         private static final byte[] ADDITIONAL_VALUE = "value".getBytes();
 
         public static Map<String, byte[]> make() {
             Map<String, byte[]> additionalProps = new HashMap<>();
             additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
             return additionalProps;
         }
 
         public static Map<String, ByteString> makeForProto() {
             return CollectionConverter.convertMapValues(
                     make(),
                     ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
         }
 
 
         public static void assertEquals(Map<String, byte[]> additionalProps) {
             assertThat(additionalProps).isNotNull();
             assertThat(additionalProps).hasSize(1);
             assertThat(additionalProps).containsKey(ADDITIONAL_KEY);
             assertThat(additionalProps.get(ADDITIONAL_KEY)).isEqualTo(ADDITIONAL_VALUE);
         }
 
         public static void assertEqualsForProto(Map<String, ByteString> additionalProps) {
             assertEquals(CollectionConverter.convertMapValues(
                     additionalProps,
                     ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
     }
 
     public static final class ValidTokenRequestInfo {
         private static final String CLIENT_ID = "XYZ.client.id";
         private static final String NONCE = "asdf";
 
         public static TokenRequestInfo make() {
             return new TokenRequestInfo.Builder()
                     .setClientId(CLIENT_ID)
                     .setNonce(NONCE)
                     .setAdditionalProperties(ValidAdditionalProperties.make())
                     .build();
         }
 
         public static void assertEquals(TokenRequestInfo info) {
             assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
             assertThat(info.getNonce()).isEqualTo(NONCE);
             ValidAdditionalProperties.assertEquals(info.getAdditionalProperties());
         }
 
         public static void assertEquals(Protobufs.TokenRequestInfo info) {
             assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
             assertThat(info.getNonce()).isEqualTo(NONCE);
             ValidAdditionalProperties.assertEqualsForProto(info.getAdditionalPropsMap());
         }
 
     }
 
     public static final class ValidTokenProviderMap {
         private static final String TOKEN_PROVIDER_1 = "https://idp1.example.com";
         private static final String TOKEN_PROVIDER_2 = "https://idp2.example.com";
 
 
         public static Map<String, TokenRequestInfo> make() {
             HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
             tokenProviders.put(TOKEN_PROVIDER_1, ValidTokenRequestInfo.make());
             tokenProviders.put(TOKEN_PROVIDER_2, null);
             return tokenProviders;
         }
 
         public static void assertEquals(Map<String, TokenRequestInfo> tokenProviders) {
             assertThat(tokenProviders).hasSize(2);
             assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_1);
             assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_2);
             ValidTokenRequestInfo.assertEquals(tokenProviders.get(TOKEN_PROVIDER_1));
             assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getClientId()).isNull();
             assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getNonce()).isNull();
             assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getAdditionalProperties()).isEmpty();
         }
     }
 
     public static final class ValidProperties {
         public static final String PROPERTY_A_NAME = "Property A";
         public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
 
         public static final String PROPERTY_B_NAME = "Property B";
         public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
 
         public static final Map<String, byte[]> MAP_INSTANCE;
 
         static {
             MAP_INSTANCE = new HashMap<>();
             MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
             MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
         }
 
         public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
             Map<String, byte[]> byteMap =
                     CollectionConverter.convertMapValues(
                             map,
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             assertEqualTo(byteMap);
         }
 
         public static void assertEqualTo(Map<String, byte[]> map) {
             assertThat(map).hasSize(2);
             assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
             assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
         }
     }
 
     public static final class ValidFacebookCredential {
         public final static String ID = "bob@facebook.com";
         public final static String ID_TOKEN = "'His name is bob' - xoxo facebook";
         public final static AuthenticationMethod AUTHENTICATION_METHOD =
                 AuthenticationMethods.FACEBOOK;
         public final static String PASSWORD = "hunter2";
         public final static String DISPLAY_NAME = "Bob";
         public final static Uri DISPLAY_PICTURE_URL =
                 Uri.parse("https://pictures.facebook.com/bob_pics.jpeg");
         public final static Map<String, byte[]> ADDITIONAL_PROPERTIES =
                 ValidProperties.MAP_INSTANCE;
         public final static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
         public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
                 new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
 
         public static Credential make() {
             return new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN)
                     .setDisplayName(DISPLAY_NAME)
                     .setDisplayPicture(DISPLAY_PICTURE_URL)
                     .setPassword(PASSWORD)
                     .setIdToken(ID_TOKEN)
                     .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                     .build();
         }
 
         public static void assertEqualTo(Credential credential) {
             assertThat(credential.getIdentifier()).isEqualTo(ID);
             assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
             assertThat(credential.getPassword()).isEqualTo(PASSWORD);
             assertThat(credential.getDisplayName()).isEqualTo(DISPLAY_NAME);
             assertThat(credential.getDisplayPicture()).isEqualTo(DISPLAY_PICTURE_URL);
             ValidProperties.assertEqualTo(credential.getAdditionalProperties());
             assertThat(credential.getAuthenticationMethod()).isEqualTo(AUTHENTICATION_METHOD);
             assertThat(credential.getAuthenticationDomain()).isEqualTo(AUTHENTICATION_DOMAIN);
         }
 
         public static void assertEqualTo(Protobufs.Credential credential) throws Exception {
             assertEqualTo(Credential.fromProtobuf(credential));
         }
     }
 
     public static final class ValidEmailHint {
         private static final String ALICE_ID = "alice@example.com";
         private static final String ALICE_NAME = "Alice";
         private static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://avatars.example.com/alice";
         private static final Uri ALICE_DISPLAY_PICTURE_URI = Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
         private static final String GENERATED_PASSWORD = "correctH0rseBatterySt4ple";
         private static final String ID_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
                 + "eyJzdWIiOiJ5b2xvIn0."
                 + "BI1g9ns0shv6PKfwlhfPKwh5XzxQyg_el_35_wZbtsI";
 
         public static Hint make() {
             return new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                     .setDisplayName(ALICE_NAME)
                     .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
                     .setGeneratedPassword(GENERATED_PASSWORD)
                     .setIdToken(ID_TOKEN)
                     .build();
         }
 
         public static void assertEquals(Context context, Credential credential) {
             assertThat(credential.getIdentifier()).isEqualTo(ALICE_ID);
             assertThat(credential.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
             assertThat(credential.getDisplayName()).isEqualTo(ALICE_NAME);
             assertThat(credential.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
             assertThat(credential.getPassword()).isEqualTo(GENERATED_PASSWORD);
             assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
             assertThat(credential.getAuthenticationDomain())
                     .isEqualTo(AuthenticationDomain.getSelfAuthDomain(context));
         }
 
         public static void assertEquals(Hint hint) {
             assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
             assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
             assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
-            assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+            assertThat(hint.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
             assertThat(hint.getGeneratedPassword()).isEqualTo(GENERATED_PASSWORD);
             assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
         }
 
         public static void assertEquals(Protobufs.Hint protoHint) {
             assertThat(protoHint.getId()).isEqualTo(ALICE_ID);
             assertThat(protoHint.getAuthMethod().getUri())
                     .isEqualTo(AuthenticationMethods.EMAIL.toString());
             assertThat(protoHint.getDisplayName()).isEqualTo(ALICE_NAME);
             assertThat(protoHint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
             assertThat(protoHint.getGeneratedPassword()).isEqualTo(GENERATED_PASSWORD);
             assertThat(protoHint.getIdToken()).isEqualTo(ID_TOKEN);
         }
     }
 
     public static final class ValidApplication {
         public static final String PACKAGE_NAME = "com.example.app";
         private static final String FINGERPRINT =
                 "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                         + "7V4Lo8BdCxaA307H0HYkAw==";
         private static byte[] SIGNATURE_BYTES = new byte[]
                 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
 
         public static final class AuthDomain {
             private static final String AUTHENTICATION_DOMAIN_STRING =
                     "android://" + FINGERPRINT + "@" + PACKAGE_NAME;
 
             public static AuthenticationDomain make() {
                 return new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
             }
 
             public static void assertEquals(AuthenticationDomain domain) {
                 assertThat(domain).isEqualTo(make());
             }
         }
 
         public static Context install(Context context) throws Exception {
             PackageManager packageManager = mock(PackageManager.class);
 
             when(packageManager.getPackageInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_SIGNATURES)))
                     .thenReturn(makePackageInfo());
             doThrow(PackageManager.NameNotFoundException.class)
                     .when(packageManager).getPackageInfo(
                             not(eq(PACKAGE_NAME)),
                             eq(PackageManager.GET_SIGNATURES));
 
             context = spy(context);
             when(context.getPackageName()).thenReturn(PACKAGE_NAME);
             when(context.getPackageManager()).thenReturn(packageManager);
 
             return context;
         }
 
         private static PackageInfo makePackageInfo() {
             PackageInfo packageInfo = new PackageInfo();
             packageInfo.signatures = new Signature[1];
             packageInfo.signatures[0] = new Signature(SIGNATURE_BYTES);
 
             return packageInfo;
         }
     }
 
     public static final class ApplicationWithMultipleSignatures {
         public static final String PACKAGE_NAME = "com.example.app.multiple_signatures";
         private static byte[] SIGNATURE_BYTES = new byte[]
                 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
         public static Context install(Context context) throws Exception {
             PackageManager packageManager = mock(PackageManager.class);
 
             when(packageManager.getPackageInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_SIGNATURES)))
                     .thenReturn(makePackageInfo());
             doThrow(PackageManager.NameNotFoundException.class)
                     .when(packageManager).getPackageInfo(
                     not(eq(PACKAGE_NAME)),
                     eq(PackageManager.GET_SIGNATURES));
 
             context = spy(context);
             when(context.getPackageName()).thenReturn(PACKAGE_NAME);
             when(context.getPackageManager()).thenReturn(packageManager);
 
             return context;
         }
 
         private static PackageInfo makePackageInfo() {
             PackageInfo packageInfo = new PackageInfo();
             packageInfo.signatures = new Signature[2];
             packageInfo.signatures[0] = new Signature(SIGNATURE_BYTES);
             packageInfo.signatures[1] = new Signature(SIGNATURE_BYTES);
 
             return packageInfo;
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 14fa734..6701c8c 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -40,231 +40,231 @@ import org.valid4j.errors.RequireViolation;
 public final class CredentialView extends LinearLayout {
 
     private static final String TAG = "CredentialView";
 
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_email_provider_button)
     ImageButton mEmailProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
     /**
      * Simple constructor to use when creating a credential view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mEmailProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void setEmailAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
         GlideApp.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Populates the fragment's fields from a given OpenYOLO hint.
      */
     public void setFieldsFromHint(Hint hint) {
         copyIfNotNull(hint.getIdentifier(), mIdField);
         copyIfNotNull(hint.getGeneratedPassword(), mPasswordField);
         copyIfNotNull(hint.getDisplayName(), mDisplayNameField);
-        copyIfNotNull(hint.getDisplayPictureUri(), mProfilePictureField);
+        copyIfNotNull(hint.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(hint.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authMethodStr = mAuthenticationMethodField.getText().toString();
         AuthenticationMethod authMethod;
         try {
             authMethod = new AuthenticationMethod(authMethodStr);
         } catch (RequireViolation ex) {
             Log.w(TAG, "User entered authentication method " + authMethodStr + " is invalid", ex);
             return null;
         }
 
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethod,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         credentialBuilder.setPassword(mPasswordField.getText().toString());
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }

commit 3b3c67054a4e35262e3d5a5c0733921a2ddabd2d
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue Sep 26 10:17:25 2017 -0700

    Standardized on intent style callbacks for CredentialClient (#85)

diff --git a/api/AndroidManifest.xml b/api/AndroidManifest.xml
index ece46ed..0b4e84b 100644
--- a/api/AndroidManifest.xml
+++ b/api/AndroidManifest.xml
@@ -1,12 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.openyolo.api">
 
     <application>
         <activity
-            android:name=".ui.ProviderPickerActivity"
+            android:name=".internal.ProviderPickerActivity"
             android:label="@string/provider_picker_activity_label"
-            android:theme="@style/PickerTheme"
+            android:theme="@style/ProviderPicker"
+            android:exported="false" />
+        <activity
+            android:name=".internal.FinishWithResultActivity"
+            android:theme="@style/Invisible"
+            android:exported="false" />
+        <activity
+            android:name=".internal.CredentialRetrieveActivity"
+            android:theme="@style/Invisible"
             android:exported="false" />
     </application>
 </manifest>
diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 5c56e3d..2d0b80d 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -17,3 +17,2 @@ package org.openyolo.api;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.protocol.ProtocolConstants.CREDENTIAL_DATA_TYPE;
 import static org.openyolo.protocol.ProtocolConstants.DELETE_CREDENTIAL_ACTION;
@@ -39,15 +38,11 @@ import android.support.annotation.VisibleForTesting;
 import android.util.Log;
-import com.google.bbq.BroadcastQueryClient;
-import com.google.bbq.QueryCallback;
-import com.google.bbq.QueryResponse;
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-
+import org.openyolo.api.internal.ActivityResult;
+import org.openyolo.api.internal.CredentialRetrieveActivity;
+import org.openyolo.api.internal.FinishWithResultActivity;
+import org.openyolo.api.internal.ProviderPickerActivity;
 import org.openyolo.api.persistence.AppSettings;
 import org.openyolo.api.persistence.internal.AppSettingsImpl;
-import org.openyolo.api.ui.ProviderPickerActivity;
 import org.openyolo.protocol.Credential;
@@ -62,512 +57,475 @@ import org.openyolo.protocol.HintRetrieveResult;
 import org.openyolo.protocol.MalformedDataException;
-import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
-import org.openyolo.protocol.RetrieveBbqResponse;
-import org.openyolo.protocol.internal.IntentUtil;
+
 
 /**
  * The primary way of interacting with OpenYOLO credential providers. The client is light weight
  * allowing new instances to be created as needed.
  *
  * Requests are executed by starting an Activity based intent and its result returned via
  * {@link android.app.Activity#onActivityResult(int, int, Intent)}. For each request/response pair
  * there exist two client methods:
  * 1) Takes a given request and returns the Activity Intent which sends the request.
  * 2) Takes an Intent returned via {@link android.app.Activity#onActivityResult(int, int, Intent)}
  *    and returns the associated result.
  *
  * For example using the hint flow:
  * <pre>{@code
  * CredentialClient client = CredentialClient.getInstance(this);
  * HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
  *
  * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
  * startActivityForResult(retrieveHintIntent, RC_HINT);
  * // ...
  *
  * @Override
  * public void onActivityResult(int requestCode, int resultCode, Intent data) {
  *     super.onActivityResult(requestCode, resultCode, data);
  *
  *     HintRetrieveResult result = client.getHintRetrieveResult(data);
  * }}</pre>
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#operations">
  *     OpenYOLO Specification: Operations</a>
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private final Context mApplicationContext;
-    private final BroadcastQueryClient mQueryClient;
     private final AppSettings mDeviceState;
 
     /**
      * Returns a new credential client instance configured with the default options.
      */
     public static CredentialClient getInstance(@NonNull Context context) {
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(AppSettingsImpl.getInstance(context)).build();
 
         return getInstance(context, options);
     }
 
     /**
      * Returns a new credential client instance configured with the given
      * {@link CredentialClientOptions}.
      */
     public static CredentialClient getInstance(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
-        return new CredentialClient(context, BroadcastQueryClient.getInstance(context), options);
+        return new CredentialClient(context, options);
     }
 
     @VisibleForTesting
     CredentialClient(
             @NonNull Context context,
-            @NonNull BroadcastQueryClient broadcastQueryClient,
             @NonNull CredentialClientOptions options) {
         validate(context, notNullValue(), NullPointerException.class);
-        validate(broadcastQueryClient, notNullValue(), NullPointerException.class);
         validate(options, notNullValue(), NullPointerException.class);
 
         mApplicationContext = context.getApplicationContext();
-        mQueryClient = broadcastQueryClient;
         mDeviceState = options.getDeviceState();
     }
 
+    /**
+     * Provides an Activity intent to request any available credentials from the credential
+     * providers on the device.
+     *
+     * Launch the returned intent via
+     * {@link android.app.Activity#startActivityForResult(Intent, int)} and extract the result via
+     * {@link #getCredentialRetrieveResult(Intent)} using the Intent data received in the associated
+     * {@link android.app.Activity#onActivityResult(int, int, Intent)} callback.
+     *
+     * <pre>{@code
+     * CredentialClient client = CredentialClient.getInstance(getContext());
+     * // ...
+     *
+     * CredentialRetrieveRequest request  =
+     *     CredentialRetrieveRequest.of(AuthenticationMethods.EMAIL, AuthenticationMethods.GOOGLE);
+     * Intent retrieveCredentialIntent = client.getCredentialRetrieveIntent(request);
+     * startActivityForResult(retrieveCredentialIntent, RC_RETRIEVE_CREDENTIAL);
+     *
+     * // ...
+     * @Override
+     * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+     *     super.onActivityResult(requestCode, resultCode, data);
+     *     if (RC_RETRIEVE_CREDENTIAL == requestCode) {
+     *        CredentialRetrieveResult result = client.getCredentialRetrieveResult(data);
+     *        // handle result ...
+     *     }
+     * }
+     * }</pre>
+     *
+     * @see #getCredentialRetrieveResult(Intent)
+     */
+    public Intent getCredentialRetrieveIntent(CredentialRetrieveRequest request) {
+        if (mDeviceState.isAutoSignInDisabled()) {
+            request = new CredentialRetrieveRequest.Builder(request)
+                    .setRequireUserMediation(true)
+                    .build();
+        }
+
+        return CredentialRetrieveActivity.createIntent(mApplicationContext, request);
+    }
+
     /**
      * Provides an intent to request a login hint. This will target the user's preferred credential
-     * provider, if this can be determined. If no providers are available, {@code null} is
-     * returned.
+     * provider, if this can be determined.
      */
-    @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
-            return null;
+            ActivityResult result = ActivityResult.of(
+                    HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE,
+                    HintRetrieveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
+
+            return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
-    /**
-     * Requests and retrieves any available credentials from the credential providers on the device.
-     * @param request  Properties of the credential request
-     * @param callback Handler for the result of the credential request.
-     */
-    public void retrieve(
-            CredentialRetrieveRequest request,
-            final RetrieveCallback callback) {
-
-        if (mDeviceState.isAutoSignInDisabled()) {
-            request = new CredentialRetrieveRequest.Builder(request)
-                    .setRequireUserMediation(true)
-                    .build();
-        }
-
-        mQueryClient.queryFor(
-                CREDENTIAL_DATA_TYPE,
-                request.toProtocolBuffer(),
-                new CredentialRetrieveQueryCallback(callback));
-    }
-
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
-    @Nullable
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
-            return null;
+            ActivityResult result = ActivityResult.of(
+                    CredentialSaveResult.CODE_NO_PROVIDER_AVAILABLE,
+                    CredentialSaveResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
+
+            return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
-    @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
-            return null;
+            ActivityResult result = ActivityResult.of(
+                    CredentialDeleteResult.CODE_NO_PROVIDER_AVAILABLE,
+                    CredentialDeleteResult.NO_PROVIDER_AVAILABLE.toResultDataIntent());
+
+            return FinishWithResultActivity.createIntent(mApplicationContext, result);
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             CredentialRetrieveResult result =
                     CredentialRetrieveResult.fromProtobufBytes(resultBytes);
 
             // Once a successfully retrieve result has been handled, re-enable auto sign-in.
             if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
                 mDeviceState.setIsAutoSignInDisabled(false);
             }
 
             return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return createDefaultHintRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a credential save request from the intent data returned by a provider.
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return createDefaultCredentialSaveResult();
         }
     }
 
     /**
      * Disables automatically signing a user until a successful response is given to
      * {@link CredentialClient#getCredentialRetrieveResult(Intent)}.
      */
     public void disableAutoSignIn() {
         mDeviceState.setIsAutoSignInDisabled(true);
     }
 
     @NonNull
     private static CredentialSaveResult createDefaultCredentialSaveResult() {
         return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
                 .build();
     }
 
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @NonNull
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
-
-    private class CredentialRetrieveQueryCallback implements QueryCallback {
-
-        private final RetrieveCallback mCallback;
-
-        CredentialRetrieveQueryCallback(RetrieveCallback callback) {
-            mCallback = callback;
-        }
-
-        @Override
-        public void onResponse(long queryId, List<QueryResponse> queryResponses) {
-            ArrayList<Intent> retrieveIntents = new ArrayList<>();
-            Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
-            for (QueryResponse queryResponse : queryResponses) {
-                Protobufs.CredentialRetrieveBbqResponse response;
-                try {
-                    response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
-                            queryResponse.responseMessage);
-                } catch (IOException e) {
-                    Log.w(LOG_TAG, "Failed to decode credential retrieve response");
-                    continue;
-                }
-
-                protoResponses.put(queryResponse.responderPackage, response);
-
-                if (!response.getRetrieveIntent().isEmpty()) {
-                    // TODO: handle failure to decode retrieve intent gracefully
-                    // (i.e. ignore the response)
-                    Intent retrieveIntent =
-                            IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
-
-                    if (!queryResponse.responderPackage.equals(
-                            retrieveIntent.getComponent().getPackageName())) {
-                        Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
-                        continue;
-                    }
-
-                    retrieveIntents.add(retrieveIntent);
-                }
-            }
-
-            Intent retrieveIntent = null;
-            if (retrieveIntents.size() == 1) {
-                retrieveIntent = retrieveIntents.get(0);
-            } else if (retrieveIntents.size() > 1) {
-                retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
-                        mApplicationContext,
-                        retrieveIntents);
-            }
-
-            mCallback.onComplete(
-                    new RetrieveBbqResponse.Builder()
-                            .setProtoResponses(protoResponses)
-                            .setRetrieveIntent(retrieveIntent)
-                            .build(),
-                    null);
-        }
-    }
 }
diff --git a/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
new file mode 100644
index 0000000..e1130af
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/CredentialRetrieveActivity.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import static org.openyolo.protocol.ProtocolConstants.CREDENTIAL_DATA_TYPE;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.BadParcelableException;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.util.Log;
+import android.view.WindowManager.LayoutParams;
+import com.google.bbq.BroadcastQueryClient;
+import com.google.bbq.QueryCallback;
+import com.google.bbq.QueryResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
+import org.openyolo.protocol.internal.IntentUtil;
+
+/**
+ * An invisible Activity that forwards a given {@link CredentialRetrieveRequest} based on the
+ * the set of available credential providers capable of handling it. A
+ * {@link CredentialRetrieveResult} will be returned as described by
+ * {@link org.openyolo.api.CredentialClient#getCredentialRetrieveIntent(CredentialRetrieveRequest)}.
+ */
+public final class CredentialRetrieveActivity extends Activity {
+
+    private static final String LOG_TAG = "CredentialRetrieveAct";
+    private static final String EXTRA_REQUEST = "Request";
+
+    private boolean mIsDestroyed = false;
+
+    /**
+     * Returns an Intent for {@link CredentialRetrieveActivity} for the given
+     * {@link CredentialRetrieveRequest}.
+     */
+    public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
+        return new Intent()
+                .setClass(context, CredentialRetrieveActivity.class)
+                .putExtra(EXTRA_REQUEST, request);
+    }
+
+    @Override
+    public void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        getWindow().addFlags(LayoutParams.FLAG_NOT_TOUCHABLE);
+
+        CredentialRetrieveRequest request = getIntent().getParcelableExtra(EXTRA_REQUEST);
+        if (null == request) {
+            setResult(
+                    CredentialRetrieveResult.CODE_UNKNOWN,
+                    CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
+            finish();
+            return;
+        }
+
+        BroadcastQueryClient.getInstance(this)
+                .queryFor(
+                        CREDENTIAL_DATA_TYPE,
+                        request.toProtocolBuffer(),
+                        new CredentialRetrieveQueryCallback());
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mIsDestroyed = true;
+    }
+
+
+    private class CredentialRetrieveQueryCallback implements QueryCallback {
+        @Override
+        public void onResponse(long queryId, List<QueryResponse> queryResponses) {
+            ArrayList<Intent> retrieveIntents = new ArrayList<>();
+            Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
+            for (QueryResponse queryResponse : queryResponses) {
+                Protobufs.CredentialRetrieveBbqResponse response;
+                try {
+                    response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
+                            queryResponse.responseMessage);
+                } catch (IOException e) {
+                    Log.w(LOG_TAG, "Failed to decode credential retrieve response");
+                    continue;
+                }
+
+                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");
+                    continue;
+                }
+
+                if (!queryResponse.responderPackage.equals(
+                        retrieveIntent.getComponent().getPackageName())) {
+                    Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
+                    continue;
+                }
+
+                retrieveIntents.add(retrieveIntent);
+            }
+
+            if (retrieveIntents.isEmpty()) {
+                setResult(
+                        CredentialRetrieveResult.CODE_UNKNOWN,
+                        CredentialRetrieveResult.UNKNOWN.toResultDataIntent());
+                finish();
+                return;
+            }
+
+            if (retrieveIntents.size() == 1) {
+                forwardResultFromActivity(retrieveIntents.get(0));
+                return;
+            }
+
+            Intent intent = ProviderPickerActivity.createRetrieveIntent(
+                    CredentialRetrieveActivity.this,
+                    retrieveIntents);
+
+            forwardResultFromActivity(intent);
+        }
+    }
+
+    private void forwardResultFromActivity(Intent intent) {
+        if (mIsDestroyed) {
+            return;
+        }
+
+        intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+        startActivity(intent);
+        finish();
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/FinishWithResultActivity.java b/api/java/org/openyolo/api/internal/FinishWithResultActivity.java
new file mode 100644
index 0000000..b6cb316
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/FinishWithResultActivity.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+
+/**
+ * An invisible Activity which immediately finishes with the given {@link ActivityResult}.
+ */
+public final class FinishWithResultActivity extends Activity {
+
+    private static final String KEY_RESULT = "ActivityResult";
+
+    /**
+     * Returns an Intent for {@link FinishWithResultActivity} for the given {@link ActivityResult}.
+     */
+    public static Intent createIntent(Context context, ActivityResult result) {
+        return new Intent()
+                .setClass(context, FinishWithResultActivity.class)
+                .putExtra(KEY_RESULT, result);
+    }
+
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        ActivityResult result = getIntent().getParcelableExtra(KEY_RESULT);
+        if (null != result) {
+            setResult(result.getResultCode(), result.getData());
+        }
+
+        finish();
+    }
+}
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
similarity index 96%
rename from api/java/org/openyolo/api/ui/ProviderPickerActivity.java
rename to api/java/org/openyolo/api/internal/ProviderPickerActivity.java
index f6a3fd2..e280eea 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/internal/ProviderPickerActivity.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api.ui;
+package org.openyolo.api.internal;
 
@@ -19,2 +19,3 @@ import static org.valid4j.Assertive.require;
 
+import android.app.Activity;
 import android.content.Context;
@@ -29,3 +30,2 @@ import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
-import android.support.v7.app.AppCompatActivity;
 import android.util.Log;
@@ -45,3 +45,2 @@ import org.openyolo.api.KnownProviders;
 import org.openyolo.api.R;
-import org.openyolo.api.internal.ActivityResult;
 import org.openyolo.protocol.CredentialDeleteResult;
@@ -50,232 +49,232 @@ import org.openyolo.protocol.CredentialSaveResult;
 import org.openyolo.protocol.HintRetrieveResult;
 
 /**
- * Activity which presents the list of providers that claim to have a credential available.
- * The user can select one of these options, which fires the associated intent for that provider,
- * or cancel the whole operation.
+ * Activity which presents the given list of providers and their associated intent operations.
+ * The user can select one of these providers, which fires the associated intent, or cancel the
+ * whole operation.
  */
-public final class ProviderPickerActivity extends AppCompatActivity {
+public final class ProviderPickerActivity extends Activity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES_ID = "titleRes";
     private static final String EXTRA_USER_CANCELED_RESULT = "userCanceledResult";
     private static final String LOG_TAG = "ProviderPicker";
 
     private static final ActivityResult RETRIEVE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialRetrieveResult.CODE_USER_CANCELED,
                     CredentialRetrieveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult SAVE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialSaveResult.CODE_USER_CANCELED,
                     CredentialSaveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult HINT_USER_CANCELED_RESULT =
             ActivityResult.of(
                     HintRetrieveResult.CODE_USER_CANCELED,
                     HintRetrieveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult DELETE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialDeleteResult.CODE_USER_CANCELED,
                     CredentialDeleteResult.USER_CANCELED.toResultDataIntent());
 
     private View mPickerContainer;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.provider_picker_layout);
         getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
 
         mPickerContainer = findViewById(R.id.picker_container);
 
         // Setup title
         TextView titleView = findViewById(R.id.picker_title);
         @StringRes int titleResId = getIntent().getIntExtra(EXTRA_TITLE_RES_ID, 0);
         String title = getResources().getString(titleResId);
         titleView.setText(title);
 
         // Setup provider list
         ListView providerView = findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
     @Override
     public boolean dispatchTouchEvent(MotionEvent event) {
 
         // finishWithUserCanceled() if the user tapped outside the picker
         if (MotionEvent.ACTION_DOWN == event.getAction()) {
             Rect visibilityRect = new Rect();
             mPickerContainer.getGlobalVisibleRect(visibilityRect);
             boolean tappedOutsidePicker =
                     !visibilityRect.contains((int) event.getRawX(), (int) event.getRawY());
             if (tappedOutsidePicker) {
                 finishWithUserCanceled();
             }
         }
 
         return super.dispatchTouchEvent(event);
     }
 
     @Override
     public void onBackPressed() {
         finishWithUserCanceled();
     }
 
     private void finishWithUserCanceled() {
         ActivityResult activityResult = getIntent().getParcelableExtra(EXTRA_USER_CANCELED_RESULT);
 
         if (null != activityResult) {
             setResult(activityResult.getResultCode(), activityResult.getData());
         }
 
         finish();
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes,
             @Nullable ActivityResult userCanceledResult) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES_ID, titleRes);
         intent.putExtra(EXTRA_USER_CANCELED_RESULT, userCanceledResult);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
 
         return createIntent(
                 context,
                 retrieveIntents,
                 R.string.retrieve_picker_prompt,
                 RETRIEVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
 
         return createIntent(
                 context,
                 retrieveIntents,
                 R.string.save_picker_prompt,
                 SAVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
 
         return createIntent(
                 context,
                 hintIntents,
                 R.string.hint_picker_prompt,
                 HINT_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for display a list of providers to which a credential deletion request
      * should be sent.
      */
     public static Intent createDeleteIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> deleteIntents) {
 
         return createIntent(
                 context,
                 deleteIntents,
                 R.string.delete_picker_prompt,
                 DELETE_USER_CANCELED_RESULT);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = itemView.findViewById(R.id.provider_name);
             View providerUnsafe = itemView.findViewById(R.id.unsafe_provider_warning);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
     }
 }
diff --git a/api/java/org/openyolo/api/ui/package-info.java b/api/java/org/openyolo/api/ui/package-info.java
deleted file mode 100644
index e1e5bab..0000000
--- a/api/java/org/openyolo/api/ui/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * UI support activities for OpenYOLO.
- */
-package org.openyolo.api.ui;
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index d08aeb8..b322513 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -21,3 +21,2 @@ import static junit.framework.TestCase.assertNotNull;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
@@ -25,3 +24,2 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -36,8 +34,3 @@ import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
-
-import com.google.bbq.BroadcastQueryClient;
-import com.google.bbq.QueryCallback;
-
 import java.util.ArrayList;
-import java.util.Collections;
 import org.junit.After;
@@ -46,11 +39,10 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.openyolo.api.internal.FinishWithResultActivity;
 import org.openyolo.api.persistence.AppSettings;
 import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
 import org.openyolo.protocol.CredentialSaveRequest;
@@ -58,432 +50,394 @@ import org.openyolo.protocol.CredentialSaveResult;
 import org.openyolo.protocol.HintRetrieveRequest;
-import org.openyolo.protocol.CredentialRetrieveResult;
-import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.HintRetrieveResult;
 import org.openyolo.protocol.ProtocolConstants;
+import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowActivity;
 
 /**
  * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
 
     private static final HintRetrieveRequest EMAIL_HINT_REQUEST =
             HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
-    @Mock
-    private BroadcastQueryClient mockBroadcastQueryClient;
-
     @Mock
     private KnownProviders mockKnownProviders;
 
     @Mock
     private AppSettings mockDeviceState;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(mockDeviceState).build();
-        credentialClient = new CredentialClient(mockContext, mockBroadcastQueryClient, options);
+        credentialClient = new CredentialClient(mockContext, options);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void getInstance_returnsNonNull() throws Exception {
         CredentialClient test = CredentialClient.getInstance(mockContext);
         assertNotNull(test);
     }
 
-    @SuppressWarnings("WrongConstant")
-    @Test
-    public void testGetHintIntent_noProviders() throws Exception {
-        when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
-                .thenReturn(Collections.<ResolveInfo>emptyList());
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
-
-        assertThat(hintIntent).isNull();
-    }
-
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
+    @Test
+    public void getHintRetrieveIntent_noAvailableProviders_finishesWithNoAvailableProviders() {
+        Intent intent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
+        ShadowActivity activity = startFinishWithResultActivity(intent);
+
+        assertThat(activity.isFinishing()).isTrue();
+        assertThat(activity.getResultCode())
+                .isEqualTo(HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE);
+
+        HintRetrieveResult result =
+                credentialClient.getHintRetrieveResult(activity.getResultIntent());
+        assertThat(result.getResultCode())
+                .isEqualTo(HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE);
+    }
+
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
-    @SuppressWarnings("WrongConstant")
-    @Test
-    public void testGetSaveIntent_noProviders() throws Exception {
-        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
-        final Intent saveIntent = credentialClient.getSaveIntent(request);
-
-        assertThat(saveIntent).isNull();
-    }
-
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(null /* intent*/);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
         final Intent intent = new Intent();
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
         final Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_validResult_returnsResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(
                         CredentialSaveResult.SAVED.toResultDataIntent());
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialRetrieveResult_withErrorResult_returnsErrorResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verifyNoMoreInteractions(mockDeviceState);
     }
 
     @Test
     public void getCredentialRetrieveResult_withSuccessfulResult_returnsSuccessfulResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verify(mockDeviceState).setIsAutoSignInDisabled(eq(false));
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
-    @Test
-    public void retrieve_autoSignInDisabled_requestRequiresUserMediation() {
-        CredentialRetrieveRequest request =
-                CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL);
-
-        when(mockDeviceState.isAutoSignInDisabled()).thenReturn(true);
-
-        // Act
-        credentialClient.retrieve(request, null /* callBack */);
-
-        // Assert
-        ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
-                ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
-        verify(mockBroadcastQueryClient)
-                .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
-        assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isTrue();
-    }
-
-    @Test
-    public void retrieve_autoSignInEnabled_requestDoesNotRequireUserMediation() {
-        CredentialRetrieveRequest request =
-                new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                        .setRequireUserMediation(false)
-                        .build();
-
-        when(mockDeviceState.isAutoSignInDisabled()).thenReturn(false);
-
-        // Act
-        credentialClient.retrieve(request, null /* callBack */);
-
-        // Assert
-        ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
-                ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
-        verify(mockBroadcastQueryClient)
-                .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
-        assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isFalse();
-    }
-
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
+    private ShadowActivity startFinishWithResultActivity(Intent intent) {
+        return Shadows.shadowOf(
+                Robolectric.buildActivity(FinishWithResultActivity.class, intent).create().get());
+    }
+
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/api/javatests/org/openyolo/api/internal/FinishWithResultActivityTest.java b/api/javatests/org/openyolo/api/internal/FinishWithResultActivityTest.java
new file mode 100644
index 0000000..1579772
--- /dev/null
+++ b/api/javatests/org/openyolo/api/internal/FinishWithResultActivityTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.internal;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.robolectric.Robolectric.buildActivity;
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.Intent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.HintRetrieveResult;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowActivity;
+
+/**
+ * Units tests for {@link FinishWithResultActivity}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class FinishWithResultActivityTest {
+
+    private static final Context CONTEXT = RuntimeEnvironment.application;
+
+    @Test
+    public void startActivity_withResult_finishesWithResult() {
+        int givenResultCode = 0x2c001;
+        Intent givenIntent =
+                new HintRetrieveResult.Builder(givenResultCode).build().toResultDataIntent();
+        Intent intent = FinishWithResultActivity.createIntent(
+                CONTEXT,
+                ActivityResult.of(givenResultCode, givenIntent));
+
+        ShadowActivity activity = startActivity(intent);
+
+        assertThat(activity.isFinishing()).isTrue();
+        HintRetrieveResult result =
+                CredentialClient.getInstance(CONTEXT)
+                        .getHintRetrieveResult(activity.getResultIntent());
+        assertThat(result.getResultCode()).isEqualTo(givenResultCode);
+        assertThat(activity.getResultCode()).isEqualTo(givenResultCode);
+    }
+
+    private static ShadowActivity startActivity(Intent intent) {
+        return shadowOf(buildActivity(FinishWithResultActivity.class, intent).create().get());
+    }
+}
diff --git a/api/res/values/styles.xml b/api/res/values/styles.xml
index e5f3023..acd5868 100644
--- a/api/res/values/styles.xml
+++ b/api/res/values/styles.xml
@@ -1,10 +1,22 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <style name="PickerTheme" parent="Theme.AppCompat.Light">
+    <style name="ProviderPicker" parent="Theme.AppCompat.Light">
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>
         <item name="android:windowBackground">@android:color/transparent</item>
         <item name="android:windowIsFloating">true</item>
         <item name="android:backgroundDimEnabled">true</item>
     </style>
+
+  <style name="Invisible">
+    <item name="android:windowNoTitle">true</item>
+    <item name="android:windowActionBar">false</item>
+    <item name="android:windowBackground">@android:color/transparent</item>
+    <item name="android:windowIsTranslucent">true</item>
+    <item name="android:windowContentOverlay">@null</item>
+    <item name="android:colorBackgroundCacheHint">@null</item>
+    <item name="android:windowIsFloating">true</item>
+    <item name="android:backgroundDimEnabled">false</item>
+  </style>
+
 </resources>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index de28034..0fceb07 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -48,470 +48,447 @@ import org.openyolo.protocol.HintRetrieveRequest;
 import org.openyolo.protocol.HintRetrieveResult;
-import org.openyolo.protocol.RetrieveBbqResponse;
 
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
     private static final int MIN_PASSWORD_LENGTH = 4;
 
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
     public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
     public final ObservableBoolean showError = new ObservableBoolean(false);
 
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
     private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
         mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
         mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
             mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
-     * Initiates an OpenYOLO credential retrieval request, and forwards the response to
-     * {@link #handleRetrieveQueryResult(RetrieveBbqResponse, Throwable)} for processing.
+     * Initiates an OpenYOLO credential retrieval request.
      */
     private void tryRetrieveExistingCredential() {
         setShowLoading(R.string.existing_account_search_prompt);
-        mCredentialClient.retrieve(
-                CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL),
-                (queryResponse, queryError) ->
-                    getExecutor().execute(
-                            () -> handleRetrieveQueryResult(queryResponse, queryError)));
-    }
-
-    /**
-     * Inspects the initial response from the OpenYOLO retrieve request. If a retrieve intent
-     * is available, this is used to attempt to source a credential from the provider. The result
-     * of this is indirectly routed to {@link #handleRetrieveResult(Intent)}.
-     *
-     * If no intent is returned, an attempt is made to source an account hint instead.
-     */
-    private void handleRetrieveQueryResult(
-            RetrieveBbqResponse queryResponse,
-            Throwable queryError) {
-        if (queryResponse != null && queryResponse.getRetrieveIntent() != null) {
-            Log.i(TAG, "retrieving credential from provider");
-            mNavigator.get().startOpenYoloRetrieve(queryResponse.getRetrieveIntent());
-            return;
-        }
-
-        Log.i(TAG, "no OpenYOLO providers for retrieve");
-        tryRetrieveHint();
+        Intent intent =
+                mCredentialClient.getCredentialRetrieveIntent(
+                        CredentialRetrieveRequest.fromAuthMethods(AuthenticationMethods.EMAIL));
+        mNavigator.get().startOpenYoloRetrieve(intent);
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
                 boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
                         credential.getPassword());
                 if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.of(AuthenticationMethods.EMAIL));
 
         if (hintIntent != null) {
             setShowLoading(R.string.requesting_hint_prompt);
             mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
                         hint.getDisplayPictureUri());
                 String hintPassword = hint.getGeneratedPassword();
 
 
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
                 boolean authenticated = false;
 
                 if (hintPassword != null) {
                     authenticated = mUserDataSource.createPasswordAccount(
                             hintEmail, displayName, displayPicture, hintPassword);
 
                     if (authenticated) {
                         // account created, attempt to save it back to the OpenYOLO provider
                         trySaveCredential(hint.toCredentialBuilder(mApplication).build());
                     }
                 }
 
                 if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
 
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
     public void signInButtonClicked(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
         if (userPassword.length() < MIN_PASSWORD_LENGTH) {
             passwordError.set(getResourceString(R.string.error_password_too_short));
             return;
         } else {
             emailError.set("");
         }
 
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
                     null, // name
                     null, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 showError.set(true);
             }
         }
     }
 
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
             mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
         mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
         mNavigator.get().goToMain();
     }
 
     private void setShowLoading(@StringRes int loadingLabelId) {
         setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
     private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
         showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
         showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
index a688ea2..2eb44fc 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
@@ -29,60 +29,60 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * Writes a credential to the credential store after it is unlocked.
  */
 public class SaveAfterUnlockActivity extends AppCompatActivity {
 
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final String LOG_TAG = "SaveAfterUnlock";
 
     private Credential mCredential;
 
     /**
      * Creates an intent to save the provided credential after the store is unlocked.
      */
     public static Intent createIntent(Context context, Credential credentialProto) {
         Intent intent = new Intent(context, SaveAfterUnlockActivity.class);
         intent.putExtra(EXTRA_CREDENTIAL, credentialProto.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
             mCredential = Credential.parseFrom(credentialBytes);
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to decode credential to save");
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 try {
                     client.upsertCredential(mCredential);
                     runOnUiThread(new SendResultRunnable(CredentialSaveResult.SAVED));
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to store credential after save", e);
-                    runOnUiThread(new SendResultRunnable(CredentialSaveResult.UNSPECIFIED));
+                    runOnUiThread(new SendResultRunnable(CredentialSaveResult.UNKNOWN));
                 }
 
                 client.disconnect(SaveAfterUnlockActivity.this);
             }
         });
     }
 
     private class SendResultRunnable implements Runnable {
         private final CredentialSaveResult mResult;
 
         SendResultRunnable(CredentialSaveResult result) {
             mResult = result;
         }
 
         @Override
         public void run() {
             setResult(mResult.getResultCode(), mResult.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
index 7860dc3..cdff760 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -34,116 +34,116 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * Verifies the rights to save a credential, before proceeding to
  * {@link SaveCredentialConfirmationActivity}.
  */
 public class SaveCredentialActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
 
     private CredentialSaveRequest mRequest;
     private String mCallingPackage;
     private AuthenticationDomain mAuthDomainForApp;
     private CredentialStorageClient mStorageClient;
 
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         final byte[] encodedRequest =
                 getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_REQUEST);
 
         // Ensure the intent contains a save request
         if (null == encodedRequest) {
             Log.w(LOG_TAG, "No save request included in intent");
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         // Ensure the request can successfully be parsed from it's encoded form
         try {
             mRequest = CredentialSaveRequest.fromProtoBytes(encodedRequest);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "Failed to decode save request", ex);
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         if (!verifyCaller()) {
             Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
                     + mRequest.getCredential().getAuthenticationDomain());
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(final CredentialStorageClient client) {
                 mStorageClient = client;
                 runOnUiThread(new AfterStorageConnect());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         if (mStorageClient != null) {
             mStorageClient.disconnect(this);
         }
     }
 
     @UiThread
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private boolean verifyCaller() {
         final ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         mCallingPackage = callingActivity.getPackageName();
         mAuthDomainForApp = AuthenticationDomain.fromPackageName(this, mCallingPackage);
 
         final AuthenticationDomain authDomain = mRequest.getCredential().getAuthenticationDomain();
         if (!authDomain.equals(mAuthDomainForApp)) {
             Log.w(LOG_TAG, "App " + mCallingPackage
                     + " is not provably associated to authentication domain "
                     + authDomain
                     + " for the credential to be saved.");
             return false;
         }
 
         return true;
     }
 
     private final class AfterStorageConnect implements Runnable {
         @Override
         public void run() {
             try {
                 // Ensure authentication domain is not on never save list
                 if (mStorageClient.isOnNeverSaveList(Arrays.asList(mAuthDomainForApp))) {
                     finishWithResult(CredentialSaveResult.PROVIDER_REFUSED);
                     return;
                 }
 
                 // Start confirm activity
                 Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
                         SaveCredentialActivity.this,
                         mCallingPackage,
                         mRequest.getCredential());
                 confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(confirmIntent);
                 finish();
             } catch (IOException ex) {
-                finishWithResult(CredentialSaveResult.UNSPECIFIED);
+                finishWithResult(CredentialSaveResult.UNKNOWN);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
index c7207dc..343c1a9 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -38,132 +38,132 @@ import org.openyolo.protocol.MalformedDataException;
 /**
  * Confirms with the user whether they want to save a credential provided by the
  * calling app. Verification of the app's right to save such a credential occurs
  * in {@link SaveCredentialActivity} before reaching this point.
  */
 public class SaveCredentialConfirmationActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
     private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
 
     @BindView(R.id.save_prompt)
     TextView mSavePromptView;
 
     private Credential mCredential;
     private String mCallingAppName;
 
     private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
     private final CountDownLatch mClientConnected = new CountDownLatch(1);
 
     /**
      * Creates an intent to confirm whether the user wishes to save the specified credential.
      */
     public static Intent createIntent(
             Context context,
             String callingPackage,
             Credential credential) {
         Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
         intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toProtobuf().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mCredential = Credential.fromProtoBytes(
                     getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
         } catch (MalformedDataException e) {
             Log.e(LOG_TAG, "Unable to decode credential", e);
-            finishWithResult(CredentialSaveResult.UNSPECIFIED);
+            finishWithResult(CredentialSaveResult.UNKNOWN);
         }
 
         mCallingAppName = CallerUtil.getCallingAppName(this);
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 mClient.set(client);
                 mClientConnected.countDown();
             }
         });
 
         setContentView(R.layout.save_layout);
         ButterKnife.bind(this);
 
         String savePromptTemplate = getString(R.string.save_prompt_template);
         mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
     }
 
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         CredentialStorageClient client = mClient.get();
         if (client != null) {
             client.disconnect(this);
         }
     }
 
     @OnClick(R.id.save_button)
     void onSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
-            finishWithResult(CredentialSaveResult.UNSPECIFIED);
+            finishWithResult(CredentialSaveResult.UNKNOWN);
             return;
         }
 
         if (client.isUnlocked()) {
             try {
                 client.upsertCredential(mCredential.toProtobuf());
                 finishWithResult(CredentialSaveResult.SAVED);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to write credential to storage");
-                finishWithResult(CredentialSaveResult.UNSPECIFIED);
+                finishWithResult(CredentialSaveResult.UNKNOWN);
             }
         } else {
             Intent saveAfterUnlock = UnlockActivity.createIntent(
                     this,
                     true,
                     SaveAfterUnlockActivity.createIntent(this, mCredential.toProtobuf()));
             saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(saveAfterUnlock);
             finish();
         }
     }
 
     @OnClick(R.id.never_save_button)
     void onNeverSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             finishWithResult(CredentialSaveResult.USER_REFUSED);
             return;
         }
 
         try {
             client.addToNeverSaveList(mCredential.getAuthenticationDomain());
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to add app to never save list", e);
         }
 
         finishWithResult(CredentialSaveResult.USER_REFUSED);
     }
 
     private CredentialStorageClient getStorageClient() {
         try {
             mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
             return mClient.get();
         } catch (InterruptedException e) {
             Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
             return null;
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index 553651a..31f403c 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -33,268 +33,281 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
  *     OpenYOLO Specification: Credential Deletion</a>
  */
 public final class CredentialDeleteResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
+    /**
+     * Indicates that no provider was available and able to handle the associated request.
+     */
+    public static final int CODE_NO_PROVIDER_AVAILABLE =
+            Protobufs.CredentialDeleteResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
+
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult UNKNOWN =
             new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
 
+    /**
+     * Pre-built deletion result that indicates that no provider was available and able to handle
+     * the associated request.
+     */
+    public static final CredentialDeleteResult NO_PROVIDER_AVAILABLE =
+            new CredentialDeleteResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
+
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
     private static final String UNABLE_TO_EXTRACT_RESULT =
             "Unable to extract or parse the credential deletion result";
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), IllegalArgumentException.class);
 
         return new CredentialDeleteResult.Builder(proto).build();
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
      * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
     public static CredentialDeleteResult fromResultIntentData(
             @Nullable Intent intent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_RESULT,
                         Protobufs.CredentialDeleteResult.parser(),
                         UNABLE_TO_EXTRACT_RESULT,
                         intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_DELETED == mResultCode;
     }
 
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * credential deletion result, if available.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
     public Intent toResultDataIntent() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
          * @throws MalformedDataException if the protocol buffer could not be parsed from the
          *     intent.
          */
         private Builder(Protobufs.CredentialDeleteResult proto) throws MalformedDataException {
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion result. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index e711e11..a055ffb 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -49,363 +49,363 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
 public class CredentialRetrieveRequest implements Parcelable {
 
     @VisibleForTesting
     static final Boolean DEFAULT_REQUIRE_USER_MEDIATION_VALUE = false;
 
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
-    public static CredentialRetrieveRequest forAuthenticationMethods(
+    public static CredentialRetrieveRequest fromAuthMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
-    public static CredentialRetrieveRequest forAuthenticationMethods(
+    public static CredentialRetrieveRequest fromAuthMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
             @NonNull Protobufs.CredentialRetrieveRequest proto) throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
      * @throws MalformedDataException if the intent does not contain a retrieve request, or the
      *     contained request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
             throws MalformedDataException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
             throw new MalformedDataException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
     @NonNull
     private final boolean mRequireUserMediation;
 
     private CredentialRetrieveRequest(Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalParams);
         mRequireUserMediation = builder.mRequireUserMediation;
     }
 
     /**
      * The set of authentication methods that the requester supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The set of token providers that the requester supports. These are used by the
      * credential provider and the OpenYOLO client library to attempt to acquire a "proof of access"
      * ID token for any returned credential.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * Specifies if the provider MUST have the user interact before a successful response is
      * returned.
      */
     @NonNull
     public boolean getRequireUserMediation() {
         return mRequireUserMediation;
     }
 
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .setRequireUserMediation(mRequireUserMediation)
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
         private boolean mRequireUserMediation = DEFAULT_REQUIRE_USER_MEDIATION_VALUE;
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided credential retrieve request.
          */
         public Builder(CredentialRetrieveRequest request) {
             mAuthMethods = request.mAuthMethods;
             mTokenProviders = request.mTokenProviders;
             mAdditionalParams = request.mAdditionalProps;
             mRequireUserMediation = request.mRequireUserMediation;
         }
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          * @throws MalformedDataException if the given protocol buffer is not valid.
          */
         private Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
 
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
 
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
 
                 setRequireUserMediation(requestProto.getRequireUserMediation());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies if the provider MUST require user interaction before returning a successful
          * response.
          */
         public Builder setRequireUserMediation(boolean value) {
             mRequireUserMediation = value;
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
 
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public CredentialRetrieveRequest build() {
             return new CredentialRetrieveRequest(this);
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return CredentialRetrieveRequest.fromProtobufBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index e435e95..5397a57 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -27,2 +27,3 @@ import java.util.HashMap;
 import java.util.Map;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveResult.ResultCode;
 import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
@@ -32,269 +33,288 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
  *     OpenYOLO Specification: Credential Retrieval</a>
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
+    /**
+     * Indicates that no provider was available and able to handle the associated request.
+     */
+    public static final int CODE_NO_PROVIDER_AVAILABLE = ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
+
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that a credential was successfully chosen and has been returned as part of this
      * response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
+    /**
+     * Pre-built result that indicates that the provider returned a response that could not be
+     * interpreted.
+     */
+    public static final CredentialRetrieveResult UNKNOWN =
+            new CredentialRetrieveResult.Builder(CODE_UNKNOWN).build();
+
+    /**
+     * Pre-built result that indicates that no provider was available and able to handle the
+     * associated request.
+     */
+    public static final CredentialRetrieveResult NO_PROVIDER_AVAILABLE =
+            new CredentialRetrieveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
+
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_CREDENTIAL_SELECTED == mResultCode;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          * @throws MalformedDataException if the given protocol buffer was invalid.
          */
         private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setCredentialFromProto(proto.getCredential());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
                 throws MalformedDataException {
             if (null == credential
                     || Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = null;
             } else {
                 mCredential = Credential.fromProtobuf(credential);
             }
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index b3f1328..c06c8b6 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -31,243 +31,256 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential save request. Contains a result code,
  * indicating whether the request was successful or not, and an optional set of additional,
  * non-standard result properties.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credential</a>
  */
 public final class CredentialSaveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
 
+    /**
+     * Indicates that no provider was available and able to handle the associated request.
+     */
+    public static final int CODE_NO_PROVIDER_AVAILABLE =
+            Protobufs.CredentialSaveResult.ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
+
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential sent to the provider was saved.
      */
     public static final int CODE_SAVED =
             Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
 
     /**
      * Indicates the provider refused to save the credential, due to some policy restriction. For
      * example, a provider may refuse to update an existing credential if it is stored in a shared
      * keychain. The client SHOULD NOT request to save this credential again.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to delete the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates the user refused the request to save this credential. The client SHOULD NOT request
      * to save this credential again.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built save result for an unspecified outcome. Carries no additional properties.
      */
-    public static final CredentialSaveResult UNSPECIFIED =
+    public static final CredentialSaveResult UNKNOWN =
             new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
 
+    /**
+     * Pre-built save result that indicates that no provider was available and able to handle the
+     * associated request.
+     */
+    public static final CredentialSaveResult NO_PROVIDER_AVAILABLE =
+            new CredentialSaveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
+
     /**
      * Pre-built save result that indicates the credential was saved. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult SAVED =
             new CredentialSaveResult.Builder(CODE_SAVED).build();
 
     /**
      * Pre-built save result that indicates the request was malformed. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult BAD_REQUEST =
             new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to save the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final CredentialSaveResult USER_CANCELED =
             new CredentialSaveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the user. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult USER_REFUSED =
             new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the provider. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult PROVIDER_REFUSED =
             new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     private final int mResultCode;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential save result from its protocol buffer equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialSaveResult.Builder(proto).build();
     }
 
     /**
      * Creates a protocol buffer representation of the credential save result, for transmission
      * or storage.
      */
     public Protobufs.CredentialSaveResult toProtobuf() {
         Protobufs.CredentialSaveResult.Builder builder =
                 Protobufs.CredentialSaveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProperties);
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential save result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_SAVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     private CredentialSaveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProperties = builder.mAdditionalProps;
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_SAVED == mResultCode;
     }
 
 
     /**
      * The result code for the credential save operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link CredentialSaveResult} instances.
      */
     public static final class Builder {
         private int mResultCode = CODE_UNKNOWN;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result given the mandatory status
          * code.
          * @throws MalformedDataException if the given protocol buffer was not valid.
          */
         private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 proto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Seeds a credential save result from its protocol buffer equivalent.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
             return this;
         }
 
         /**
          * Finalizes the creation of the credential save result.
          */
         public CredentialSaveResult build() {
             return new CredentialSaveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
index d9b90c1..9fcf225 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -33,267 +33,279 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
  * of the request, and the response may contain a hint.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
 public final class HintRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN = ResultCode.UNSPECIFIED_VALUE;
 
+    /**
+     * Indicates that no provider was available and able to handle the associated request.
+     */
+    public static final int CODE_NO_PROVIDER_AVAILABLE = ResultCode.NO_PROVIDER_AVAILABLE_VALUE;
+
     /**
      * Indicates that the hint request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST = ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that a hint was successfully chosen and has been returned as part of this response.
      */
     public static final int CODE_HINT_SELECTED = ResultCode.HINT_SELECTED_VALUE;
 
     /**
      * Indicates that no hints are available that meet the requirements of the hint request.
      */
     public static final int CODE_NO_HINTS_AVAILABLE = ResultCode.NO_HINTS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user  canceled the selection of a hint in a manner that indicates they
      * wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that The user canceled the selection of a hint in a manner that indicates they do
      * not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED = ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built hint result for an unspecified outcome. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult UNKNOWN =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_UNKNOWN).build();
 
+    /**
+     * Pre-build hint result that indicates that no provider was available and able to handle the
+     * associated request.
+     */
+    public static final HintRetrieveResult NO_PROVIDER_AVAILABLE =
+            new HintRetrieveResult.Builder(CODE_NO_PROVIDER_AVAILABLE).build();
+
     /**
      * Pre-built hint result for a bad request. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult BAD_REQUEST =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built hint result for when no hints are available. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult NO_HINTS_AVAILABLE =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_NO_HINTS_AVAILABLE).build();
 
     /**
      * Pre-built hint result for when the user requests manual authentication. Carries no hint
      * or additional properties.
      */
     public static final HintRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH)
                     .build();
 
     /**
      * Pre-built hint result for when the user canceled the selection of a hint in a manner that
      * indicates they do not wish to authenticate at this time. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult USER_CANCELED =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_USER_CANCELED).build();
 
     /**
      * Creates a hint result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto)
             throws MalformedDataException {
         return new HintRetrieveResult.Builder(proto).build();
     }
 
     /**
      * Creates a hint result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobufBytes(byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Hint mHint;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private HintRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mHint = builder.mHint;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint retrieve result, for transmission or
      * storage.
      */
     public Protobufs.HintRetrieveResult toProtobuf() {
         Protobufs.HintRetrieveResult.Builder builder =
                 Protobufs.HintRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mHint != null) {
             builder.setHint(mHint.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this hint retrieve result, that a provider should
      * return as its hint activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_HINT_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Returns {@code true} if the request was successful.
      */
     public boolean isSuccessful() {
         return CODE_HINT_SELECTED == mResultCode;
     }
 
     /**
      * The hint retrieve result code.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The hint returned as part of the hint result, if available.
      */
     @Nullable
     public Hint getHint() {
         return mHint;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * hint result, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link HintRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @Nullable
         private Hint mHint;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a hint retrieve result, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(@NonNull Protobufs.HintRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
                 setHintFromProto(proto.getHint());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a hint retrieve result, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the returned hint, if available.
          */
         public Builder setHint(@Nullable Hint hint) {
             mHint = hint;
             return this;
         }
 
         private Builder setHintFromProto(@Nullable Protobufs.Hint hint)
                 throws MalformedDataException {
             if (null == hint || Protobufs.Hint.getDefaultInstance().equals(hint)) {
                 mHint = null;
             } else {
                 mHint = Hint.fromProtobuf(hint);
             }
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. A null map is treated as an empty map. For a non-null map, all keys and values
          * must not be null, and the keys must not be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the hint retrieve result, from the specified properties.
          */
         public HintRetrieveResult build() {
             return new HintRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/IntentUtil.java b/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
index 89008d6..3c7326e 100644
--- a/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
+++ b/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
@@ -17,9 +17,9 @@ package org.openyolo.protocol.internal;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.valid4j.Assertive.ensure;
 import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
 import android.content.Intent;
+import android.os.BadParcelableException;
 import android.os.Parcel;
 import android.support.annotation.NonNull;
-
 import com.google.protobuf.ByteString;
@@ -27,49 +27,57 @@ import com.google.protobuf.ByteString;
 /**
  * Utilities for manipulating intents for use in protocol buffers.
  */
 public final class IntentUtil {
 
     private IntentUtil() {
         throw new IllegalStateException("not intended to be constructed");
     }
 
     /**
      * Serializes the provided intent to a byte array.
      */
     @NonNull
     public static byte[] toBytes(@NonNull Intent intent) {
         require(intent, notNullValue());
 
         Parcel parcel = Parcel.obtain();
         parcel.writeParcelable(intent, 0);
         byte[] intentBytes = parcel.marshall();
         parcel.recycle();
 
         return intentBytes;
     }
 
     /**
      * Serializes the provided intent to a ByteString, for use with a protocol buffer.
      */
     public static ByteString toByteString(@NonNull Intent intent) {
         require(intent, notNullValue());
         return ByteString.copyFrom(toBytes(intent));
     }
 
     /**
      * Deserializes an intent from the provided bytes array.
+     * @throws BadParcelableException if the intent is null, not present, or malformed.
      */
     @NonNull
-    public static Intent fromBytes(@NonNull byte[] intentBytes) {
+    public static Intent fromBytes(@NonNull byte[] intentBytes) throws BadParcelableException {
         require(intentBytes, notNullValue());
 
-        Parcel parcel = Parcel.obtain();
-        parcel.unmarshall(intentBytes, 0, intentBytes.length);
-        parcel.setDataPosition(0);
-        Intent intent = parcel.readParcelable(IntentUtil.class.getClassLoader());
-        parcel.recycle();
+        Intent intent;
+
+        try {
+            Parcel parcel = Parcel.obtain();
+            parcel.unmarshall(intentBytes, 0, intentBytes.length);
+            parcel.setDataPosition(0);
+            intent = parcel.readParcelable(IntentUtil.class.getClassLoader());
+            parcel.recycle();
+        } catch (Exception ex) {
+            throw new BadParcelableException(ex);
+        }
+
+        validate(intent, notNullValue(), BadParcelableException.class);
 
-        ensure(intent, notNullValue());
         return intent;
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 1b7c97e..059a9f3 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -35,119 +35,119 @@ import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 /**
  * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
         ValidTokenProviderMap.assertEquals(request.getTokenProviders());
         ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         CredentialRetrieveRequest.fromProtobuf(null);
     }
 
     @Test
     public void testWriteAndRead() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(ValidTokenProviderMap.make())
                 .setAdditionalProperties(ValidAdditionalProperties.make())
                 .setRequireUserMediation(true)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             ValidTokenProviderMap.assertEquals(deserialized.getTokenProviders());
             ValidAdditionalProperties.assertEquals(deserialized.getAdditionalProperties());
             assertThat(deserialized.getRequireUserMediation()).isTrue();
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
-            .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
+            .fromAuthMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
-        CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
+        CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
 
     @Test
     public void toProtocolBuffer_usingDefaultBuilder_returnsExpectedValues() {
         CredentialRetrieveRequest request =
                 new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL).build();
 
         Protobufs.CredentialRetrieveRequest protoRequest = request.toProtocolBuffer();
 
         assertThat(protoRequest.getRequireUserMediation())
                 .isEqualTo(CredentialRetrieveRequest.DEFAULT_REQUIRE_USER_MEDIATION_VALUE);
     }
 
     @Test
     public void toProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
-            CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(
+            CredentialRetrieveRequest request = CredentialRetrieveRequest.fromAuthMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java b/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
index 87462d3..5f817d9 100644
--- a/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
+++ b/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
@@ -19,2 +19,3 @@ package org.openyolo.protocol.internal;
 
+import static junit.framework.Assert.fail;
 import static junit.framework.TestCase.assertTrue;
@@ -23,2 +24,4 @@ import static org.junit.Assert.assertEquals;
 import android.content.Intent;
+import android.os.BadParcelableException;
+import android.os.Parcel;
 import org.junit.Test;
@@ -30,40 +33,98 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for IntentUtilTest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class IntentUtilTest {
 
     @Test(expected = RequireViolation.class)
     public void testToBytes_null() throws Exception {
         IntentUtil.toBytes(null);
     }
 
     @Test
     public void toBytes() throws Exception {
         Intent intent = new Intent("com.openyolo");
         byte[] result = IntentUtil.toBytes(intent);
         assertEquals(result.length, 235);
         //comparing a few random locations
         assertEquals(result[0], -84);
         assertEquals(result[8], 0);
         assertEquals(result[16], 22);
         assertEquals(result[32], 46);
         assertEquals(result[64], 0);
         assertEquals(result[128], -107);
         assertEquals(result[234], -1);
     }
 
     @Test
     public void fromBytes() throws Exception {
         Intent fromIntent = new Intent("com.openyolo.ACTION");
         fromIntent.setPackage("com.openyolo");
         byte[] fromBytes = IntentUtil.toBytes(fromIntent);
 
-        Intent toIntent= IntentUtil.fromBytes(fromBytes);
+        Intent toIntent = IntentUtil.fromBytes(fromBytes);
         assertTrue(toIntent.getAction().equals(fromIntent.getAction()));
         assertTrue(toIntent.getPackage().equals(fromIntent.getPackage()));
+    }
+
+    @Test
+    public void fromBytes_withNullIntent_throwsBadParcelableException() {
+        byte[] intentBytes = toBytesUnchecked(null);
+
+
+        assertThrows(BadParcelableException.class, () -> {
+            IntentUtil.fromBytes(intentBytes);
+        });
+    }
+
+    @Test
+    public void fromBytes_withIntentNotPresent_throwsBadParcelableException() {
+        byte[] intentBytes = new byte[10];
+
 
+        assertThrows(BadParcelableException.class, () -> {
+            IntentUtil.fromBytes(intentBytes);
+        });
     }
 
+    private static byte[] toBytesUnchecked(Intent intent) {
+        Parcel parcel = Parcel.obtain();
+        parcel.writeParcelable(intent,0);
+        byte[] intentBytes = parcel.marshall();
+        parcel.recycle();
+
+        return intentBytes;
+    }
+
+    private interface Operation {
+        void execute();
+    }
+
+    private static void assertThrows(Class expectedExceptionType, Operation operation) {
+        try {
+            operation.execute();
+
+            // No exception was thrown.
+            String failureMessage =
+                    String.format(
+                            "No exception was thrown, expected a %s exception",
+                            expectedExceptionType);
+
+            fail(failureMessage);
+        } catch (Exception ex) {
+            if (expectedExceptionType.isInstance(ex)) {
+                // Expected exception was thrown.
+                return;
+            }
+
+            // An unexpected exception was thrown.
+            String failureMessage =
+                    String.format(
+                            "Expected exception to be instance of %s, but was %s",
+                            expectedExceptionType,
+                            ex.getClass());
+            fail(failureMessage);
+        }
+    }
 }
\ No newline at end of file
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index a48d754..80bfbd1 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -44,16 +44,18 @@ message CredentialRetrieveBbqResponseList {
 message CredentialRetrieveResult {
+
     enum ResultCode {
         UNSPECIFIED = 0;
         BAD_REQUEST = 1;
         CREDENTIAL_SELECTED = 2;
         NO_CREDENTIALS_AVAILABLE = 3;
         USER_REQUESTS_MANUAL_AUTH = 4;
         USER_CANCELED = 5;
+        NO_PROVIDER_AVAILABLE = 6;
     }
 
     // required
     ResultCode result_code = 1;
 
     Credential credential = 2;
     map<string, bytes> additional_props = 3;
 }
@@ -72,16 +74,18 @@ message HintRetrieveRequest {
 message HintRetrieveResult {
+
     enum ResultCode {
         UNSPECIFIED = 0;
         BAD_REQUEST = 1;
         HINT_SELECTED = 2;
         NO_HINTS_AVAILABLE = 3;
         USER_REQUESTS_MANUAL_AUTH = 4;
         USER_CANCELED = 5;
+        NO_PROVIDER_AVAILABLE = 6;
     }
 
     // required
     ResultCode result_code = 1;
 
     Hint hint = 2;
     map<string, bytes> additional_props = 3;
 }
@@ -98,16 +102,17 @@ message CredentialSaveRequest {
 message CredentialSaveResult {
 
     enum ResultCode {
         UNSPECIFIED = 0;
         BAD_REQUEST = 1;
         SAVED = 2;
         PROVIDER_REFUSED = 3;
         USER_CANCELED = 4;
         USER_REFUSED = 5;
+        NO_PROVIDER_AVAILABLE = 6;
     }
 
     // required
     ResultCode result_code = 1;
 
     map<string, bytes> additional_props = 2;
 }
@@ -124,16 +129,18 @@ message CredentialDeleteRequest {
 message CredentialDeleteResult {
+
     enum ResultCode {
         UNSPECIFIED = 0;
         BAD_REQUEST = 1;
         DELETED = 2;
         NO_MATCHING_CREDENTIAL = 3;
         PROVIDER_REFUSED = 4;
         USER_CANCELED = 5;
         USER_REFUSED = 6;
+        NO_PROVIDER_AVAILABLE = 7;
     }
 
     // required
     ResultCode result_code = 1;
 
     map<string, bytes> additional_props = 2;
 }
diff --git a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
index 0c6610b..bdb59a6 100644
--- a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
@@ -31,97 +31,94 @@ import org.openyolo.protocol.CredentialDeleteResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential deletion flow.
  */
 public class DeleteTestPageFragment extends TestPageFragment  {
 
     private static final int RC_DELETE = 100;
 
     @BindView(R.id.credential_to_delete)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.delete_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.delete_button)
     void onDelete() {
         Credential credential = mCredentialView.makeCredentialFromFields();
         if (credential == null) {
             showSnackbar(R.string.invalid_credential_data);
             return;
         }
 
-        Intent deleteIntent = mApi.getDeleteIntent(credential);
-        if (deleteIntent == null) {
-            showSnackbar(R.string.no_available_delete_providers);
-            return;
-        }
-
-        startActivityForResult(deleteIntent, RC_DELETE);
+        startActivityForResult(mApi.getDeleteIntent(credential), RC_DELETE);
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_DELETE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialDeleteResult deleteResult = mApi.getDeleteResult(data);
 
         @StringRes
         int resultMessageId;
         switch (deleteResult.getResultCode()) {
             case CredentialDeleteResult.CODE_DELETED:
                 resultMessageId = R.string.delete_result_deleted;
                 break;
+            case CredentialDeleteResult.CODE_NO_PROVIDER_AVAILABLE:
+                resultMessageId = R.string.delete_no_provider_available;
+                break;
             case CredentialDeleteResult.CODE_NO_MATCHING_CREDENTIAL:
                 resultMessageId = R.string.delete_result_no_matching_credential;
                 break;
             case CredentialDeleteResult.CODE_PROVIDER_REFUSED:
                 resultMessageId = R.string.delete_result_provider_refused;
                 break;
             case CredentialDeleteResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.delete_result_user_canceled;
                 break;
             case CredentialDeleteResult.CODE_USER_REFUSED:
                 resultMessageId = R.string.delete_result_user_refused;
                 break;
             case CredentialDeleteResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.delete_result_bad_request;
                 break;
             default:
                 resultMessageId = R.string.delete_result_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @Override
     public String getPageTitle() {
         return "Delete";
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index b24158e..c9bb8c6 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -34,113 +34,110 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.token_providers_input)
     TokenProviderInputView mTokenProviderInputView;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     @BindView(R.id.id_token_view)
     IdTokenView mIdTokenView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         // CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         HintRetrieveResult result = mApi.getHintRetrieveResult(data);
         Hint hint = result.getHint();
         if (hint != null) {
             mCredentialView.setFieldsFromHint(hint);
             mIdTokenView.setIdToken(hint.getIdToken());
             return;
         }
 
         int errorStringResId;
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 errorStringResId = R.string.hint_bad_request;
                 break;
+            case HintRetrieveResult.CODE_NO_PROVIDER_AVAILABLE:
+                errorStringResId = R.string.hint_no_provider_available;
+                break;
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 errorStringResId = R.string.hint_none_available;
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 errorStringResId = R.string.hint_user_canceled;
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 errorStringResId = R.string.hint_manual_auth;
                 break;
             default:
                 errorStringResId = R.string.hint_unknown_response;
         }
         showSnackbar(errorStringResId);
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
 
         HintRetrieveRequest request =
                 new HintRetrieveRequest.Builder(authenticationMethods)
                         .setTokenProviders(mTokenProviderInputView.getTokenProviders())
                         .build();
 
-        Intent hintIntent = mApi.getHintRetrieveIntent(request);
-        if (hintIntent == null) {
-            showSnackbar(R.string.no_available_hint_providers);
-            return;
-        }
-
-        startActivityForResult(hintIntent, RC_HINT);
+        startActivityForResult(mApi.getHintRetrieveIntent(request), RC_HINT);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index cac75c3..5c903eb 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -16,3 +16,2 @@ package org.openyolo.testapp;
 
-import android.content.ActivityNotFoundException;
 import android.content.Intent;
@@ -25,3 +24,2 @@ import android.view.ViewGroup;
 import android.widget.CheckBox;
-
 import butterknife.BindView;
@@ -30,5 +28,3 @@ import butterknife.OnClick;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
 import org.openyolo.api.CredentialClient;
-import org.openyolo.api.RetrieveCallback;
 import org.openyolo.protocol.AuthenticationMethod;
@@ -37,149 +33,120 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
-import org.openyolo.protocol.RetrieveBbqResponse;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.token_providers_input)
     TokenProviderInputView mTokenProviderInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     @BindView(R.id.require_user_mediation_check_box)
     CheckBox mRequireUserMediationCheckBox;
 
     @BindView(R.id.id_token_view)
     IdTokenView mIdTokenView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         Credential credential = result.getCredential();
         if (credential != null) {
             mCredentialView.setFieldsFromCredential(credential);
             mIdTokenView.setIdToken(credential.getIdToken());
             return;
         }
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 resultMessageId = R.string.retrieve_no_credentials;
                 break;
+            case CredentialRetrieveResult.CODE_NO_PROVIDER_AVAILABLE:
+                resultMessageId = R.string.retrieve_no_provider_available;
+                break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.retrieve_bad_request;
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.retrieve_user_canceled;
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 resultMessageId = R.string.retrieve_manual_auth;
                 break;
             default:
                 resultMessageId = R.string.retrieve_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         CredentialRetrieveRequest.Builder requestBuilder =
                 new CredentialRetrieveRequest.Builder(authenticationMethods)
                         .setTokenProviders(mTokenProviderInputView.getTokenProviders());
 
         if (mRequireUserMediationCheckBox.isChecked()) {
             requestBuilder.setRequireUserMediation(true);
         }
 
-        mApi.retrieve(requestBuilder.build(), new HandleRetrieveResult());
+        startActivityForResult(
+                mApi.getCredentialRetrieveIntent(requestBuilder.build()),
+                RC_RETRIEVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
-
-    private class HandleRetrieveResult implements RetrieveCallback, Runnable {
-
-        private final AtomicReference<RetrieveBbqResponse> mResult = new AtomicReference<>();
-        private final AtomicReference<Throwable> mError = new AtomicReference<>();
-
-        @Override
-        public void onComplete(RetrieveBbqResponse result, Throwable error) {
-            mResult.set(result);
-            mError.set(error);
-            getActivity().runOnUiThread(this);
-        }
-
-        @Override
-        public void run() {
-            if (mError.get() != null) {
-                showSnackbar(R.string.request_failed);
-                return;
-            }
-
-            RetrieveBbqResponse result = mResult.get();
-            if (result.getRetrieveIntent() == null) {
-                showSnackbar(R.string.retrieve_no_credentials);
-                return;
-            }
-
-            try {
-                startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
-            } catch (ActivityNotFoundException ex) {
-                showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
-            }
-        }
-    }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index 510855b..a585e15 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -33,98 +33,94 @@ import org.openyolo.protocol.CredentialSaveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
 public final class SaveTestPageFragment extends TestPageFragment {
 
     private static final String TAG = "SaveTestPageFragment";
     private static final int RC_SAVE = 0;
 
     @BindView(R.id.save_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Save";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.save_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.save_button)
     void onSave() {
         CredentialSaveRequest request;
         try {
             Credential credential = mCredentialView.makeCredentialFromFields();
             request = CredentialSaveRequest.fromCredential(credential);
         } catch (IllegalArgumentException ex) {
             Log.e(TAG, "Invalid argument: " + ex);
             showSnackbar(R.string.save_invalid_request);
             return;
         }
 
-        final Intent saveIntent = mApi.getSaveIntent(request);
-
-        if (saveIntent == null) {
-            showSnackbar(R.string.no_available_save_providers);
-            return;
-        }
-
-        startActivityForResult(saveIntent, RC_SAVE);
+        startActivityForResult(mApi.getSaveIntent(request), RC_SAVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_SAVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialSaveResult result = mApi.getCredentialSaveResult(data);
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 resultMessageId = R.string.save_result_saved;
                 break;
+            case CredentialSaveResult.CODE_NO_PROVIDER_AVAILABLE:
+                resultMessageId = R.string.save_no_provider_available;
+                break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.save_result_bad_request;
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 resultMessageId = R.string.save_result_provider_refused;
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.save_result_user_canceled;
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 resultMessageId = R.string.save_result_user_refused;
                 break;
             default:
                 resultMessageId = R.string.save_result_unknown;
         }
 
         showSnackbar(resultMessageId);
     }
 }
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index ef55078..550c05e 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,106 +1,106 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
+    <string name="retrieve_no_provider_available">No provider available for credential request</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
-    <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
     <string name="phone_authentication_method_checkbox_text">openyolo://phone</string>
     <string name="username_authentication_method_checkbox_text">openyolo://username</string>
 
     <string name="require_user_mediation_checkbox_text">Require User Mediation</string>
     <string name="retrieve_other_section_title">Other</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
 
     <string name="save_invalid_request">Invalid Save Request</string>
 
     <string name="save_result_unknown">Unknown save result</string>
+    <string name="save_no_provider_available">No provider available for save request</string>
     <string name="save_result_saved">Credential Saved</string>
     <string name="save_result_bad_request">Malformed save request</string>
     <string name="save_result_provider_refused">Provider refused save request</string>
     <string name="save_result_user_canceled">User canceled save request</string>
     <string name="save_result_user_refused">User refused save request</string>
 
-    <string name="no_available_save_providers">"No available providers can save this credential</string>
-
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
+
+    <string name="hint_unknown_response">Unknown hint response</string>
+    <string name="hint_no_provider_available">No provider available for hint request</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
-    <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
-    <string name="no_available_delete_providers">"No available providers can delete this credential</string>
+
+    <string name="delete_result_unknown_response">Unknown delete response</string>
+    <string name="delete_no_provider_available">"No provider available for this delete request</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
-    <string name="delete_result_unknown_response">Unknown delete response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
-    <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
 
     <!-- Other Test -->
     <string name="disable_auto_sign_in_button_label">Disable Auto Sign In</string>
     <string name="disable_auto_sign_in_button_content_description">Disable Auto Sign In</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
-    <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response Properties</string>
     <string name="request">Request Properties</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
-  <string name="token_providers_header">Supported token providers</string>
+    <string name="token_providers_header">Supported token providers</string>
     <string name="use_google_token_provider">Request Google ID tokens</string>
     <string name="token_provider_uri_field_hint">Token provider URI</string>
     <string name="client_id_field_hint">Client ID</string>
     <string name="nonce_field_hint">Nonce</string>
     <string name="clear_token_provider">Clear</string>
     <string name="no_token">No token returned</string>
     <string name="id_token_view_header">ID Token</string>
 
 </resources>

commit 9b6de28a44bd36e44b02da09090ff380d28f4642
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 6 11:04:36 2017 -0700

    - Added Hint.toCredentialBuilder() & Hint.Builder(Hint) (#89)
    
    - Merged TestFixtures into TestConstants

diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index de66d6d..de28034 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -51,475 +51,467 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
     private static final int MIN_PASSWORD_LENGTH = 4;
 
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
     public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
     public final ObservableBoolean showError = new ObservableBoolean(false);
 
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
     private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
         mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
         mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
             mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
      * Initiates an OpenYOLO credential retrieval request, and forwards the response to
      * {@link #handleRetrieveQueryResult(RetrieveBbqResponse, Throwable)} for processing.
      */
     private void tryRetrieveExistingCredential() {
         setShowLoading(R.string.existing_account_search_prompt);
         mCredentialClient.retrieve(
                 CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL),
                 (queryResponse, queryError) ->
                     getExecutor().execute(
                             () -> handleRetrieveQueryResult(queryResponse, queryError)));
     }
 
     /**
      * Inspects the initial response from the OpenYOLO retrieve request. If a retrieve intent
      * is available, this is used to attempt to source a credential from the provider. The result
      * of this is indirectly routed to {@link #handleRetrieveResult(Intent)}.
      *
      * If no intent is returned, an attempt is made to source an account hint instead.
      */
     private void handleRetrieveQueryResult(
             RetrieveBbqResponse queryResponse,
             Throwable queryError) {
         if (queryResponse != null && queryResponse.getRetrieveIntent() != null) {
             Log.i(TAG, "retrieving credential from provider");
             mNavigator.get().startOpenYoloRetrieve(queryResponse.getRetrieveIntent());
             return;
         }
 
         Log.i(TAG, "no OpenYOLO providers for retrieve");
         tryRetrieveHint();
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
                 boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
                         credential.getPassword());
                 if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.of(AuthenticationMethods.EMAIL));
 
         if (hintIntent != null) {
             setShowLoading(R.string.requesting_hint_prompt);
             mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
                         hint.getDisplayPictureUri());
                 String hintPassword = hint.getGeneratedPassword();
 
 
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
                 boolean authenticated = false;
 
                 if (hintPassword != null) {
                     authenticated = mUserDataSource.createPasswordAccount(
                             hintEmail, displayName, displayPicture, hintPassword);
 
                     if (authenticated) {
                         // account created, attempt to save it back to the OpenYOLO provider
-                        trySaveCredential(
-                                new Credential.Builder(
-                                        hintEmail,
-                                        AuthenticationMethods.EMAIL,
-                                        AuthenticationDomain.getSelfAuthDomain(mApplication))
-                                        .setDisplayName(displayName)
-                                        .setDisplayPicture(displayPicture)
-                                        .setPassword(hintPassword)
-                                        .build());
+                        trySaveCredential(hint.toCredentialBuilder(mApplication).build());
                     }
                 }
 
                 if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
 
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
     public void signInButtonClicked(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
         if (userPassword.length() < MIN_PASSWORD_LENGTH) {
             passwordError.set(getResourceString(R.string.error_password_too_short));
             return;
         } else {
             emailError.set("");
         }
 
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
                     null, // name
                     null, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 showError.set(true);
             }
         }
     }
 
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
             mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
         mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
         mNavigator.get().goToMain();
     }
 
     private void setShowLoading(@StringRes int loadingLabelId) {
         setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
     private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
         showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
         showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Hint.java b/protocol/java/org/openyolo/protocol/Hint.java
index 8f0d3c0..5722eed 100644
--- a/protocol/java/org/openyolo/protocol/Hint.java
+++ b/protocol/java/org/openyolo/protocol/Hint.java
@@ -24,2 +24,3 @@ import static org.valid4j.Validation.validate;
 
+import android.content.Context;
 import android.net.Uri;
@@ -39,360 +40,386 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a hint for use in account discovery or account creation. This provides a
  * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential protocol
  * buffer} that is returned by the provider.
  *
  * <p>Hints must have an {@link #getIdentifier() identifier} and an
  * an {@link #getAuthenticationMethod() authentication method}, but all other properties are
  * optional.
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
  *     OpenYOLO specification: Hint</a>
  */
 public final class Hint implements Parcelable {
 
     /**
      * Parcelable reader for {@link Hint} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Hint> CREATOR = new HintCreator();
 
     /**
      * Creates a hint from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static Hint fromProtobuf(Protobufs.Hint proto) throws MalformedDataException {
         return new Hint.Builder(proto).build();
     }
 
     /**
      * Creates a hint from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the protocol buffer cannot be parsed from the byte array.
      */
     public static Hint fromProtobufBytes(byte[] protoBytes) throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
         try {
             return fromProtobuf(Protobufs.Hint.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPictureUri;
 
     @Nullable
     private final String mGeneratedPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Hint(Hint.Builder builder) {
         mId = builder.mId;
         mAuthMethod = builder.mAuthMethod;
         mDisplayName = builder.mDisplayName;
         mDisplayPictureUri = builder.mDisplayPictureUri;
         mGeneratedPassword = builder.mGeneratedPassword;
         mIdToken = builder.mIdToken;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint, for transmission or storage.
      */
     public Protobufs.Hint toProtobuf() {
         Protobufs.Hint.Builder builder = Protobufs.Hint.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPictureUri != null) {
             builder.setDisplayPictureUri(mDisplayPictureUri.toString());
         }
 
         if (mGeneratedPassword != null) {
             builder.setGeneratedPassword(mGeneratedPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
+    /**
+     * Returns a {@link Credential.Builder} representation of the hint.
+     */
+    public Credential.Builder toCredentialBuilder(Context context) {
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(context);
+        return new Credential.Builder(mId, mAuthMethod, authDomain)
+                .setDisplayName(mDisplayName)
+                .setDisplayPicture(mDisplayPictureUri)
+                .setPassword(mGeneratedPassword)
+                .setIdToken(mIdToken)
+                .setAdditionalProperties(getAdditionalProperties());
+    }
+
     /**
      * The hint identifier, for use in discovering an existing account within the context of the
      * authentication method and authentication domain (which is implicitly that of the requester),
      * or creating a new account.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication domain associated with the hint.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * A suggested display name for accounts created using this hint, if available.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * A suggested profile picture for accounts created using this hint. if available.
      */
     @Nullable
     public Uri getDisplayPictureUri() {
         return mDisplayPictureUri;
     }
 
     /**
      * A suggested password for use with accounts created using this hint, if available.
      */
     @Nullable
     public String getGeneratedPassword() {
         return mGeneratedPassword;
     }
 
     /**
      * An ID token that provides "proof of access" to the hint identifier, if available.
      * When provided this can be used either as a means of authentication in its
      * own right, or as a means to bypass manual proof of access verification, such as by sending
      * an email with a verification link or an SMS with a code.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the hint.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] hintBytes = toProtobuf().toByteArray();
         dest.writeInt(hintBytes.length);
         dest.writeByteArray(hintBytes);
     }
 
     /**
      * Creates instances of {@link Hint}.
      */
     public static final class Builder {
 
         @NonNull
         private String mId;
 
         @NonNull
         private AuthenticationMethod mAuthMethod;
 
         @Nullable
         private String mDisplayName;
 
         @Nullable
         private Uri mDisplayPictureUri;
 
         @Nullable
         private String mGeneratedPassword;
 
         @Nullable
         private String mIdToken;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull AuthenticationMethod authMethod) {
             setIdentifier(id);
             setAuthMethod(authMethod);
         }
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull String authMethod) {
             this(id, new AuthenticationMethod(authMethod));
         }
 
+        /**
+         * Starts the process of creating a hint using an already built hint.
+         */
+        public Builder(Hint hint) {
+            setIdentifier(hint.mId);
+            setAuthMethod(hint.mAuthMethod);
+            setDisplayName(hint.mDisplayName);
+            setDisplayPictureUri(hint.mDisplayPictureUri);
+            setGeneratedPassword(hint.mGeneratedPassword);
+            setIdToken(hint.mIdToken);
+            setAdditionalPropertiesFromProto(hint.mAdditionalProps);
+        }
+
         /**
          * Starts the process of creating a hint, based on the properties of the provided
          * protocol buffer representation of the credential. The protocol buffer must contain
          * valid data for a hint.
          */
         private Builder(@NonNull Protobufs.Hint proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setIdentifier(proto.getId());
                 setAuthMethod(proto.getAuthMethod().getUri());
                 setDisplayName(proto.getDisplayName());
                 setDisplayPictureUri(proto.getDisplayPictureUri());
                 setGeneratedPassword(proto.getGeneratedPassword());
                 setIdToken(proto.getIdToken());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the identifier for the hint. Must not be null or empty.
          */
         public Builder setIdentifier(@NonNull String id) {
             validate(id, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = id;
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint, in string form. Must be a valid
          * authentication method URI.
          *
          * @see AuthenticationMethod
          */
         public Builder setAuthMethod(@NonNull String authMethod) {
             validate(authMethod, isValidAuthenticationMethod(), IllegalArgumentException.class);
             mAuthMethod = new AuthenticationMethod(authMethod);
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint. Must not be null.
          */
         public Builder setAuthMethod(@NonNull AuthenticationMethod authMethod) {
             validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the display name for the hint. Empty values are treated as null.
          */
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Empty values are
          * treated as null. Non-empty values must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable String displayPictureUri) {
             setDisplayPictureUri(nullifyEmptyString(displayPictureUri) != null
                             ? Uri.parse(displayPictureUri)
                             : null);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Non-null values
          * must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable Uri displayPictureUri) {
             validate(displayPictureUri, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPictureUri = displayPictureUri;
             return this;
         }
 
         /**
          * Specifies the generated password for the hint. Empty values are treated as null.
          */
         public Builder setGeneratedPassword(@Nullable String generatedPassword) {
             mGeneratedPassword = nullifyEmptyString(generatedPassword);
             return this;
         }
 
         /**
          * Specifies the "proof of access" ID token for the hint. Empty values are treated as null.
          */
         public Builder setIdToken(@Nullable String idToken) {
             mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the hint.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 @Nullable Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the {@link Hint hint} instance with the specified properties.
          */
         public Hint build() {
             return new Hint(this);
         }
     }
 
     private static final class HintCreator implements Creator<Hint> {
 
         @Override
         public Hint createFromParcel(Parcel source) {
             int length = source.readInt();
             byte[] hintBytes = new byte[length];
             source.readByteArray(hintBytes);
             try {
                 return Hint.fromProtobufBytes(hintBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalArgumentException("Unable to parse hint from parcel", ex);
             }
         }
 
         @Override
         public Hint[] newArray(int size) {
             return new Hint[size];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
index 7c5a569..9a8fa61 100644
--- a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
+++ b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
@@ -21,3 +21,2 @@ import static org.assertj.core.api.Java6Assertions.failBecauseExceptionWasNotThr
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
@@ -25,5 +24,2 @@ import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.Signature;
@@ -32,7 +28,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.openyolo.protocol.TestConstants.ValidApplication;
+import org.openyolo.protocol.TestConstants.ApplicationWithMultipleSignatures;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
@@ -40,202 +35,137 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link AuthenticationDomain}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AuthenticationDomainTest {
 
     private static final String WEB_AUTH_DOMAIN_STR = "https://www.example.com";
 
-    private static final String VALID_PACKAGE_NAME = "com.example.app";
-
-    private static byte[] VALID_SIGNATURE_BYTES = new byte[]
-            { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
-
-    private static final String VALID_FINGERPRINT =
-            "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
-                    + "7V4Lo8BdCxaA307H0HYkAw==";
-
-    private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
-            "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
-
-    private static final PackageInfo VALID_PACKAGE_INFO = makeValidPackageInfo();
-
-    private static PackageInfo makeValidPackageInfo() {
-        PackageInfo packageInfo = new PackageInfo();
-        packageInfo.signatures = new Signature[1];
-        packageInfo.signatures[0] = new Signature(VALID_SIGNATURE_BYTES);
-
-        return packageInfo;
-    }
-
-    private static final class ValidAuthDomain {
-        private static final String VALID_PACKAGE_NAME = "com.example.app";
-        private static final String VALID_FINGERPRINT =
-                "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
-                        + "7V4Lo8BdCxaA307H0HYkAw==";
-
-        private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
-                "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
-        public static final AuthenticationDomain INSTANCE =
-                new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING);
-    }
-
-    @Mock
-    PackageManager mockPackageManager;
-    @Mock
-    Context mockContext;
+    Context mContext;
 
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
-                .thenReturn(VALID_PACKAGE_INFO);
-        when(mockContext.getPackageName()).thenReturn(VALID_PACKAGE_NAME);
-        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+        mContext = ValidApplication.install(RuntimeEnvironment.application);
     }
 
     @Test
-    public void fromProtobufBytes_withValidInput_returnsEquivalent() throws Exception {
-        byte[] encodedAuthDomain = ValidAuthDomain.INSTANCE.toProtobuf().toByteArray();
+    public void toProtobufBytes_fromProtobufBytes_isEquivalent() throws Exception {
+        byte[] encodedAuthDomain = ValidApplication.AuthDomain.make().toProtobuf().toByteArray();
 
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.fromProtobufBytes(encodedAuthDomain);
 
-        assertThat(authenticationDomain).isEqualTo(ValidAuthDomain.INSTANCE);
+        assertThat(authenticationDomain).isEqualTo(ValidApplication.AuthDomain.make());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_withMalformedBytes_throwsMalformedDataException() throws Exception {
         AuthenticationDomain.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_withInvalidUri_throwsInvalidProtoBufferException() throws Exception {
         byte[] invalidProtoBytes =
                 Protobufs.AuthenticationDomain.newBuilder()
                         .setUri("Invalid uri")
                         .build()
                         .toByteArray();
 
         AuthenticationDomain.fromProtobufBytes(invalidProtoBytes);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_withInvalidUri_throwsInvalidProtoBufferException() throws Exception {
         Protobufs.AuthenticationDomain invalidProto =
             Protobufs.AuthenticationDomain.newBuilder()
                 .setUri("Invalid uri")
                 .build();
 
         AuthenticationDomain.fromProtobuf(invalidProto);
     }
 
     @Test
     public void getSelfAuthDomain_withValidInput_returnsValidDomain() throws Exception {
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mContext);
 
-        assertThat(authDomain).isNotNull();
-        assertThat(authDomain.isAndroidAuthDomain()).isTrue();
-        assertThat(authDomain.toString())
-                .isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
+        ValidApplication.AuthDomain.assertEquals(authDomain);
     }
 
     @Test
     public void fromPackageName_forValidPackage_containsValidAuthenticationDomain() {
-        assertThat(AuthenticationDomain.fromPackageName(mockContext, VALID_PACKAGE_NAME))
-                .isEqualTo(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.fromPackageName(mContext, ValidApplication.PACKAGE_NAME);
+
+        ValidApplication.AuthDomain.assertEquals(authenticationDomain);
     }
 
     @Test
     public void fromPackageName_packageDoesNotExist_returnsNull() throws Exception {
-        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
-                .thenThrow(NameNotFoundException.class);
-
-        assertThat(AuthenticationDomain.fromPackageName(mockContext, VALID_PACKAGE_NAME)).isNull();
+        assertThat(AuthenticationDomain.fromPackageName(mContext, "does.not.exist")).isNull();
     }
 
     @Test
     public void fromPackageName_hasMultipleSignatures_returnsNull() throws Exception {
-        PackageInfo packageInfo = new PackageInfo();
-        packageInfo.signatures = new Signature[2];
+        Context context = ApplicationWithMultipleSignatures.install(RuntimeEnvironment.application);
 
-        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
-                .thenReturn(packageInfo);
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.fromPackageName(
+                        context,
+                        ApplicationWithMultipleSignatures.PACKAGE_NAME);
 
-        assertThat(AuthenticationDomain.fromPackageName(mockContext, VALID_PACKAGE_NAME)).isNull();
+        assertThat(authenticationDomain).isNull();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void CreateAndroidAuthDomain_withNullDomain_throwsIllegalArgumentException()
             throws Exception{
         AuthenticationDomain.createAndroidAuthDomain(null /* authDomain */, mock(Signature.class));
     }
 
     @Test
     public void validWebAuthDomain_hasExpectedBehaviour() {
         AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
 
         assertThat(authDomain.isAndroidAuthDomain()).isFalse();
         assertThat(authDomain.isWebAuthDomain()).isTrue();
 
         try {
             authDomain.getAndroidPackageName();
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
-    public void validAndroidAuthDomain_hasExpectedBehaviour(){
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-
-        assertThat(authDomain.isAndroidAuthDomain()).isTrue();
-        assertThat(authDomain.isWebAuthDomain()).isFalse();
-
-        assertThat(authDomain.getAndroidPackageName()).isEqualTo(VALID_PACKAGE_NAME);
-    }
-
-    @Test
-    public void getSelfAuthDomain_packageNotFoundException_throwsException() throws Exception {
-        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
-            .thenAnswer(new Answer<PackageInfo>() {
-                @Override
-                public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
-                    throw new NameNotFoundException();
-                }
-            });
-
-        try {
-            AuthenticationDomain.getSelfAuthDomain(mockContext);
+    public void getAndroidPackageName_withAndroidAuthDomain(){
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mContext);
 
-            failBecauseExceptionWasNotThrown(IllegalStateException.class);
-        } catch (IllegalStateException ex) {}
+        assertThat(authDomain.getAndroidPackageName()).isEqualTo(ValidApplication.PACKAGE_NAME);
     }
 
     @Test
     public void equals_withEquivalent_returnsTrue() throws Exception {
-        AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mContext);
+        AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mContext);
 
         assertThat(authDomainA).isEqualTo(authDomainA);
         assertThat(authDomainA).isEqualTo(authDomainB);
 
         assertThat(authDomainA.compareTo(authDomainB)).isEqualTo(0);
     }
 
     @Test
     public void equals_withDifferentType_returnsFalse() throws Exception {
         AuthenticationDomain domain = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
         assertThat(domain).isNotEqualTo(WEB_AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testHashCode_equivalent() throws Exception {
         AuthenticationDomain authDomainA = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
         AuthenticationDomain authDomainB = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
 
         assertThat(authDomainA.hashCode()).isEqualTo(authDomainB.hashCode());
     }
 
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
index f18f012..ad67880 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
@@ -16,8 +16,3 @@ package org.openyolo.protocol;
 
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROPS;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_VALUE;
-import static org.openyolo.protocol.TestConstants.checkAdditionalProps;
-import static org.openyolo.protocol.TestConstants.checkAdditionalPropsFromProto;
+import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 
@@ -27,2 +22,4 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
+import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
 import org.robolectric.RobolectricTestRunner;
@@ -31,152 +28,125 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteRequestTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteRequest INVALID_PROTO =
             Protobufs.CredentialDeleteRequest.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
-    private static final byte[] INVALID_PROTO_BYTES =
-            new byte[] { 1, 2, 3, 4, 5 };
+    private static final class ValidDeleteRequest {
+        public static final CredentialDeleteRequest make() {
+            return new CredentialDeleteRequest.Builder(ValidFacebookCredential.make())
+                            .setAdditionalProperties(ValidAdditionalProperties.make())
+                            .build();
+        }
 
-    private static final Credential CREDENTIAL =
-            new Credential.Builder(
-                    "alice@example.com",
-                    AuthenticationMethods.EMAIL,
-                    new AuthenticationDomain("https://example.com"))
-            .build();
+        public static void assertEquals(CredentialDeleteRequest request) {
+            ValidFacebookCredential.assertEqualTo(request.getCredential());
+            ValidAdditionalProperties.assertEquals(request.getAdditionalProps());
+        }
+    }
 
     @Test
     public void build() {
-        CredentialDeleteRequest request =
-                new CredentialDeleteRequest.Builder(CREDENTIAL)
-                        .setAdditionalProperties(ADDITIONAL_PROPS)
-                        .build();
+        CredentialDeleteRequest request = ValidDeleteRequest.make();
 
-        assertThat(request.getCredential()).isNotNull();
-        checkAdditionalProps(request.getAdditionalProps());
+        ValidDeleteRequest.assertEquals(request);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullCredential_throwsIllegalArgumentException() {
         new CredentialDeleteRequest.Builder(null).build();
     }
 
     @Test
     public void fromProtobuf() throws Exception {
-        Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
-                .setCredential(CREDENTIAL.toProtobuf())
-                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
-                .build();
+        Protobufs.CredentialDeleteRequest proto = ValidDeleteRequest.make().toProtobuf();
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromProtobuf(proto);
-        assertThat(request.getCredential()).isNotNull();
-        checkAdditionalProps(request.getAdditionalProps());
+
+        ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_nullProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
-        Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
-                .setCredential(CREDENTIAL.toProtobuf())
-                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
-                .build();
-
+        Protobufs.CredentialDeleteRequest proto = ValidDeleteRequest.make().toProtobuf();
         CredentialDeleteRequest request =
                 CredentialDeleteRequest.fromProtobufBytes(proto.toByteArray());
-        assertThat(request.getCredential()).isNotNull();
-        checkAdditionalProps(request.getAdditionalProps());
+
+        ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 
-    @Test
-    public void toProtobuf() {
-        Protobufs.CredentialDeleteRequest proto =
-                new CredentialDeleteRequest.Builder(CREDENTIAL)
-                        .setAdditionalProperties(ADDITIONAL_PROPS)
-                        .build()
-                .toProtobuf();
-
-        assertThat(proto.hasCredential());
-        checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
-    }
-
     @Test
     public void fromRequestIntent() throws Exception {
-        byte[] protoBytes =
-                new CredentialDeleteRequest.Builder(CREDENTIAL)
-                        .setAdditionalProperties(ADDITIONAL_PROPS)
-                        .build()
-                        .toProtobuf()
-                        .toByteArray();
-
+        byte[] protoBytes = ValidDeleteRequest.make().toProtobuf().toByteArray();
         Intent requestIntent = new Intent();
         requestIntent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, protoBytes);
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromRequestIntent(requestIntent);
 
-        assertThat(request.getCredential()).isNotNull();
-        checkAdditionalProps(request.getAdditionalProps());
+        ValidDeleteRequest.assertEquals(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_nullIntent_throwsException() throws Exception {
         CredentialDeleteRequest.fromRequestIntent(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_missingExtra_throwsException() throws Exception {
         Intent intent = new Intent();
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, "notAByteArray");
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO_BYTES);
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO.toByteArray());
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
index 949b72b..519d394 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
@@ -17,7 +17,3 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROPS;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_VALUE;
-import static org.openyolo.protocol.TestConstants.checkAdditionalProps;
-import static org.openyolo.protocol.TestConstants.checkAdditionalPropsFromProto;
+import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 
@@ -25,7 +21,4 @@ import android.content.Intent;
 import com.google.protobuf.ByteString;
-import com.google.protobuf.InvalidProtocolBufferException;
-
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.Protobufs.CredentialDeleteResult.ResultCode;
 import org.robolectric.RobolectricTestRunner;
@@ -34,152 +27,111 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteResult}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteResultTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteResult INVALID_PROTO =
             Protobufs.CredentialDeleteResult.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
-    private static final byte[] INVALID_PROTO_BYTES =
-            new byte[] { 1, 2, 3, 4, 5 };
-
-    @Test
-    public void build() {
-        CredentialDeleteResult result = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
-                .build();
+    private static final class ValidDeleteResult {
+        public static CredentialDeleteResult make() {
+            return new CredentialDeleteResult.Builder(
+                    CredentialDeleteResult.CODE_DELETED)
+                    .setAdditionalProperties(TestConstants.ValidAdditionalProperties.make())
+                    .build();
+        }
 
-        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
-        checkAdditionalProps(result.getAdditionalProperties());
+        public static void assertEquals(CredentialDeleteResult result) {
+            assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
+            TestConstants.ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
+        }
     }
 
     @Test
-    public void toProtobuf() {
-        Protobufs.CredentialDeleteResult result = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
-                .build()
-                .toProtobuf();
-
-        assertThat(result.getResultCodeValue()).isEqualTo(
-                Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE);
-        checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
+    public void build() {
+        CredentialDeleteResult result = ValidDeleteResult.make();
+
+        ValidDeleteResult.assertEquals(result);
     }
 
     @Test
-    public void toResultIntentData() throws InvalidProtocolBufferException {
-        Intent resultData = new CredentialDeleteResult.Builder(
-                CredentialDeleteResult.CODE_DELETED)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
-                .build()
-                .toResultDataIntent();
-
-        assertThat(resultData.hasExtra(ProtocolConstants.EXTRA_DELETE_RESULT)).isTrue();
+    public void toProtobuf_fromProtobuf_isEquivalent() throws Exception {
+        Protobufs.CredentialDeleteResult protobuf = ValidDeleteResult.make().toProtobuf();
+        CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(protobuf);
 
-        byte[] resultBytes = resultData.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_RESULT);
-        Protobufs.CredentialDeleteResult result =
-                Protobufs.CredentialDeleteResult.parseFrom(resultBytes);
-
-        assertThat(result.getResultCodeValue()).isEqualTo(ResultCode.DELETED_VALUE);
-        checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
+        ValidDeleteResult.assertEquals(result);
     }
 
     @Test
-    public void fromResultIntentData() throws Exception {
-        byte[] resultBytes = Protobufs.CredentialDeleteResult.newBuilder()
-                .setResultCode(ResultCode.USER_REFUSED)
-                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
-                .build()
-                .toByteArray();
-
-        Intent resultData = new Intent();
-        resultData.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, resultBytes);
-
+    public void toResultIntentData_fromResultIntentData_isEquivalent() throws Exception {
+        Intent resultData = ValidDeleteResult.make().toResultDataIntent();
         CredentialDeleteResult result = CredentialDeleteResult.fromResultIntentData(resultData);
-        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_USER_REFUSED);
-        checkAdditionalProps(result.getAdditionalProperties());
+
+        ValidDeleteResult.assertEquals(result);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_nullIntent_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(null);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_missingExtra_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(new Intent());
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, "notAByteArray");
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO_BYTES);
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO.toByteArray());
 
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
-    @Test
-    public void fromProtobuf() throws Exception {
-        Protobufs.CredentialDeleteResult proto = Protobufs.CredentialDeleteResult.newBuilder()
-                .setResultCode(ResultCode.BAD_REQUEST)
-                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
-                .build();
-
-        CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(proto);
-        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
-        checkAdditionalProps(result.getAdditionalProperties());
-    }
-
     @Test(expected=MalformedDataException.class)
     public void fromProtobuf_invalidProtoData_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
-        byte[] protoBytes = Protobufs.CredentialDeleteResult.newBuilder()
-                .setResultCode(ResultCode.BAD_REQUEST)
-                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
-                .build()
-                .toByteArray();
+        byte[] protoBytes = ValidDeleteResult.make().toProtobuf().toByteArray();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobufBytes(protoBytes);
-        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
-        checkAdditionalProps(result.getAdditionalProperties());
+        ValidDeleteResult.assertEquals(result);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 476af6d..1b7c97e 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -21,2 +21,3 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
+
 import android.os.Parcel;
@@ -30,121 +31,123 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
+import org.openyolo.protocol.TestConstants.ValidTokenProviderMap;
+import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 
 /**
  * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
-                .setTokenProviders(TestConstants.createTokenProviderMap())
-                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .setTokenProviders(ValidTokenProviderMap.make())
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
-        TestConstants.checkTokenProviderMap(request.getTokenProviders());
-        TestConstants.checkAdditionalProps(request.getAdditionalProperties());
+        ValidTokenProviderMap.assertEquals(request.getTokenProviders());
+        ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         CredentialRetrieveRequest.fromProtobuf(null);
     }
 
     @Test
     public void testWriteAndRead() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
-                .setTokenProviders(TestConstants.createTokenProviderMap())
-                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .setTokenProviders(ValidTokenProviderMap.make())
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .setRequireUserMediation(true)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
-            TestConstants.checkTokenProviderMap(deserialized.getTokenProviders());
-            TestConstants.checkAdditionalProps(deserialized.getAdditionalProperties());
+            ValidTokenProviderMap.assertEquals(deserialized.getTokenProviders());
+            ValidAdditionalProperties.assertEquals(deserialized.getAdditionalProperties());
             assertThat(deserialized.getRequireUserMediation()).isTrue();
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
 
     @Test
     public void toProtocolBuffer_usingDefaultBuilder_returnsExpectedValues() {
         CredentialRetrieveRequest request =
                 new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL).build();
 
         Protobufs.CredentialRetrieveRequest protoRequest = request.toProtocolBuffer();
 
         assertThat(protoRequest.getRequireUserMediation())
                 .isEqualTo(CredentialRetrieveRequest.DEFAULT_REQUIRE_USER_MEDIATION_VALUE);
     }
 
     @Test
     public void toProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
index ea5cfbf..ce42941 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
@@ -22,3 +22,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestFixtures.ValidProperties;
+import org.openyolo.protocol.TestConstants.ValidProperties;
 import org.robolectric.RobolectricTestRunner;
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
index 7e1f47d..a5859f7 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
@@ -26,4 +26,4 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestFixtures.ValidProperties;
-import org.openyolo.protocol.TestFixtures.ValidFacebookCredential;
+import org.openyolo.protocol.TestConstants.ValidProperties;
+import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -35,140 +35,140 @@ import org.robolectric.annotation.Config;
 /** Unit tests for {@link CredentialSaveRequest} */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class CredentialSaveRequestTest {
 
     private static final class ValidClientVersion {
         public static final int MAJOR = 1;
         public static final int MINOR = 2;
         public static final int PATCH = 3;
         public static final String VENDOR = "com.customVendor";
 
         public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
                 .setMajor(MAJOR)
                 .setMinor(MINOR)
                 .setPatch(PATCH)
                 .setVendor(VENDOR)
                 .build();
     }
 
     private static final class ValidRequest {
-        public static final Credential CREDENTIAL = ValidFacebookCredential.INSTANCE;
-        public static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+        private static final Credential CREDENTIAL = ValidFacebookCredential.make();
+        private static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
-        public static final CredentialSaveRequest INSTANCE =
+        private static final CredentialSaveRequest INSTANCE =
                 new CredentialSaveRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(CredentialSaveRequest request) {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             ValidProperties.assertEqualTo(request.getAdditionalProperties());
         }
 
         public static void assertEqualTo(Protobufs.CredentialSaveRequest request) throws Exception {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
 
             final Map<String, byte[]> additionalProperties =
                     CollectionConverter.convertMapValues(
                             request.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             ValidProperties.assertEqualTo(additionalProperties);
         }
     }
 
     @Before
     public void setup() {
         ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtoBytes_withNull_throwsMalformedDataException() throws Exception {
         CredentialSaveRequest.fromProtoBytes(null /* bytes */);
     }
 
     @Test()
     public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
         final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
     public void fromProto_withValidProto_resultIsEqual() throws Exception {
         final CredentialSaveRequest request =
             CredentialSaveRequest.fromProtobuf(ValidRequest.INSTANCE.toProtocolBuffer());
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
         CredentialSaveRequest.fromProtobuf(null);
     }
 
     @Test
     public void fromCredential_withValidCredential_returnsRequestForCredential() {
         final CredentialSaveRequest request =
-                CredentialSaveRequest.fromCredential(ValidFacebookCredential.INSTANCE);
+                CredentialSaveRequest.fromCredential(ValidFacebookCredential.make());
 
-        assertThat(request.getCredential()).isSameAs(ValidFacebookCredential.INSTANCE);
+        ValidFacebookCredential.assertEqualTo(request.getCredential());
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void parcelAndUnparcel_withValidCredential_isEqual() {
         Parcel parcel = Parcel.obtain();
         ValidRequest.INSTANCE.writeToParcel(parcel, 0);
         parcel.setDataPosition(0);
         final CredentialSaveRequest request =
                 CredentialSaveRequest.CREATOR.createFromParcel(parcel);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
     public void toProtocolBuffer_withValidCredential_containsClientVersion() throws Exception {
         final Protobufs.CredentialSaveRequest protoRequest =
                 ValidRequest.INSTANCE.toProtocolBuffer();
 
         ValidRequest.assertEqualTo(protoRequest);
     }
 
     @Test
     public void builder_withValidCredential_resultIsEqual() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL).build();
 
         assertThat(request.getCredential()).isSameAs(ValidRequest.CREDENTIAL);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builder_withNullCredential_throwsIllegalArgumentException() {
         new CredentialSaveRequest.Builder((Credential) null);
     }
 
     public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
         CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
                         .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
                         .setAdditionalProperties(null)
                         .build();
 
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void builder_setAdditionalProperties_isSuccessful() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
                         .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
                         .build();
 
         ValidProperties.assertEqualTo(request.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
index c7e1e82..0ff4540 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
@@ -25,3 +25,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestFixtures.ValidProperties;
+import org.openyolo.protocol.TestConstants.ValidProperties;
 import org.openyolo.protocol.internal.ByteStringConverters;
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index c73aa07..7ed58c0 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -25,3 +25,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TestFixtures.ValidFacebookCredential;
+import org.openyolo.protocol.TestConstants.ValidFacebookCredential;
 import org.robolectric.RobolectricTestRunner;
@@ -30,283 +30,289 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
-    public static final String EMAIL_ID = "alice@example.com";
-    public static final String AUTH_DOMAIN_STR = "https://www.example.com";
-    public static final AuthenticationDomain AUTH_DOMAIN =
+    private static final String EMAIL_ID = "alice@example.com";
+    private static final String AUTH_DOMAIN_STR = "https://www.example.com";
+    private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
+    private static final String ID_TOKEN =
+            "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSIsImF1ZCI"
+                    + "6IlhZWi5jbGllbnQuaWQiLCJpc3MiOiJpZHAuZXhhbXBsZS5jb20iLCJlbWFpbCI"
+                    + "6ImFsaWNlQGV4YW1wbGUuY29tIiwibmFtZSI6IkFsaWNlIE1jVGVzdGVyc29uIiw"
+                    + "icGljdHVyZSI6Imh0dHBzOi8vcm9ib2hhc2gub3JnL2FsaWNlIn0.2-D7AZ1C7mv"
+                    + "dLRf6Q7aqH8Ah4rlK1uuHPSU2HPImtyk";
 
     @Test
     public void fromProtobuf_withValidCredential_returnsEquivalentCredential() throws Exception {
         Credential credential =
-                Credential.fromProtobuf(ValidFacebookCredential.INSTANCE.toProtobuf());
+                Credential.fromProtobuf(ValidFacebookCredential.make().toProtobuf());
 
         ValidFacebookCredential.assertEqualTo(credential);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetIdToken_validInput_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
-                .setIdToken(TestConstants.ALICE_ID_TOKEN)
+                .setIdToken(ID_TOKEN)
                 .build();
 
-        assertThat(cr.getIdToken()).isEqualTo(TestConstants.ALICE_ID_TOKEN);
+        assertThat(cr.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(null)
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken("")
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
         @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index 79df8f0..382e1f3 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -27,238 +27,240 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
+import org.openyolo.protocol.TestConstants.ValidTokenProviderMap;
+import org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
-                .setTokenProviders(TestConstants.createTokenProviderMap())
+                .setTokenProviders(ValidTokenProviderMap.make())
                 .setPasswordSpecification(originalSpec)
-                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
-        TestConstants.checkTokenProviderMap(request.getTokenProviders());
-        TestConstants.checkAdditionalProps(request.getAdditionalProperties());
+        ValidTokenProviderMap.assertEquals(request.getTokenProviders());
+        ValidAdditionalProperties.assertEquals(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
-                .setTokenProviders(TestConstants.createTokenProviderMap())
-                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .setTokenProviders(ValidTokenProviderMap.make())
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
-            TestConstants.checkTokenProviderMap(read.getTokenProviders());
-            TestConstants.checkAdditionalProps(read.getAdditionalProperties());
+            ValidTokenProviderMap.assertEquals(read.getTokenProviders());
+            ValidAdditionalProperties.assertEquals(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Set<AuthenticationMethod>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
index ac294e2..48c0ece 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
@@ -17,10 +17,5 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_KEY;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROPS;
-import static org.openyolo.protocol.TestConstants.ADDITIONAL_VALUE;
-import static org.openyolo.protocol.TestConstants.checkAdditionalProps;
-import static org.openyolo.protocol.TestConstants.checkAdditionalPropsFromProto;
+import static org.openyolo.protocol.TestConstants.ValidAdditionalProperties;
 
 import android.content.Intent;
-import com.google.protobuf.ByteString;
 import org.junit.Test;
@@ -32,101 +27,101 @@ import org.robolectric.annotation.Config;
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveResultTest {
 
     private static final String ALICE_ID = "alice@example.com";
     private static final Hint HINT =
             new Hint.Builder(
                     ALICE_ID,
                     AuthenticationMethods.EMAIL)
                     .build();
 
     @Test
     public void build() {
 
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isSameAs(HINT);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void buildSetHint_nullValue() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setHint(null)
                 .build();
 
         assertThat(result.getHint()).isNull();
     }
 
     @Test
     public void fromProtobuf_withDefaultInstanceOfHint_doesNotThrowException() throws Exception {
         Protobufs.HintRetrieveResult hintRetrieveResult =
                 Protobufs.HintRetrieveResult.newBuilder().build();
 
         HintRetrieveResult.fromProtobuf(hintRetrieveResult);
     }
 
     @Test
     public void buildSetAdditionalProperties() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         assertThat(result.getAdditionalProperties()).hasSize(1);
-        checkAdditionalProps(result.getAdditionalProperties());
+        ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
     }
 
     @Test
     public void toProtobuf() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Protobufs.HintRetrieveResult proto = result.toProtobuf();
         assertThat(proto.getResultCodeValue()).isEqualTo(ResultCode.HINT_SELECTED_VALUE);
         assertThat(proto.hasHint());
-        checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
+        ValidAdditionalProperties.assertEqualsForProto(proto.getAdditionalPropsMap());
     }
 
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.HintRetrieveResult proto = Protobufs.HintRetrieveResult.newBuilder()
                 .setResultCode(ResultCode.HINT_SELECTED)
                 .setHint(Protobufs.Hint.newBuilder()
                         .setId(ALICE_ID)
                         .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf()))
-                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .putAllAdditionalProps(ValidAdditionalProperties.makeForProto())
                 .build();
 
         HintRetrieveResult result = HintRetrieveResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isNotNull();
-        checkAdditionalProps(result.getAdditionalProperties());
+        ValidAdditionalProperties.assertEquals(result.getAdditionalProperties());
     }
 
     @Test
     public void toResultIntentData() throws Exception {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .setAdditionalProperties(ValidAdditionalProperties.make())
                 .build();
 
         Intent intent = result.toResultDataIntent();
         assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
         byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
 
         HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
         assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(readResult.getHint()).isNotNull();
-        checkAdditionalProps(readResult.getAdditionalProperties());
+        ValidAdditionalProperties.assertEquals(readResult.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintTest.java b/protocol/javatests/org/openyolo/protocol/HintTest.java
index 273b981..c644853 100644
--- a/protocol/javatests/org/openyolo/protocol/HintTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintTest.java
@@ -20,3 +20,3 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
-import android.net.Uri;
+import android.content.Context;
 import android.os.Parcel;
@@ -24,312 +24,153 @@ import java.util.HashMap;
 import java.util.Map;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidEmailHint;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
+/** Unit tests for {@link Hint}*/
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
-public class HintTest {
+public final class HintTest {
 
-    private static final String ALICE_ID = "alice@example.com";
-    private static final String ALICE_NAME = "Alice";
-    private static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://avatars.example.com/alice";
-    private static final Uri ALICE_DISPLAY_PICTURE_URI = Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
-    private static final String PASSWORD = "correctH0rseBatterySt4ple";
-    private static final String ID_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
-            + "eyJzdWIiOiJ5b2xvIn0."
-            + "BI1g9ns0shv6PKfwlhfPKwh5XzxQyg_el_35_wZbtsI";
+    private static final String ID = "coold00d@aol.gov";
+
+    Context mContext;
+
+    @Before
+    public void initializeMocks() throws Exception {
+        mContext = TestConstants.ValidApplication.install(RuntimeEnvironment.application);
+    }
 
     @Test
-    public void build_minimalData() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL).build();
-        assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
+    public void build_withRequiredParamsOnly() {
+        Hint hint = new Hint.Builder(ID, AuthenticationMethods.EMAIL).build();
+
+        assertThat(hint.getIdentifier()).isEqualTo(ID);
         assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
         assertThat(hint.getDisplayName()).isNull();
         assertThat(hint.getDisplayPictureUri()).isNull();
         assertThat(hint.getIdToken()).isNull();
         assertThat(hint.getAdditionalProperties()).isEmpty();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullId_shouldThrowException() {
         new Hint.Builder(
                 null,// id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void build_emptyId_shouldThrowException() {
         new Hint.Builder(
                 "", // id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethod_shouldThrowException() {
         new Hint.Builder(
-                ALICE_ID,
+                ID,
                 (AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
-                ALICE_ID,
+                ID,
                 (String) null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void build_emptyAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
-                ALICE_ID,
+                ID,
                 "")
                 .build();
     }
 
-    @Test
-    public void builderSetDisplayName() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayName(ALICE_NAME)
-                .build();
-        assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
-    }
-
-    @Test
-    public void builderSetDisplayName_nullValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayName(null)
-                .build();
-
-        assertThat(hint.getDisplayName()).isNull();
-    }
-
-    @Test
-    public void builderSetDisplayName_emptyValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayName("")
-                .build();
-
-        assertThat(hint.getDisplayName()).isNull();
-    }
-
-    @Test
-    public void builderSetDisplayPictureUri() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
-                .build();
-        assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
-    }
-
-    @Test
-    public void builderSetDisplayPictureUri_nullValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayPictureUri((Uri) null)
-                .build();
-        assertThat(hint.getDisplayPictureUri()).isNull();
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void builderSetDisplayPictureUri_nonHttp_shouldThrowException() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayPictureUri(Uri.parse("gopher://hello"))
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test
-    public void builderSetDisplayPictureUriStr() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
-                .build();
-        assertThat(hint.getDisplayPictureUri().toString()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
-    }
-
-    @Test
-    public void builderSetDisplayPictureUriStr_nullValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayPictureUri((String) null)
-                .build();
-        assertThat(hint.getDisplayPictureUri()).isNull();
-    }
-
-    @Test
-    public void builderSetDisplayPictureUriStr_emptyValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setDisplayPictureUri("")
-                .build();
-        assertThat(hint.getDisplayPictureUri()).isNull();
-    }
-
-    @Test
-    public void builderSetGeneratedPassword() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setGeneratedPassword(PASSWORD)
-                .build();
-
-        assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
-    }
-
-    @Test
-    public void builderSetGeneratedPassword_nullValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setGeneratedPassword(null)
-                .build();
-
-        assertThat(hint.getGeneratedPassword()).isNull();
-    }
-
-    @Test
-    public void builderSetGeneratedPassword_emptyValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setGeneratedPassword("")
-                .build();
-
-        assertThat(hint.getGeneratedPassword()).isNull();
-    }
-
-    @Test
-    public void builderSetIdToken() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setIdToken(ID_TOKEN)
-                .build();
-
-        assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
-    }
-
-    @Test
-    public void builderSetIdToken_nullValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setIdToken(null)
-                .build();
-
-        assertThat(hint.getIdToken()).isNull();
-    }
-
-    @Test
-    public void builderSetIdToken_emptyValue() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
-                .setIdToken(null)
-                .build();
-
-        assertThat(hint.getIdToken()).isNull();
-    }
-
     @Test
     public void builderSetAdditionalProps() {
         String additionalKey = "extra";
         byte[] additionalValue = "value".getBytes();
 
         Map<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(additionalKey, additionalValue);
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+        Hint hint = new Hint.Builder(ValidEmailHint.make())
                 .setAdditionalProperties(additionalProps)
                 .build();
 
         assertThat(hint.getAdditionalProperties()).hasSize(1);
         assertThat(hint.getAdditionalProperties()).containsKey(additionalKey);
         assertThat(hint.getAdditionalProperties().get(additionalKey)).isEqualTo(additionalValue);
     }
 
     @Test
-    public void toProtobuf() {
-        Hint hint = new Hint.Builder(
-                ALICE_ID,
-                AuthenticationMethods.EMAIL)
-                .setDisplayName(ALICE_NAME)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
-                .setGeneratedPassword(PASSWORD)
-                .setIdToken(ID_TOKEN)
-                .build();
+    public void builder_withHintContructor_isEquivalent() {
+        Hint hint = new Hint.Builder(ValidEmailHint.make()).build();
 
-        Protobufs.Hint proto = hint.toProtobuf();
-        assertThat(proto.getId()).isEqualTo(ALICE_ID);
-        assertThat(proto.getAuthMethod().getUri())
-                .isEqualTo(AuthenticationMethods.EMAIL.toString());
-        assertThat(proto.getDisplayName()).isEqualTo(ALICE_NAME);
-        assertThat(proto.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
-        assertThat(proto.getGeneratedPassword()).isEqualTo(PASSWORD);
-        assertThat(proto.getIdToken()).isEqualTo(ID_TOKEN);
+        ValidEmailHint.assertEquals(hint);
     }
 
     @Test
-    public void fromProtobuf() throws Exception {
-        Protobufs.Hint proto = Protobufs.Hint.newBuilder()
-                .setId(ALICE_ID)
-                .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
-                .setDisplayName(ALICE_NAME)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
-                .setGeneratedPassword(PASSWORD)
-                .setIdToken(ID_TOKEN)
-                .build();
+    public void toProtobuf_isEquivalent() {
+        Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
 
-        Hint hint = Hint.fromProtobuf(proto);
-        assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
-        assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
-        assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
-        assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
-        assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
-        assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+        ValidEmailHint.assertEquals(proto);
     }
 
     @Test
-    public void fromProtobufBytes() throws Exception {
-        Protobufs.Hint proto = Protobufs.Hint.newBuilder()
-                .setId(ALICE_ID)
-                .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
-                .setDisplayName(ALICE_NAME)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
-                .setGeneratedPassword(PASSWORD)
-                .setIdToken(ID_TOKEN)
-                .build();
+    public void fromProtobuf_isEquivalent() throws Exception {
+        Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
+        Hint hint = Hint.fromProtobuf(proto);
+
+        ValidEmailHint.assertEquals(hint);
+    }
 
+    @Test
+    public void fromProtobufBytes_isEquivalent() throws Exception {
+        Protobufs.Hint proto = ValidEmailHint.make().toProtobuf();
         Hint hint = Hint.fromProtobufBytes(proto.toByteArray());
-        assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
-        assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
-        assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
-        assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
-        assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
-        assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+
+        ValidEmailHint.assertEquals(hint);
     }
 
     @Test
     public void writeToAndReadFromParcel() {
-        Hint hint = new Hint.Builder(
-                ALICE_ID,
-                AuthenticationMethods.EMAIL)
-                .setDisplayName(ALICE_NAME)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
-                .setGeneratedPassword(PASSWORD)
-                .setIdToken(ID_TOKEN)
-                .build();
+        Hint hint = ValidEmailHint.make();
 
         Parcel p = Parcel.obtain();
         try {
             hint.writeToParcel(p, 0);
             p.setDataPosition(0);
             Hint readHint = Hint.CREATOR.createFromParcel(p);
 
-            assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
-            assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
-            assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
-            assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
-            assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
-            assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+            ValidEmailHint.assertEquals(readHint);
         } finally {
             p.recycle();
         }
     }
 
+    @Test
+    public void toCredentialBuilder_isEquivalent() {
+        Credential credential = ValidEmailHint.make().toCredentialBuilder(mContext).build();
+
+        ValidEmailHint.assertEquals(mContext, credential);
+    }
+
     @Test
     public void describeContents() {
-        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL).build();
+        Hint hint = ValidEmailHint.make();
         assertThat(hint.describeContents()).isEqualTo(0);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TestConstants.java b/protocol/javatests/org/openyolo/protocol/TestConstants.java
index e2e0e77..370b081 100644
--- a/protocol/javatests/org/openyolo/protocol/TestConstants.java
+++ b/protocol/javatests/org/openyolo/protocol/TestConstants.java
@@ -17,6 +17,14 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.AdditionalMatchers.not;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
 import android.content.pm.Signature;
 import android.net.Uri;
-import android.util.Base64;
 import com.google.protobuf.ByteString;
@@ -28,185 +36,290 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Useful constants and associated verification methods for tests.
  */
 public final class TestConstants {
 
-    public static final String ALICE_EMAIL = "alice@example.com";
-    public static final String ALICE_NAME = "Alice McTesterson";
-    public static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://robohash.org/alice";
-    public static final Uri ALICE_DISPLAY_PICTURE_URI =
-            Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
-    public static final String ALICE_PASSWORD = "CorrectH0rseBatteryStapl3";
-
-    public static final String ALICE_ID_TOKEN =
-            "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSIsImF1ZCI"
-                    + "6IlhZWi5jbGllbnQuaWQiLCJpc3MiOiJpZHAuZXhhbXBsZS5jb20iLCJlbWFpbCI"
-                    + "6ImFsaWNlQGV4YW1wbGUuY29tIiwibmFtZSI6IkFsaWNlIE1jVGVzdGVyc29uIiw"
-                    + "icGljdHVyZSI6Imh0dHBzOi8vcm9ib2hhc2gub3JnL2FsaWNlIn0.2-D7AZ1C7mv"
-                    + "dLRf6Q7aqH8Ah4rlK1uuHPSU2HPImtyk";
-
-    public static final String CLIENT_ID = "XYZ.client.id";
-    public static final String NONCE = "asdf";
-
-    public static final String EXAMPLE_APP_PACKAGE_NAME = "com.example.app";
-
-    public static final byte[] EXAMPLE_APP_SIGNATURE_BYTES =
-            Base64.decode(
-                    "MIICwzCCAaugAwIBAgIEYUHE8DANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDEwd0"
-                    + "ZXN0aW5nMB4XDTE3MDUxMDIxMTY1M1oXDTQ0MDkyNTIxMTY1M1owEjEQMA4GA1UE"
-                    + "AxMHdGVzdGluZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ2+5bxE"
-                    + "24gsczcfwoAgJrerBGgew5rHiUYekp6nlfOlqQqJbC5KNKOr8qK1IF92MSrcphIw"
-                    + "CWWkp67Bqqe49nK3ce9kVHqhXjaz9w4HVex3N3kWt1r7s08lNax/67vTrfQXlDnI"
-                    + "1VDijm82vklmLtcXXnww10FQRKVdtxSkCmtUjmuYpLqFZY5cDIG5fpoeFhzoDolj"
-                    + "pfmYkDsFGEUVOIilrM70rdwziEuvXPVGIzI8Lz88OkdamtQ2dtWSFP+4O8tv6qSW"
-                    + "Q00/YAIm/RV2Z3NFIPma1n7GmTqm+QBM4lq8Irc24yL/a78nVT+fibfBOr7Iu02Z"
-                    + "qy4Rpkosq4bfgt8CAwEAAaMhMB8wHQYDVR0OBBYEFJXEQr/2vuy2E2o2lz8LRbZW"
-                    + "b/QzMA0GCSqGSIb3DQEBCwUAA4IBAQB5N++YqygWTFDwfCGgBT3pytaKVGbSujvB"
-                    + "ChmBry2kfT5SpZcMerTboxq+0Jny50jS+2FAl0apKYC56R+FZC3Zg1qUBlqcCOrZ"
-                    + "j2r7INQHWfiZo76zBjsaf9iDJwwDHKox5Bu8TK0Iux4hPi3J0hWg+MXDq6GUHQPT"
-                    + "aFfxVAPNjnu+BnMrdw3YwEGxUBNTm0BeJruF2Hvzt9s/HOJ4y70dhlnz3McrxSQ2"
-                    + "Tmlo1G0YwaTDO3jYDtD7CJ2V9EdAr9HjUeIlOiHwSHxDZexRxsiJf9rADP3Mqh7r"
-                    + "I+gmzIbXs+UA7nsHXVgTyg5NviDbmYcu/hqKOLf1UeMwAEjQu0U9",
-                    Base64.NO_PADDING);
-
-    public static final Signature EXAMPLE_APP_SIGNATURE =
-            new Signature(EXAMPLE_APP_SIGNATURE_BYTES);
-
-    public static final String EXAMPLE_APP_SHA256_FINGERPRINT =
-            "uHq8C9rrDcJ_MqkyeauSba4OYMSOJJqUDWEuMWiOdfo=";
-
-    public static final String EXAMPLE_APP_SHA512_FINGERPRINT =
-            "KSYmxK5qmKUKhNxHJYv__Tgg8nFXkm_w7mhJd_feckMW"
-                    + "NqBXGK7yhZugh4OVI5ffJn8_V4SEN-mqetuIqiqPVA==";
-
-    public static final AuthenticationDomain EXAMPLE_APP_AUTH_DOMAIN =
-            AuthenticationDomain.createAndroidAuthDomain(
-                    EXAMPLE_APP_PACKAGE_NAME,
-                    EXAMPLE_APP_SIGNATURE);
-
-    public static final String TOKEN_PROVIDER_1 = "https://idp1.example.com";
-    public static final String TOKEN_PROVIDER_2 = "https://idp2.example.com";
-
-    public static final String ADDITIONAL_KEY = "extra";
-    public static final byte[] ADDITIONAL_VALUE = "value".getBytes();
-    public static final Map<String, byte[]> ADDITIONAL_PROPS;
-    public static final Map<String, ByteString> ADDITIONAL_PROPS_FOR_PROTO;
-
-    public static final byte[] INVALID_PROTO_BYTES = new byte[] { 1, 2, 3 };
-
-    static {
-        Map<String, byte[]> additionalProps = new HashMap<>();
-        additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
-        ADDITIONAL_PROPS = additionalProps;
-        ADDITIONAL_PROPS_FOR_PROTO = CollectionConverter.convertMapValues(
-                additionalProps,
-                ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
-    }
+    public static final byte[] INVALID_PROTO_BYTES =
+            new byte[] { 'i', 'n', 'v', 'a', 'l', 'i', 'd' };
 
-    public static void checkAdditionalProps(Map<String, byte[]> additionalProps) {
-        assertThat(additionalProps).isNotNull();
-        assertThat(additionalProps).hasSize(1);
-        assertThat(additionalProps).containsKey(ADDITIONAL_KEY);
-        assertThat(additionalProps.get(ADDITIONAL_KEY)).isEqualTo(ADDITIONAL_VALUE);
-    }
+    public static final class ValidAdditionalProperties {
+        private static final String ADDITIONAL_KEY = "extra";
+        private static final byte[] ADDITIONAL_VALUE = "value".getBytes();
 
-    public static void checkAdditionalPropsFromProto(Map<String, ByteString> additionalProps) {
-        checkAdditionalProps(CollectionConverter.convertMapValues(
-                additionalProps,
-                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
-    }
+        public static Map<String, byte[]> make() {
+            Map<String, byte[]> additionalProps = new HashMap<>();
+            additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
+            return additionalProps;
+        }
 
-    public static TokenRequestInfo createTokenRequestInfo() {
-        return new TokenRequestInfo.Builder()
-                .setClientId(CLIENT_ID)
-                .setNonce(NONCE)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
-                .build();
-    }
+        public static Map<String, ByteString> makeForProto() {
+            return CollectionConverter.convertMapValues(
+                    make(),
+                    ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
+        }
 
-    public static Protobufs.TokenRequestInfo createTokenRequestInfoProto() {
-        return Protobufs.TokenRequestInfo.newBuilder()
-                .setClientId(CLIENT_ID)
-                .setNonce(NONCE)
-                .putAllAdditionalProps(ADDITIONAL_PROPS_FOR_PROTO)
-                .build();
-    }
 
-    public static void checkTokenRequestInfo(TokenRequestInfo info) {
-        assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
-        assertThat(info.getNonce()).isEqualTo(NONCE);
-        TestConstants.checkAdditionalProps(info.getAdditionalProperties());
+        public static void assertEquals(Map<String, byte[]> additionalProps) {
+            assertThat(additionalProps).isNotNull();
+            assertThat(additionalProps).hasSize(1);
+            assertThat(additionalProps).containsKey(ADDITIONAL_KEY);
+            assertThat(additionalProps.get(ADDITIONAL_KEY)).isEqualTo(ADDITIONAL_VALUE);
+        }
+
+        public static void assertEqualsForProto(Map<String, ByteString> additionalProps) {
+            assertEquals(CollectionConverter.convertMapValues(
+                    additionalProps,
+                    ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        }
     }
 
-    public static void checkTokenRequestInfoProto(Protobufs.TokenRequestInfo info) {
-        assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
-        assertThat(info.getNonce()).isEqualTo(NONCE);
-        TestConstants.checkAdditionalPropsFromProto(info.getAdditionalPropsMap());
+    public static final class ValidTokenRequestInfo {
+        private static final String CLIENT_ID = "XYZ.client.id";
+        private static final String NONCE = "asdf";
+
+        public static TokenRequestInfo make() {
+            return new TokenRequestInfo.Builder()
+                    .setClientId(CLIENT_ID)
+                    .setNonce(NONCE)
+                    .setAdditionalProperties(ValidAdditionalProperties.make())
+                    .build();
+        }
+
+        public static void assertEquals(TokenRequestInfo info) {
+            assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
+            assertThat(info.getNonce()).isEqualTo(NONCE);
+            ValidAdditionalProperties.assertEquals(info.getAdditionalProperties());
+        }
+
+        public static void assertEquals(Protobufs.TokenRequestInfo info) {
+            assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
+            assertThat(info.getNonce()).isEqualTo(NONCE);
+            ValidAdditionalProperties.assertEqualsForProto(info.getAdditionalPropsMap());
+        }
+
     }
 
-    public static Map<String, TokenRequestInfo> createTokenProviderMap() {
-        HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
-        tokenProviders.put(TOKEN_PROVIDER_1, createTokenRequestInfo());
-        tokenProviders.put(TOKEN_PROVIDER_2, null);
-        return tokenProviders;
+    public static final class ValidTokenProviderMap {
+        private static final String TOKEN_PROVIDER_1 = "https://idp1.example.com";
+        private static final String TOKEN_PROVIDER_2 = "https://idp2.example.com";
+
+
+        public static Map<String, TokenRequestInfo> make() {
+            HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
+            tokenProviders.put(TOKEN_PROVIDER_1, ValidTokenRequestInfo.make());
+            tokenProviders.put(TOKEN_PROVIDER_2, null);
+            return tokenProviders;
+        }
+
+        public static void assertEquals(Map<String, TokenRequestInfo> tokenProviders) {
+            assertThat(tokenProviders).hasSize(2);
+            assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_1);
+            assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_2);
+            ValidTokenRequestInfo.assertEquals(tokenProviders.get(TOKEN_PROVIDER_1));
+            assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getClientId()).isNull();
+            assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getNonce()).isNull();
+            assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getAdditionalProperties()).isEmpty();
+        }
     }
 
-    public static void checkTokenProviderMap(Map<String, TokenRequestInfo> tokenProviders) {
-        assertThat(tokenProviders).hasSize(2);
-        assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_1);
-        assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_2);
-        checkTokenRequestInfo(tokenProviders.get(TOKEN_PROVIDER_1));
-        assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getClientId()).isNull();
-        assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getNonce()).isNull();
-        assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getAdditionalProperties()).isEmpty();
+    public static final class ValidProperties {
+        public static final String PROPERTY_A_NAME = "Property A";
+        public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
+
+        public static final String PROPERTY_B_NAME = "Property B";
+        public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
+
+        public static final Map<String, byte[]> MAP_INSTANCE;
+
+        static {
+            MAP_INSTANCE = new HashMap<>();
+            MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
+            MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
+        }
+
+        public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
+            Map<String, byte[]> byteMap =
+                    CollectionConverter.convertMapValues(
+                            map,
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+
+            assertEqualTo(byteMap);
+        }
+
+        public static void assertEqualTo(Map<String, byte[]> map) {
+            assertThat(map).hasSize(2);
+            assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
+            assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
+        }
     }
 
-    public static Credential createEmailCredential() {
-        return new Credential.Builder(
-                ALICE_EMAIL,
-                AuthenticationMethods.EMAIL,
-                EXAMPLE_APP_AUTH_DOMAIN)
-                .setDisplayName(ALICE_NAME)
-                .setDisplayPicture(ALICE_DISPLAY_PICTURE_URI)
-                .setPassword(ALICE_PASSWORD)
-                .setIdentifier(ALICE_ID_TOKEN)
-                .setIdToken(ALICE_ID_TOKEN)
-                .setAdditionalProperties(ADDITIONAL_PROPS)
-                .build();
+    public static final class ValidFacebookCredential {
+        public final static String ID = "bob@facebook.com";
+        public final static String ID_TOKEN = "'His name is bob' - xoxo facebook";
+        public final static AuthenticationMethod AUTHENTICATION_METHOD =
+                AuthenticationMethods.FACEBOOK;
+        public final static String PASSWORD = "hunter2";
+        public final static String DISPLAY_NAME = "Bob";
+        public final static Uri DISPLAY_PICTURE_URL =
+                Uri.parse("https://pictures.facebook.com/bob_pics.jpeg");
+        public final static Map<String, byte[]> ADDITIONAL_PROPERTIES =
+                ValidProperties.MAP_INSTANCE;
+        public final static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
+        public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
+                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
+
+        public static Credential make() {
+            return new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN)
+                    .setDisplayName(DISPLAY_NAME)
+                    .setDisplayPicture(DISPLAY_PICTURE_URL)
+                    .setPassword(PASSWORD)
+                    .setIdToken(ID_TOKEN)
+                    .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+                    .build();
+        }
+
+        public static void assertEqualTo(Credential credential) {
+            assertThat(credential.getIdentifier()).isEqualTo(ID);
+            assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
+            assertThat(credential.getPassword()).isEqualTo(PASSWORD);
+            assertThat(credential.getDisplayName()).isEqualTo(DISPLAY_NAME);
+            assertThat(credential.getDisplayPicture()).isEqualTo(DISPLAY_PICTURE_URL);
+            ValidProperties.assertEqualTo(credential.getAdditionalProperties());
+            assertThat(credential.getAuthenticationMethod()).isEqualTo(AUTHENTICATION_METHOD);
+            assertThat(credential.getAuthenticationDomain()).isEqualTo(AUTHENTICATION_DOMAIN);
+        }
+
+        public static void assertEqualTo(Protobufs.Credential credential) throws Exception {
+            assertEqualTo(Credential.fromProtobuf(credential));
+        }
     }
 
-    public static Protobufs.Credential createEmailCredentialProto() {
-        return Protobufs.Credential.newBuilder()
-                .setId(ALICE_EMAIL)
-                .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
-                .setAuthDomain(EXAMPLE_APP_AUTH_DOMAIN.toProtobuf())
-                .setDisplayName(ALICE_NAME)
-                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
-                .setPassword(ALICE_PASSWORD)
-                .setIdToken(ALICE_ID_TOKEN)
-                .putAllAdditionalProps(ADDITIONAL_PROPS_FOR_PROTO)
-                .build();
+    public static final class ValidEmailHint {
+        private static final String ALICE_ID = "alice@example.com";
+        private static final String ALICE_NAME = "Alice";
+        private static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://avatars.example.com/alice";
+        private static final Uri ALICE_DISPLAY_PICTURE_URI = Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
+        private static final String GENERATED_PASSWORD = "correctH0rseBatterySt4ple";
+        private static final String ID_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
+                + "eyJzdWIiOiJ5b2xvIn0."
+                + "BI1g9ns0shv6PKfwlhfPKwh5XzxQyg_el_35_wZbtsI";
+
+        public static Hint make() {
+            return new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                    .setDisplayName(ALICE_NAME)
+                    .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
+                    .setGeneratedPassword(GENERATED_PASSWORD)
+                    .setIdToken(ID_TOKEN)
+                    .build();
+        }
+
+        public static void assertEquals(Context context, Credential credential) {
+            assertThat(credential.getIdentifier()).isEqualTo(ALICE_ID);
+            assertThat(credential.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
+            assertThat(credential.getDisplayName()).isEqualTo(ALICE_NAME);
+            assertThat(credential.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+            assertThat(credential.getPassword()).isEqualTo(GENERATED_PASSWORD);
+            assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
+            assertThat(credential.getAuthenticationDomain())
+                    .isEqualTo(AuthenticationDomain.getSelfAuthDomain(context));
+        }
+
+        public static void assertEquals(Hint hint) {
+            assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
+            assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
+            assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
+            assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+            assertThat(hint.getGeneratedPassword()).isEqualTo(GENERATED_PASSWORD);
+            assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+        }
+
+        public static void assertEquals(Protobufs.Hint protoHint) {
+            assertThat(protoHint.getId()).isEqualTo(ALICE_ID);
+            assertThat(protoHint.getAuthMethod().getUri())
+                    .isEqualTo(AuthenticationMethods.EMAIL.toString());
+            assertThat(protoHint.getDisplayName()).isEqualTo(ALICE_NAME);
+            assertThat(protoHint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
+            assertThat(protoHint.getGeneratedPassword()).isEqualTo(GENERATED_PASSWORD);
+            assertThat(protoHint.getIdToken()).isEqualTo(ID_TOKEN);
+        }
     }
 
-    public static void checkEmailCredential(Credential credential) {
-        assertThat(credential.getIdentifier()).isEqualTo(ALICE_EMAIL);
-        assertThat(credential.getAuthenticationMethod())
-                .isEqualTo(AuthenticationMethods.EMAIL);
-        assertThat(credential.getAuthenticationDomain()).isEqualTo(EXAMPLE_APP_AUTH_DOMAIN);
-        assertThat(credential.getDisplayName()).isEqualTo(ALICE_NAME);
-        assertThat(credential.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
-        assertThat(credential.getPassword()).isEqualTo(ALICE_PASSWORD);
-        assertThat(credential.getIdToken()).isEqualTo(ALICE_ID_TOKEN);
+    public static final class ValidApplication {
+        public static final String PACKAGE_NAME = "com.example.app";
+        private static final String FINGERPRINT =
+                "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
+                        + "7V4Lo8BdCxaA307H0HYkAw==";
+        private static byte[] SIGNATURE_BYTES = new byte[]
+                { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+
+
+        public static final class AuthDomain {
+            private static final String AUTHENTICATION_DOMAIN_STRING =
+                    "android://" + FINGERPRINT + "@" + PACKAGE_NAME;
+
+            public static AuthenticationDomain make() {
+                return new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
+            }
+
+            public static void assertEquals(AuthenticationDomain domain) {
+                assertThat(domain).isEqualTo(make());
+            }
+        }
+
+        public static Context install(Context context) throws Exception {
+            PackageManager packageManager = mock(PackageManager.class);
+
+            when(packageManager.getPackageInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_SIGNATURES)))
+                    .thenReturn(makePackageInfo());
+            doThrow(PackageManager.NameNotFoundException.class)
+                    .when(packageManager).getPackageInfo(
+                            not(eq(PACKAGE_NAME)),
+                            eq(PackageManager.GET_SIGNATURES));
+
+            context = spy(context);
+            when(context.getPackageName()).thenReturn(PACKAGE_NAME);
+            when(context.getPackageManager()).thenReturn(packageManager);
+
+            return context;
+        }
+
+        private static PackageInfo makePackageInfo() {
+            PackageInfo packageInfo = new PackageInfo();
+            packageInfo.signatures = new Signature[1];
+            packageInfo.signatures[0] = new Signature(SIGNATURE_BYTES);
+
+            return packageInfo;
+        }
     }
 
-    public static void checkEmailCredentialProto(Protobufs.Credential proto) {
-        assertThat(proto.getId()).isEqualTo(ALICE_EMAIL);
-        assertThat(proto.getAuthMethod().getUri())
-                .isEqualTo(AuthenticationMethods.EMAIL.toString());
-        assertThat(proto.getAuthDomain().getUri())
-                .isEqualTo(EXAMPLE_APP_AUTH_DOMAIN.toString());
-        assertThat(proto.getDisplayName()).isEqualTo(ALICE_NAME);
-        assertThat(proto.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
-        assertThat(proto.getIdToken()).isEqualTo(ALICE_ID_TOKEN);
-        checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
+    public static final class ApplicationWithMultipleSignatures {
+        public static final String PACKAGE_NAME = "com.example.app.multiple_signatures";
+        private static byte[] SIGNATURE_BYTES = new byte[]
+                { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+
+        public static Context install(Context context) throws Exception {
+            PackageManager packageManager = mock(PackageManager.class);
+
+            when(packageManager.getPackageInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_SIGNATURES)))
+                    .thenReturn(makePackageInfo());
+            doThrow(PackageManager.NameNotFoundException.class)
+                    .when(packageManager).getPackageInfo(
+                    not(eq(PACKAGE_NAME)),
+                    eq(PackageManager.GET_SIGNATURES));
+
+            context = spy(context);
+            when(context.getPackageName()).thenReturn(PACKAGE_NAME);
+            when(context.getPackageManager()).thenReturn(packageManager);
+
+            return context;
+        }
+
+        private static PackageInfo makePackageInfo() {
+            PackageInfo packageInfo = new PackageInfo();
+            packageInfo.signatures = new Signature[2];
+            packageInfo.signatures[0] = new Signature(SIGNATURE_BYTES);
+            packageInfo.signatures[1] = new Signature(SIGNATURE_BYTES);
+
+            return packageInfo;
+        }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TestFixtures.java b/protocol/javatests/org/openyolo/protocol/TestFixtures.java
deleted file mode 100644
index e413df4..0000000
--- a/protocol/javatests/org/openyolo/protocol/TestFixtures.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.protocol;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-import android.net.Uri;
-import com.google.protobuf.ByteString;
-import java.util.HashMap;
-import java.util.Map;
-import org.openyolo.protocol.internal.ByteStringConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
-
-/** Collection of shared test constants */
-public final class TestFixtures {
-    public static final class ValidProperties {
-        public static final String PROPERTY_A_NAME = "Property A";
-        public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
-
-        public static final String PROPERTY_B_NAME = "Property B";
-        public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
-
-        public static final Map<String, byte[]> MAP_INSTANCE;
-
-        static {
-            MAP_INSTANCE = new HashMap<>();
-            MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
-            MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
-        }
-
-        public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
-            Map<String, byte[]> byteMap =
-                    CollectionConverter.convertMapValues(
-                            map,
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
-
-            assertEqualTo(byteMap);
-        }
-
-        public static void assertEqualTo(Map<String, byte[]> map) {
-            assertThat(map).hasSize(2);
-            assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
-            assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
-        }
-    }
-
-    public static final byte[] INVALID_PROTO_BYES =
-            new byte[] { 'i', 'n', 'v', 'a', 'l', 'i', 'd' };
-
-    public static final class ValidFacebookCredential {
-        public final static String ID = "bob@facebook.com";
-        public final static String ID_TOKEN = "'His name is bob' - xoxo facebook";
-        public final static AuthenticationMethod AUTHENTICATION_METHOD =
-                AuthenticationMethods.FACEBOOK;
-        public final static String PASSWORD = "hunter2";
-        public final static String DISPLAY_NAME = "Bob";
-        public final static Uri DISPLAY_PICTURE_URL =
-                Uri.parse("https://pictures.facebook.com/bob_pics.jpeg");
-        public final static Map<String, byte[]> ADDITIONAL_PROPERTIES =
-                ValidProperties.MAP_INSTANCE;
-        public final static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
-        public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
-                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
-
-        public final static Credential INSTANCE =
-                new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN)
-                        .setDisplayName(DISPLAY_NAME)
-                        .setDisplayPicture(DISPLAY_PICTURE_URL)
-                        .setPassword(PASSWORD)
-                        .setIdToken(ID_TOKEN)
-                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
-                        .build();
-
-        public static void assertEqualTo(Credential credential) {
-            assertThat(credential.getIdentifier()).isEqualTo(ID);
-            assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
-            assertThat(credential.getPassword()).isEqualTo(PASSWORD);
-            assertThat(credential.getDisplayName()).isEqualTo(DISPLAY_NAME);
-            assertThat(credential.getDisplayPicture()).isEqualTo(DISPLAY_PICTURE_URL);
-            ValidProperties.assertEqualTo(credential.getAdditionalProperties());
-            assertThat(credential.getAuthenticationMethod()).isEqualTo(AUTHENTICATION_METHOD);
-            assertThat(credential.getAuthenticationDomain()).isEqualTo(AUTHENTICATION_DOMAIN);
-        }
-
-        public static void assertEqualTo(Protobufs.Credential credential) throws Exception {
-            assertEqualTo(Credential.fromProtobuf(credential));
-        }
-    }
-}
diff --git a/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java b/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java
index 11b5255..fa027be 100644
--- a/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java
+++ b/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java
@@ -20,83 +20,77 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.TestConstants.ValidTokenRequestInfo;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Tests for {@link TokenRequestInfo}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class TokenRequestInfoTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
-        TokenRequestInfo info = TestConstants.createTokenRequestInfo();
-        TestConstants.checkTokenRequestInfo(info);
-
+        TokenRequestInfo info = ValidTokenRequestInfo.make();
+        ValidTokenRequestInfo.assertEquals(info);
     }
 
     @Test
     public void builderSetClientId_nullValue_shouldSucceed() {
         TokenRequestInfo info = new TokenRequestInfo.Builder()
                 .setClientId(null)
                 .build();
 
         assertThat(info.getClientId()).isNull();
     }
 
     @Test
     public void builderSetClientId_emptyValue_treatedAsNull() {
         TokenRequestInfo info = new TokenRequestInfo.Builder()
                 .setClientId("")
                 .build();
 
         assertThat(info.getClientId()).isNull();
     }
 
     @Test
     public void builderSetNonce_nullValue_shouldSucceed() {
         TokenRequestInfo info = new TokenRequestInfo.Builder()
                 .setNonce(null)
                 .build();
 
         assertThat(info.getNonce()).isNull();
     }
 
     @Test
     public void builderSetNonce_emptyValue_treatedAsNull() {
         TokenRequestInfo info = new TokenRequestInfo.Builder()
                 .setNonce("")
                 .build();
 
         assertThat(info.getNonce()).isNull();
     }
 
     @Test
-    public void fromProto_validInput_shouldSucceed() throws MalformedDataException {
-        Protobufs.TokenRequestInfo proto = TestConstants.createTokenRequestInfoProto();
+    public void toProto_fromProto_isEquivalent() throws MalformedDataException {
+        Protobufs.TokenRequestInfo proto = ValidTokenRequestInfo.make().toProtobuf();
         TokenRequestInfo info = TokenRequestInfo.fromProtobuf(proto);
-        TestConstants.checkTokenRequestInfo(info);
+
+        ValidTokenRequestInfo.assertEquals(info);
     }
 
     @Test
     public void fromProto_defaultInstance_shouldSucceed() throws MalformedDataException {
         Protobufs.TokenRequestInfo proto = Protobufs.TokenRequestInfo.getDefaultInstance();
 
         TokenRequestInfo info = TokenRequestInfo.fromProtobuf(proto);
         assertThat(info.getClientId()).isNull();
         assertThat(info.getNonce()).isNull();
         assertThat(info.getAdditionalProperties()).isEmpty();
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtoBytes_invalidData_shouldThrowException() throws Exception {
         TokenRequestInfo.fromProtobufBytes(TestConstants.INVALID_PROTO_BYTES);
     }
-
-    @Test
-    public void toProto_validInput_shouldSucceed() {
-        TokenRequestInfo info = TestConstants.createTokenRequestInfo();
-        TestConstants.checkTokenRequestInfoProto(info.toProtobuf());
-    }
 }

commit 49421ff16b8adbe6c4d10573e3cef9297bee97da
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 6 10:49:25 2017 -0700

    Renamed DeviceState to AppSettings (#90)

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index f87719b..5c56e3d 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -49,4 +49,4 @@ import java.util.Map;
 
-import org.openyolo.api.persistence.DeviceState;
-import org.openyolo.api.persistence.internal.DeviceStateImpl;
+import org.openyolo.api.persistence.AppSettings;
+import org.openyolo.api.persistence.internal.AppSettingsImpl;
 import org.openyolo.api.ui.ProviderPickerActivity;
@@ -68,506 +68,506 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * The primary way of interacting with OpenYOLO credential providers. The client is light weight
  * allowing new instances to be created as needed.
  *
  * Requests are executed by starting an Activity based intent and its result returned via
  * {@link android.app.Activity#onActivityResult(int, int, Intent)}. For each request/response pair
  * there exist two client methods:
  * 1) Takes a given request and returns the Activity Intent which sends the request.
  * 2) Takes an Intent returned via {@link android.app.Activity#onActivityResult(int, int, Intent)}
  *    and returns the associated result.
  *
  * For example using the hint flow:
  * <pre>{@code
  * CredentialClient client = CredentialClient.getInstance(this);
  * HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
  *
  * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
  * startActivityForResult(retrieveHintIntent, RC_HINT);
  * // ...
  *
  * @Override
  * public void onActivityResult(int requestCode, int resultCode, Intent data) {
  *     super.onActivityResult(requestCode, resultCode, data);
  *
  *     HintRetrieveResult result = client.getHintRetrieveResult(data);
  * }}</pre>
  *
  * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#operations">
  *     OpenYOLO Specification: Operations</a>
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private final Context mApplicationContext;
     private final BroadcastQueryClient mQueryClient;
-    private final DeviceState mDeviceState;
+    private final AppSettings mDeviceState;
 
     /**
      * Returns a new credential client instance configured with the default options.
      */
     public static CredentialClient getInstance(@NonNull Context context) {
         CredentialClientOptions options =
-                new CredentialClientOptions.Builder(DeviceStateImpl.getInstance(context)).build();
+                new CredentialClientOptions.Builder(AppSettingsImpl.getInstance(context)).build();
 
         return getInstance(context, options);
     }
 
     /**
      * Returns a new credential client instance configured with the given
      * {@link CredentialClientOptions}.
      */
     public static CredentialClient getInstance(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         return new CredentialClient(context, BroadcastQueryClient.getInstance(context), options);
     }
 
     @VisibleForTesting
     CredentialClient(
             @NonNull Context context,
             @NonNull BroadcastQueryClient broadcastQueryClient,
             @NonNull CredentialClientOptions options) {
         validate(context, notNullValue(), NullPointerException.class);
         validate(broadcastQueryClient, notNullValue(), NullPointerException.class);
         validate(options, notNullValue(), NullPointerException.class);
 
         mApplicationContext = context.getApplicationContext();
         mQueryClient = broadcastQueryClient;
         mDeviceState = options.getDeviceState();
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's preferred credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
 
         if (mDeviceState.isAutoSignInDisabled()) {
             request = new CredentialRetrieveRequest.Builder(request)
                     .setRequireUserMediation(true)
                     .build();
         }
 
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
     @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             return null;
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             CredentialRetrieveResult result =
                     CredentialRetrieveResult.fromProtobufBytes(resultBytes);
 
             // Once a successfully retrieve result has been handled, re-enable auto sign-in.
             if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
                 mDeviceState.setIsAutoSignInDisabled(false);
             }
 
             return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return createDefaultHintRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a credential save request from the intent data returned by a provider.
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return createDefaultCredentialSaveResult();
         }
     }
 
     /**
      * Disables automatically signing a user until a successful response is given to
      * {@link CredentialClient#getCredentialRetrieveResult(Intent)}.
      */
     public void disableAutoSignIn() {
         mDeviceState.setIsAutoSignInDisabled(true);
     }
 
     @NonNull
     private static CredentialSaveResult createDefaultCredentialSaveResult() {
         return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
                 .build();
     }
 
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @NonNull
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/CredentialClientOptions.java b/api/java/org/openyolo/api/CredentialClientOptions.java
index 29b0d05..c42175b 100644
--- a/api/java/org/openyolo/api/CredentialClientOptions.java
+++ b/api/java/org/openyolo/api/CredentialClientOptions.java
@@ -21,52 +21,52 @@ import android.support.annotation.NonNull;
 
-import org.openyolo.api.persistence.DeviceState;
+import org.openyolo.api.persistence.AppSettings;
 
 
 /**
  * Context object that may be used to configure a {@link CredentialClient} instance.
  */
 public class CredentialClientOptions {
-    private final DeviceState mDeviceState;
+    private final AppSettings mAppSettings;
 
     private CredentialClientOptions(Builder builder) {
-        mDeviceState = builder.mDeviceState;
+        mAppSettings = builder.mAppSettings;
     }
 
     @NonNull
-    DeviceState getDeviceState() {
-        return mDeviceState;
+    AppSettings getDeviceState() {
+        return mAppSettings;
     }
 
     /**
      * Builder for {@link CredentialClientOptions}.
      */
     public static final class Builder {
-        private DeviceState mDeviceState;
+        private AppSettings mAppSettings;
 
         /**
          * Default builder for {@link CredentialClientOptions}.
          */
-        public Builder(@NonNull DeviceState deviceState) {
+        public Builder(@NonNull AppSettings deviceState) {
             setDeviceState(deviceState);
         }
 
         /**
-         * Specifies the {@link DeviceState} implementation that will be used by the
+         * Specifies the {@link AppSettings} implementation that will be used by the
          * {@link CredentialClient}.
          */
-        public Builder setDeviceState(@NonNull DeviceState deviceState) {
-            validate(deviceState, notNullValue(), NullPointerException.class);
+        public Builder setDeviceState(@NonNull AppSettings appSettings) {
+            validate(appSettings, notNullValue(), NullPointerException.class);
 
-            this.mDeviceState = deviceState;
+            this.mAppSettings = appSettings;
             return this;
         }
 
         /**
          * Returns a new {@link CredentialClientOptions} instance based on the configuration of this
          * builder.
          */
         public CredentialClientOptions build() {
             return new CredentialClientOptions(this);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/persistence/DeviceState.java b/api/java/org/openyolo/api/persistence/AppSettings.java
similarity index 84%
rename from api/java/org/openyolo/api/persistence/DeviceState.java
rename to api/java/org/openyolo/api/persistence/AppSettings.java
index e3bde63..403bed5 100644
--- a/api/java/org/openyolo/api/persistence/DeviceState.java
+++ b/api/java/org/openyolo/api/persistence/AppSettings.java
@@ -15,15 +15,17 @@
 package org.openyolo.api.persistence;
 
-/** Collection of per application per device settings that should be persisted. */
-public interface DeviceState {
+/**
+ * Interface for the collection persisted settings. Settings should beper application per device.
+ */
+public interface AppSettings {
 
     /**
      * Returns {@code true} if the current application has disabled automatically signing in.
      */
     boolean isAutoSignInDisabled();
 
     /**
      * Setter for {@link #isAutoSignInDisabled()}.
      */
     void setIsAutoSignInDisabled(boolean isDisabled);
 }
diff --git a/api/java/org/openyolo/api/persistence/internal/DeviceStateImpl.java b/api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java
similarity index 71%
rename from api/java/org/openyolo/api/persistence/internal/DeviceStateImpl.java
rename to api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java
index 07250f3..17f559a 100644
--- a/api/java/org/openyolo/api/persistence/internal/DeviceStateImpl.java
+++ b/api/java/org/openyolo/api/persistence/internal/AppSettingsImpl.java
@@ -18,35 +18,35 @@ import android.content.Context;
 
-import org.openyolo.api.persistence.DeviceState;
+import org.openyolo.api.persistence.AppSettings;
 
 /**
- * The default implementation of {@link DeviceState}.
+ * The default implementation of {@link AppSettings}.
  */
-public final class DeviceStateImpl implements DeviceState {
+public final class AppSettingsImpl implements AppSettings {
 
-    private static final String SETTING_NAME_SPACE = "DeviceState";
+    private static final String SETTING_NAME_SPACE = "AppSettings";
     private static final String KEY_IS_AUTO_SIGN_IN_DISABLED = "is_auto_sign_in_disabled";
 
     private final SettingsFactory.BooleanSetting mIsAutoSignInDisabled;
 
     /**
-     * Returns a new instance of {@link DeviceStateImpl}.
+     * Returns a new instance of {@link AppSettingsImpl}.
      */
-    public static DeviceState getInstance(Context context) {
-        return new DeviceStateImpl(SettingsFactoryImpl.getInstance(context, SETTING_NAME_SPACE));
+    public static AppSettings getInstance(Context context) {
+        return new AppSettingsImpl(SettingsFactoryImpl.getInstance(context, SETTING_NAME_SPACE));
     }
 
-    private DeviceStateImpl(SettingsFactory settingsFactory) {
+    private AppSettingsImpl(SettingsFactory settingsFactory) {
         mIsAutoSignInDisabled =
                 settingsFactory.makeBoolean(KEY_IS_AUTO_SIGN_IN_DISABLED, false /* defaultValue */);
     }
 
     @Override
     public boolean isAutoSignInDisabled() {
         return mIsAutoSignInDisabled.get();
     }
 
     @Override
     public void setIsAutoSignInDisabled(boolean isDisabled) {
         mIsAutoSignInDisabled.set(isDisabled);
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 2de4629..d08aeb8 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -49,3 +49,3 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.openyolo.api.persistence.DeviceState;
+import org.openyolo.api.persistence.AppSettings;
 import org.openyolo.protocol.AuthenticationDomain;
@@ -65,425 +65,425 @@ import org.robolectric.annotation.Config;
 /**
  * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
 
     private static final HintRetrieveRequest EMAIL_HINT_REQUEST =
             HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private BroadcastQueryClient mockBroadcastQueryClient;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     @Mock
-    private DeviceState mockDeviceState;
+    private AppSettings mockDeviceState;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(mockDeviceState).build();
         credentialClient = new CredentialClient(mockContext, mockBroadcastQueryClient, options);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void getInstance_returnsNonNull() throws Exception {
         CredentialClient test = CredentialClient.getInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(null /* intent*/);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
         final Intent intent = new Intent();
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
         final Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_validResult_returnsResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(
                         CredentialSaveResult.SAVED.toResultDataIntent());
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialRetrieveResult_withErrorResult_returnsErrorResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verifyNoMoreInteractions(mockDeviceState);
     }
 
     @Test
     public void getCredentialRetrieveResult_withSuccessfulResult_returnsSuccessfulResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verify(mockDeviceState).setIsAutoSignInDisabled(eq(false));
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     @Test
     public void retrieve_autoSignInDisabled_requestRequiresUserMediation() {
         CredentialRetrieveRequest request =
                 CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL);
 
         when(mockDeviceState.isAutoSignInDisabled()).thenReturn(true);
 
         // Act
         credentialClient.retrieve(request, null /* callBack */);
 
         // Assert
         ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
                 ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
         verify(mockBroadcastQueryClient)
                 .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
         assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isTrue();
     }
 
     @Test
     public void retrieve_autoSignInEnabled_requestDoesNotRequireUserMediation() {
         CredentialRetrieveRequest request =
                 new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                         .setRequireUserMediation(false)
                         .build();
 
         when(mockDeviceState.isAutoSignInDisabled()).thenReturn(false);
 
         // Act
         credentialClient.retrieve(request, null /* callBack */);
 
         // Assert
         ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
                 ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
         verify(mockBroadcastQueryClient)
                 .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
         assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isFalse();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }

commit 85d7d442598e77329a9e8301ca0654433a07d1fe
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 6 10:48:30 2017 -0700

    Added @see links to the associated OpenYOLO specification section (#88)

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 5e67411..f87719b 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -66,481 +66,508 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 import org.openyolo.protocol.internal.IntentUtil;
 
 /**
- * Interact with credential providers on the device which support OpenYOLO.
+ * The primary way of interacting with OpenYOLO credential providers. The client is light weight
+ * allowing new instances to be created as needed.
+ *
+ * Requests are executed by starting an Activity based intent and its result returned via
+ * {@link android.app.Activity#onActivityResult(int, int, Intent)}. For each request/response pair
+ * there exist two client methods:
+ * 1) Takes a given request and returns the Activity Intent which sends the request.
+ * 2) Takes an Intent returned via {@link android.app.Activity#onActivityResult(int, int, Intent)}
+ *    and returns the associated result.
+ *
+ * For example using the hint flow:
+ * <pre>{@code
+ * CredentialClient client = CredentialClient.getInstance(this);
+ * HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
+ *
+ * Intent retrieveHintIntent = client.getHintRetrieveIntent(request);
+ * startActivityForResult(retrieveHintIntent, RC_HINT);
+ * // ...
+ *
+ * @Override
+ * public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ *     super.onActivityResult(requestCode, resultCode, data);
+ *
+ *     HintRetrieveResult result = client.getHintRetrieveResult(data);
+ * }}</pre>
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#operations">
+ *     OpenYOLO Specification: Operations</a>
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private final Context mApplicationContext;
     private final BroadcastQueryClient mQueryClient;
     private final DeviceState mDeviceState;
 
     /**
      * Returns a new credential client instance configured with the default options.
      */
     public static CredentialClient getInstance(@NonNull Context context) {
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(DeviceStateImpl.getInstance(context)).build();
 
         return getInstance(context, options);
     }
 
     /**
      * Returns a new credential client instance configured with the given
      * {@link CredentialClientOptions}.
      */
     public static CredentialClient getInstance(
             @NonNull Context context,
             @NonNull CredentialClientOptions options) {
         return new CredentialClient(context, BroadcastQueryClient.getInstance(context), options);
     }
 
     @VisibleForTesting
     CredentialClient(
             @NonNull Context context,
             @NonNull BroadcastQueryClient broadcastQueryClient,
             @NonNull CredentialClientOptions options) {
         validate(context, notNullValue(), NullPointerException.class);
         validate(broadcastQueryClient, notNullValue(), NullPointerException.class);
         validate(options, notNullValue(), NullPointerException.class);
 
         mApplicationContext = context.getApplicationContext();
         mQueryClient = broadcastQueryClient;
         mDeviceState = options.getDeviceState();
     }
 
     /**
-     * Provides an intent to request a login hint. This will target the user's prefered credential
+     * Provides an intent to request a login hint. This will target the user's preferred credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
 
         if (mDeviceState.isAutoSignInDisabled()) {
             request = new CredentialRetrieveRequest.Builder(request)
                     .setRequireUserMediation(true)
                     .build();
         }
 
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
     @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             return null;
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             CredentialRetrieveResult result =
                     CredentialRetrieveResult.fromProtobufBytes(resultBytes);
 
             // Once a successfully retrieve result has been handled, re-enable auto sign-in.
             if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
                 mDeviceState.setIsAutoSignInDisabled(false);
             }
 
             return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return createDefaultHintRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a credential save request from the intent data returned by a provider.
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return createDefaultCredentialSaveResult();
         }
     }
 
     /**
      * Disables automatically signing a user until a successful response is given to
      * {@link CredentialClient#getCredentialRetrieveResult(Intent)}.
      */
     public void disableAutoSignIn() {
         mDeviceState.setIsAutoSignInDisabled(true);
     }
 
     @NonNull
     private static CredentialSaveResult createDefaultCredentialSaveResult() {
         return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
                 .build();
     }
 
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @NonNull
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/RetrieveCallback.java b/api/java/org/openyolo/api/RetrieveCallback.java
index b4fc326..8a1d606 100644
--- a/api/java/org/openyolo/api/RetrieveCallback.java
+++ b/api/java/org/openyolo/api/RetrieveCallback.java
@@ -17,5 +17,5 @@ package org.openyolo.api;
 import org.openyolo.protocol.RetrieveBbqResponse;
 
 /**
- * Asyncronous callback type for credential retrieval.
+ * Asynchronous callback type for credential retrieval.
  */
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 0042cc4..2de4629 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -51,2 +51,3 @@ import org.openyolo.api.persistence.DeviceState;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
@@ -64,429 +65,425 @@ import org.robolectric.annotation.Config;
 /**
  * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
 
+    private static final HintRetrieveRequest EMAIL_HINT_REQUEST =
+            HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
+
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private BroadcastQueryClient mockBroadcastQueryClient;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     @Mock
     private DeviceState mockDeviceState;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         CredentialClientOptions options =
                 new CredentialClientOptions.Builder(mockDeviceState).build();
         credentialClient = new CredentialClient(mockContext, mockBroadcastQueryClient, options);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void getInstance_returnsNonNull() throws Exception {
         CredentialClient test = CredentialClient.getInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
-        Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(EMAIL_HINT_REQUEST);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(null /* intent*/);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
         final Intent intent = new Intent();
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
         final Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_validResult_returnsResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(
                         CredentialSaveResult.SAVED.toResultDataIntent());
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialRetrieveResult_withErrorResult_returnsErrorResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verifyNoMoreInteractions(mockDeviceState);
     }
 
     @Test
     public void getCredentialRetrieveResult_withSuccessfulResult_returnsSuccessfulResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
 
         // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
         assertThat(result.getAdditionalProps()).isEmpty();
 
         verify(mockDeviceState).setIsAutoSignInDisabled(eq(false));
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     @Test
     public void retrieve_autoSignInDisabled_requestRequiresUserMediation() {
         CredentialRetrieveRequest request =
                 CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL);
 
         when(mockDeviceState.isAutoSignInDisabled()).thenReturn(true);
 
         // Act
         credentialClient.retrieve(request, null /* callBack */);
 
         // Assert
         ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
                 ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
         verify(mockBroadcastQueryClient)
                 .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
         assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isTrue();
     }
 
     @Test
     public void retrieve_autoSignInEnabled_requestDoesNotRequireUserMediation() {
         CredentialRetrieveRequest request =
                 new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                         .setRequireUserMediation(false)
                         .build();
 
         when(mockDeviceState.isAutoSignInDisabled()).thenReturn(false);
 
         // Act
         credentialClient.retrieve(request, null /* callBack */);
 
         // Assert
         ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
                 ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
         verify(mockBroadcastQueryClient)
                 .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
         assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isFalse();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index 9a6a33d..de66d6d 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -51,475 +51,475 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
     private static final int MIN_PASSWORD_LENGTH = 4;
 
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
     public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
     public final ObservableBoolean showError = new ObservableBoolean(false);
 
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
     private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
         mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
         mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
             mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
      * Initiates an OpenYOLO credential retrieval request, and forwards the response to
      * {@link #handleRetrieveQueryResult(RetrieveBbqResponse, Throwable)} for processing.
      */
     private void tryRetrieveExistingCredential() {
         setShowLoading(R.string.existing_account_search_prompt);
         mCredentialClient.retrieve(
                 CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL),
                 (queryResponse, queryError) ->
                     getExecutor().execute(
                             () -> handleRetrieveQueryResult(queryResponse, queryError)));
     }
 
     /**
      * Inspects the initial response from the OpenYOLO retrieve request. If a retrieve intent
      * is available, this is used to attempt to source a credential from the provider. The result
      * of this is indirectly routed to {@link #handleRetrieveResult(Intent)}.
      *
      * If no intent is returned, an attempt is made to source an account hint instead.
      */
     private void handleRetrieveQueryResult(
             RetrieveBbqResponse queryResponse,
             Throwable queryError) {
         if (queryResponse != null && queryResponse.getRetrieveIntent() != null) {
             Log.i(TAG, "retrieving credential from provider");
             mNavigator.get().startOpenYoloRetrieve(queryResponse.getRetrieveIntent());
             return;
         }
 
         Log.i(TAG, "no OpenYOLO providers for retrieve");
         tryRetrieveHint();
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
                 boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
                         credential.getPassword());
                 if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
-                HintRetrieveRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.of(AuthenticationMethods.EMAIL));
 
         if (hintIntent != null) {
             setShowLoading(R.string.requesting_hint_prompt);
             mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
                         hint.getDisplayPictureUri());
                 String hintPassword = hint.getGeneratedPassword();
 
 
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
                 boolean authenticated = false;
 
                 if (hintPassword != null) {
                     authenticated = mUserDataSource.createPasswordAccount(
                             hintEmail, displayName, displayPicture, hintPassword);
 
                     if (authenticated) {
                         // account created, attempt to save it back to the OpenYOLO provider
                         trySaveCredential(
                                 new Credential.Builder(
                                         hintEmail,
                                         AuthenticationMethods.EMAIL,
                                         AuthenticationDomain.getSelfAuthDomain(mApplication))
                                         .setDisplayName(displayName)
                                         .setDisplayPicture(displayPicture)
                                         .setPassword(hintPassword)
                                         .build());
                     }
                 }
 
                 if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
 
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
                 null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
     public void signInButtonClicked(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
         if (userPassword.length() < MIN_PASSWORD_LENGTH) {
             passwordError.set(getResourceString(R.string.error_password_too_short));
             return;
         } else {
             emailError.set("");
         }
 
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
                     null, // name
                     null, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 showError.set(true);
             }
         }
     }
 
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
             mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
         mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
         mNavigator.get().goToMain();
     }
 
     private void setShowLoading(@StringRes int loadingLabelId) {
         setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
     private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
         showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
         showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
index 2192260..80865f9 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
@@ -34,18 +34,21 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
 
 /**
  * A URI-based representation of an authentication domain, which determines the scope within which
  * a credential is valid. An authentication domain may have multiple equivalent representations,
  * such as when apps and sites share the same authentication system. The responsibility for
  * determining whether two given authentication domains are equivalent lies with the credential
  * provider.
  *
  * <p>Two broad classes of authentication domain are defined in the OpenYOLO
  * specification : Android authentication domains, of form
  * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
  * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
  * with no path, query or fragment. They must therefore always be of form
  * {@code scheme://authority}.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#authentication-domains">
+ *     OpenYOLO Specification: Authentication Domain</a>
  */
 @SuppressLint("PackageManagerGetSignatures")
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationMethod.java b/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
index 2f76a7e..adaafea 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
@@ -22,7 +22,10 @@ import java.io.IOException;
 import org.openyolo.protocol.internal.CustomMatchers;
 
 
 /**
  * A URI-based representation of an authentication method, which describes how a credential is
  * used to authenticate a user.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#authentication-methods">
+ *     OpenYOLO Specification: Authentication Method</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationMethods.java b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
index 13faad8..ebf60b7 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
@@ -17,6 +17,9 @@ package org.openyolo.protocol;
 import org.openyolo.protocol.Credential.Builder;
 
 /**
  * A set of well-known authentication method URIs for use with
  * {@link Builder#setAuthenticationMethod(AuthenticationMethod)}.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#authentication-methods">
+ *     OpenYOLO Specification: Authentication Method</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 2d79377..9de6565 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -36,11 +36,14 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * A representation of a credential for use in sign-in. This provides a higher-level,
  * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
  * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credentials">
+ *     OpenYOLO Specification: Credential</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index 63c8638..bf6a540 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -33,5 +33,8 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
+ *     OpenYOLO Specification: Credential Deletion</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index 9c1ccae..553651a 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -31,6 +31,9 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-deletion">
+ *     OpenYOLO Specification: Credential Deletion</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index ac82359..e711e11 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -47,5 +47,8 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 
 /**
  * A request for credentials, to be sent to credential providers on the device.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
+ *     OpenYOLO Specification: Credential Retrieval</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index dbcb075..e435e95 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -30,7 +30,10 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#credential-retrieval">
+ *     OpenYOLO Specification: Credential Retrieval</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index 382f3b5..b3f1328 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -29,10 +29,10 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * Result data which is sent in response to a credential save request. Contains a result code,
  * indicating whether the request was successful or not, and an optional set of additional,
  * non-standard result properties.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
- *     OpenYOLO specification: Saving Credentials</a>
+ *     OpenYOLO specification: Saving Credential</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/Hint.java b/protocol/java/org/openyolo/protocol/Hint.java
index adb6d77..8f0d3c0 100644
--- a/protocol/java/org/openyolo/protocol/Hint.java
+++ b/protocol/java/org/openyolo/protocol/Hint.java
@@ -37,11 +37,14 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * A representation of a hint for use in account discovery or account creation. This provides a
  * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential protocol
  * buffer} that is returned by the provider.
  *
  * <p>Hints must have an {@link #getIdentifier() identifier} and an
  * an {@link #getAuthenticationMethod() authentication method}, but all other properties are
  * optional.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
+ *     OpenYOLO specification: Hint</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
index 86759a4..fe290b3 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
@@ -43,347 +43,351 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
+ *     OpenYOLO specification: Hint</a>
  */
 public class HintRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRetrieveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRetrieveRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProperties;
 
     /**
-     * Creates a hint request for email and password based accounts.
+     * Creates a hint request from the given set of authentication methods.
      */
-    public static HintRetrieveRequest forEmailAndPasswordAccount() {
-        return new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .build();
+    public static HintRetrieveRequest of(AuthenticationMethod... authenticationMethods) {
+        return new HintRetrieveRequest.Builder(authenticationMethods).build();
+    }
+
+    /**
+     * Creates a hint request from the given set of authentication methods.
+     */
+    public static HintRetrieveRequest of(Set<AuthenticationMethod> authenticationMethods) {
+        return new HintRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws MalformedDataException {
         validate(hintRequestProtoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Reads a hint request from its protocol buffer form.
      * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtobuf(Protobufs.HintRetrieveRequest protobuf)
             throws MalformedDataException {
         validate(protobuf, notNullValue(), MalformedDataException.class);
 
         return new HintRetrieveRequest.Builder(protobuf).build();
     }
 
     private HintRetrieveRequest(@NonNull Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mPasswordSpec = builder.mPasswordSpec;
         mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The token providers supported by the requester, with the per-provider request info
      * message.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(mAdditionalProperties)
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          * @throws MalformedDataException if the given hint protocol buffer was not valid.
          *
          * @see HintRetrieveRequest#toProtocolBuffer()
          */
         private Builder(@NonNull Protobufs.HintRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
                 setPasswordSpecification(
                         PasswordSpecification.fromProtobuf(requestProto.getPasswordSpec()));
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
-        public Builder(
-                @NonNull AuthenticationMethod authMethod,
-                @NonNull AuthenticationMethod... additionalAuthMethods) {
-            setAuthenticationMethods(authMethod, additionalAuthMethods);
+        public Builder(@NonNull AuthenticationMethod... additionalAuthMethods) {
+            setAuthenticationMethods(additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
-        public Builder setAuthenticationMethods(
-                @NonNull AuthenticationMethod authMethod,
-                AuthenticationMethod... additionalAuthMethods) {
+        public Builder setAuthenticationMethods(AuthenticationMethod... authenticationMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
-                            authMethod,
-                            additionalAuthMethods,
+                            authenticationMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
             validate(authenticationMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             validate(passwordSpec, notNullValue(), IllegalArgumentException.class);
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRetrieveRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRetrieveRequest build() {
             return new HintRetrieveRequest(this);
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRetrieveRequest> {
         @Override
         public HintRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return HintRetrieveRequest.fromProtoBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRetrieveRequest[] newArray(int size) {
             return new HintRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
index 3f300d2..d9b90c1 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -31,6 +31,9 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
  * of the request, and the response may contain a hint.
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#hints">
+ *     OpenYOLO specification: Hint</a>
  */
diff --git a/protocol/java/org/openyolo/protocol/PasswordSpecification.java b/protocol/java/org/openyolo/protocol/PasswordSpecification.java
index e9fc386..5e896eb 100644
--- a/protocol/java/org/openyolo/protocol/PasswordSpecification.java
+++ b/protocol/java/org/openyolo/protocol/PasswordSpecification.java
@@ -39,44 +39,47 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 
 /**
  * Specification of an acceptable set of passwords, expressed in terms of allowed and required
  * sets of characters and a size range. Only ASCII printable characters are supported.
  *
  * <p>
  * Example Specifications:
  *
  * <ul>
  *     <li>
  *     A 12-16 character password that must contain at least one digit and one upper-case letter:
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .ofLength(12, 16)
  *             .allow(ALL_PRINTABLE)
  *             .require(NUMERALS, 1)
  *             .require(UPPER_ALPHA, 1)
  *             .build();
  *     }
  *     </li>
  *     <li>
  *     A 6-digit pin number:
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .allow(NUMERALS)
  *             .ofLength(6,6)
  *             .build();
  *     }
  *     </li>
  *     <li>
  *     An 8-12 character password permitting only alphanumeric characters
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .ofLength(8,12)
  *             .allow(LOWER_ALPHA)
  *             .allow(UPPER_ALPHA)
  *             .allow(NUMERALS)
  *             .build();
  *     }
  *     </li>
  * </ul>
  * </p>
+ *
+ * @see <a href="http://spec.openyolo.org/openyolo-android-spec.html#password-specifications">
+ *     OpenYOLO specification: Password Specifications</a>
  */
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index 62ef4e3..79df8f0 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -29,246 +29,236 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setPasswordSpecification(originalSpec)
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         TestConstants.checkTokenProviderMap(request.getTokenProviders());
         TestConstants.checkAdditionalProps(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
-    @Test
-    public void testForEmailAndPasswordAccount() {
-        HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
-        assertThat(request.getAuthenticationMethods())
-                .containsOnly(AuthenticationMethods.EMAIL);
-        assertThat(request.getPasswordSpecification())
-                .isEqualTo(PasswordSpecification.DEFAULT);
-        assertThat(request.getAdditionalProperties()).isEmpty();
-    }
-
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
-            HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
+            HintRetrieveRequest request = HintRetrieveRequest.of(AuthenticationMethods.EMAIL);
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
             TestConstants.checkTokenProviderMap(read.getTokenProviders());
             TestConstants.checkAdditionalProps(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAuthenticationMethods(null)
+                .setAuthenticationMethods((Set<AuthenticationMethod>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file

commit b3ea9bd12bf9d49c8c7d124107be796d2afd30a6
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Sep 6 10:12:57 2017 -0700

    Added #isSuccessful() methods to result types (#87)

diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index f9e6609..9c1ccae 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -33,258 +33,265 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  */
 public final class CredentialDeleteResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult UNKNOWN =
             new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
     private static final String UNABLE_TO_EXTRACT_RESULT =
             "Unable to extract or parse the credential deletion result";
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), IllegalArgumentException.class);
 
         return new CredentialDeleteResult.Builder(proto).build();
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
      * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
     public static CredentialDeleteResult fromResultIntentData(
             @Nullable Intent intent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_RESULT,
                         Protobufs.CredentialDeleteResult.parser(),
                         UNABLE_TO_EXTRACT_RESULT,
                         intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
+    /**
+     * Returns {@code true} if the request was successful.
+     */
+    public boolean isSuccessful() {
+        return CODE_DELETED == mResultCode;
+    }
+
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * credential deletion result, if available.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
     public Intent toResultDataIntent() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
          * @throws MalformedDataException if the protocol buffer could not be parsed from the
          *     intent.
          */
         private Builder(Protobufs.CredentialDeleteResult proto) throws MalformedDataException {
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion result. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index c0b9d04..dbcb075 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -32,258 +32,266 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
-     * Indicates that the user selected a hint, that has been returned as part of this response.
+     * Indicates that a credential was successfully chosen and has been returned as part of this
+     * response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
+    /**
+     * Returns {@code true} if the request was successful.
+     */
+    public boolean isSuccessful() {
+        return CODE_CREDENTIAL_SELECTED == mResultCode;
+    }
+
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          * @throws MalformedDataException if the given protocol buffer was invalid.
          */
         private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setCredentialFromProto(proto.getCredential());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
                 throws MalformedDataException {
             if (null == credential
                     || Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = null;
             } else {
                 mCredential = Credential.fromProtobuf(credential);
             }
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index 8ddd08a..382f3b5 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -31,236 +31,243 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential save request. Contains a result code,
  * indicating whether the request was successful or not, and an optional set of additional,
  * non-standard result properties.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credentials</a>
  */
 public final class CredentialSaveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential sent to the provider was saved.
      */
     public static final int CODE_SAVED =
             Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
 
     /**
      * Indicates the provider refused to save the credential, due to some policy restriction. For
      * example, a provider may refuse to update an existing credential if it is stored in a shared
      * keychain. The client SHOULD NOT request to save this credential again.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to delete the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates the user refused the request to save this credential. The client SHOULD NOT request
      * to save this credential again.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built save result for an unspecified outcome. Carries no additional properties.
      */
     public static final CredentialSaveResult UNSPECIFIED =
             new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built save result that indicates the credential was saved. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult SAVED =
             new CredentialSaveResult.Builder(CODE_SAVED).build();
 
     /**
      * Pre-built save result that indicates the request was malformed. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult BAD_REQUEST =
             new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to save the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final CredentialSaveResult USER_CANCELED =
             new CredentialSaveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the user. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult USER_REFUSED =
             new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the provider. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult PROVIDER_REFUSED =
             new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     private final int mResultCode;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential save result from its protocol buffer equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialSaveResult.Builder(proto).build();
     }
 
     /**
      * Creates a protocol buffer representation of the credential save result, for transmission
      * or storage.
      */
     public Protobufs.CredentialSaveResult toProtobuf() {
         Protobufs.CredentialSaveResult.Builder builder =
                 Protobufs.CredentialSaveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProperties);
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential save result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_SAVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     private CredentialSaveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProperties = builder.mAdditionalProps;
     }
 
+    /**
+     * Returns {@code true} if the request was successful.
+     */
+    public boolean isSuccessful() {
+        return CODE_SAVED == mResultCode;
+    }
+
+
     /**
      * The result code for the credential save operation.
      */
-    @NonNull
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link CredentialSaveResult} instances.
      */
     public static final class Builder {
         private int mResultCode = CODE_UNKNOWN;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result given the mandatory status
          * code.
          * @throws MalformedDataException if the given protocol buffer was not valid.
          */
         private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 proto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Seeds a credential save result from its protocol buffer equivalent.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
             return this;
         }
 
         /**
          * Finalizes the creation of the credential save result.
          */
         public CredentialSaveResult build() {
             return new CredentialSaveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
index cf4b39e..3f300d2 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -33,257 +33,264 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
  * of the request, and the response may contain a hint.
  */
 public final class HintRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN = ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the hint request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST = ResultCode.BAD_REQUEST_VALUE;
 
     /**
-     * Indicates that the user selected a hint, that has been returned as part of this response.
+     * Indicates that a hint was successfully chosen and has been returned as part of this response.
      */
     public static final int CODE_HINT_SELECTED = ResultCode.HINT_SELECTED_VALUE;
 
     /**
      * Indicates that no hints are available that meet the requirements of the hint request.
      */
     public static final int CODE_NO_HINTS_AVAILABLE = ResultCode.NO_HINTS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user  canceled the selection of a hint in a manner that indicates they
      * wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that The user canceled the selection of a hint in a manner that indicates they do
      * not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED = ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built hint result for an unspecified outcome. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult UNKNOWN =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_UNKNOWN).build();
 
     /**
      * Pre-built hint result for a bad request. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult BAD_REQUEST =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built hint result for when no hints are available. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult NO_HINTS_AVAILABLE =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_NO_HINTS_AVAILABLE).build();
 
     /**
      * Pre-built hint result for when the user requests manual authentication. Carries no hint
      * or additional properties.
      */
     public static final HintRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH)
                     .build();
 
     /**
      * Pre-built hint result for when the user canceled the selection of a hint in a manner that
      * indicates they do not wish to authenticate at this time. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult USER_CANCELED =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_USER_CANCELED).build();
 
     /**
      * Creates a hint result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto)
             throws MalformedDataException {
         return new HintRetrieveResult.Builder(proto).build();
     }
 
     /**
      * Creates a hint result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobufBytes(byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Hint mHint;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private HintRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mHint = builder.mHint;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint retrieve result, for transmission or
      * storage.
      */
     public Protobufs.HintRetrieveResult toProtobuf() {
         Protobufs.HintRetrieveResult.Builder builder =
                 Protobufs.HintRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mHint != null) {
             builder.setHint(mHint.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this hint retrieve result, that a provider should
      * return as its hint activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_HINT_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
+    /**
+     * Returns {@code true} if the request was successful.
+     */
+    public boolean isSuccessful() {
+        return CODE_HINT_SELECTED == mResultCode;
+    }
+
     /**
      * The hint retrieve result code.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The hint returned as part of the hint result, if available.
      */
     @Nullable
     public Hint getHint() {
         return mHint;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * hint result, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link HintRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @Nullable
         private Hint mHint;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a hint retrieve result, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(@NonNull Protobufs.HintRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
                 setHintFromProto(proto.getHint());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a hint retrieve result, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the returned hint, if available.
          */
         public Builder setHint(@Nullable Hint hint) {
             mHint = hint;
             return this;
         }
 
         private Builder setHintFromProto(@Nullable Protobufs.Hint hint)
                 throws MalformedDataException {
             if (null == hint || Protobufs.Hint.getDefaultInstance().equals(hint)) {
                 mHint = null;
             } else {
                 mHint = Hint.fromProtobuf(hint);
             }
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. A null map is treated as an empty map. For a non-null map, all keys and values
          * must not be null, and the keys must not be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the hint retrieve result, from the specified properties.
          */
         public HintRetrieveResult build() {
             return new HintRetrieveResult(this);
         }
     }
 }

commit 471241ccf663d08774698e23cab8c6ceb2ea8533
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Aug 30 10:09:49 2017 -0700

    ProviderPickerActivity improvments: (#84)
    
    - Replaced vector warning icon with png to avoid importing support
      library.
    - Improved accessibility support by increasing text and image size and
      contrast.
    - Added RTL support.
    - Added support for canceling the picker by tapping outside the bounds.

diff --git a/api/AndroidManifest.xml b/api/AndroidManifest.xml
index 8c8fd2c..ece46ed 100644
--- a/api/AndroidManifest.xml
+++ b/api/AndroidManifest.xml
@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.openyolo.api">
 
     <application>
-        <activity android:name=".ui.ProviderPickerActivity"
+        <activity
+            android:name=".ui.ProviderPickerActivity"
+            android:label="@string/provider_picker_activity_label"
             android:theme="@style/PickerTheme"
             android:exported="false" />
     </application>
 </manifest>
diff --git a/api/build.gradle b/api/build.gradle
index 412078a..fc60dc7 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -21,12 +21,11 @@ android {
 dependencies {
     api project(":bbq")
     api project(":protocol")
     implementation "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
     implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
-    implementation "com.android.support:support-vector-drawable:${rootProject.ext.supportLibVersion}"
     implementation "org.hamcrest:hamcrest-core:${rootProject.ext.hamcrestVersion}"
     implementation "org.valid4j:valid4j:${rootProject.ext.valid4jVersion}"
     apply from:'../config/testdeps.gradle', to:it
 
     testImplementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
 }
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
index acd97c3..f6a3fd2 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -23,9 +23,5 @@ import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
-import android.content.res.Resources;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
-import android.os.Build;
 import android.os.Bundle;
-import android.support.annotation.ColorRes;
-import android.support.annotation.DimenRes;
 import android.support.annotation.NonNull;
@@ -33,3 +29,2 @@ import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
-import android.support.graphics.drawable.VectorDrawableCompat;
 import android.support.v7.app.AppCompatActivity;
@@ -37,5 +32,6 @@ import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.Window;
+import android.view.ViewGroup.LayoutParams;
 import android.widget.ArrayAdapter;
@@ -47,3 +43,2 @@ import java.util.Collections;
 import java.util.List;
-
 import org.openyolo.api.KnownProviders;
@@ -57,246 +52,230 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * Activity which presents the list of providers that claim to have a credential available.
  * The user can select one of these options, which fires the associated intent for that provider,
  * or cancel the whole operation.
  */
-public class ProviderPickerActivity extends AppCompatActivity {
+public final class ProviderPickerActivity extends AppCompatActivity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
-    private static final String EXTRA_TITLE_RES = "titleRes";
+    private static final String EXTRA_TITLE_RES_ID = "titleRes";
     private static final String EXTRA_USER_CANCELED_RESULT = "userCanceledResult";
     private static final String LOG_TAG = "ProviderPicker";
 
     private static final ActivityResult RETRIEVE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialRetrieveResult.CODE_USER_CANCELED,
                     CredentialRetrieveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult SAVE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialSaveResult.CODE_USER_CANCELED,
                     CredentialSaveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult HINT_USER_CANCELED_RESULT =
             ActivityResult.of(
                     HintRetrieveResult.CODE_USER_CANCELED,
                     HintRetrieveResult.USER_CANCELED.toResultDataIntent());
 
     private static final ActivityResult DELETE_USER_CANCELED_RESULT =
             ActivityResult.of(
                     CredentialDeleteResult.CODE_USER_CANCELED,
                     CredentialDeleteResult.USER_CANCELED.toResultDataIntent());
 
+    private View mPickerContainer;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.picker_layout);
 
-        Rect rectangle = new Rect();
-        Window window = getWindow();
-        window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
-
-        Resources res = getResources();
-        @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
-        int statusBarHeight = 0;
-        if (resourceId > 0) {
-            statusBarHeight = res.getDimensionPixelSize(resourceId);
-        }
+        setContentView(R.layout.provider_picker_layout);
+        getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
 
-        getWindow().setLayout(
-                rectangle.width(),
-                rectangle.height() - statusBarHeight);
+        mPickerContainer = findViewById(R.id.picker_container);
 
-        TextView titleView = (TextView) findViewById(R.id.picker_title);
-        @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
-        if (titleRes != 0) {
-            //robotium has an issue recovering resources in the shadow classes.
-            titleView.setText(titleRes);
-        }
+        // Setup title
+        TextView titleView = findViewById(R.id.picker_title);
+        @StringRes int titleResId = getIntent().getIntExtra(EXTRA_TITLE_RES_ID, 0);
+        String title = getResources().getString(titleResId);
+        titleView.setText(title);
 
-        ListView providerView = (ListView) findViewById(R.id.provider_list);
+        // Setup provider list
+        ListView providerView = findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent event) {
+
+        // finishWithUserCanceled() if the user tapped outside the picker
+        if (MotionEvent.ACTION_DOWN == event.getAction()) {
+            Rect visibilityRect = new Rect();
+            mPickerContainer.getGlobalVisibleRect(visibilityRect);
+            boolean tappedOutsidePicker =
+                    !visibilityRect.contains((int) event.getRawX(), (int) event.getRawY());
+            if (tappedOutsidePicker) {
+                finishWithUserCanceled();
+            }
+        }
+
+        return super.dispatchTouchEvent(event);
+    }
+
     @Override
     public void onBackPressed() {
         finishWithUserCanceled();
     }
 
     private void finishWithUserCanceled() {
         ActivityResult activityResult = getIntent().getParcelableExtra(EXTRA_USER_CANCELED_RESULT);
 
         if (null != activityResult) {
             setResult(activityResult.getResultCode(), activityResult.getData());
         }
 
         finish();
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes,
             @Nullable ActivityResult userCanceledResult) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
-        intent.putExtra(EXTRA_TITLE_RES, titleRes);
+        intent.putExtra(EXTRA_TITLE_RES_ID, titleRes);
         intent.putExtra(EXTRA_USER_CANCELED_RESULT, userCanceledResult);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
 
         return createIntent(
                 context,
                 retrieveIntents,
                 R.string.retrieve_picker_prompt,
                 RETRIEVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
 
         return createIntent(
                 context,
                 retrieveIntents,
                 R.string.save_picker_prompt,
                 SAVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
 
         return createIntent(
                 context,
                 hintIntents,
                 R.string.hint_picker_prompt,
                 HINT_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for display a list of providers to which a credential deletion request
      * should be sent.
      */
     public static Intent createDeleteIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> deleteIntents) {
 
         return createIntent(
                 context,
                 deleteIntents,
                 R.string.delete_picker_prompt,
                 DELETE_USER_CANCELED_RESULT);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
-            ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
-            TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
-            TextView providerUnsafe =
-                    (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
-
-            // To support vector drawables on Pre-L devices we choose to set the drawable
-            // programmatically. See https://github.com/openid/OpenYOLO-Android/issues/63 for more
-            // details.
-            VectorDrawableCompat vectorDrawableCompat =
-                    VectorDrawableCompat.create(
-                            getResources(),
-                            R.drawable.warning_icon,
-                            getTheme());
-            providerUnsafe.setCompoundDrawablesWithIntrinsicBounds(
-                    vectorDrawableCompat,
-                    null,
-                    null,
-                    null);
+            ImageView providerIconView = itemView.findViewById(R.id.provider_icon);
+            TextView providerNameView = itemView.findViewById(R.id.provider_name);
+            View providerUnsafe = itemView.findViewById(R.id.unsafe_provider_warning);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
-
-        @SuppressWarnings("deprecation")
-        private int getColor(@ColorRes int colorRes) {
-            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
-                return getResources().getColor(colorRes, null);
-            } else {
-                return getResources().getColor(colorRes);
-            }
-        }
     }
 }
diff --git a/api/res/drawable-hdpi/warning_icon.png b/api/res/drawable-hdpi/warning_icon.png
new file mode 100644
index 0000000..81930d3
Binary files /dev/null and b/api/res/drawable-hdpi/warning_icon.png differ
diff --git a/api/res/drawable-mdpi/warning_icon.png b/api/res/drawable-mdpi/warning_icon.png
new file mode 100644
index 0000000..57611df
Binary files /dev/null and b/api/res/drawable-mdpi/warning_icon.png differ
diff --git a/api/res/drawable-xhdpi/warning_icon.png b/api/res/drawable-xhdpi/warning_icon.png
new file mode 100644
index 0000000..c6cafac
Binary files /dev/null and b/api/res/drawable-xhdpi/warning_icon.png differ
diff --git a/api/res/drawable-xxhdpi/warning_icon.png b/api/res/drawable-xxhdpi/warning_icon.png
new file mode 100644
index 0000000..6068107
Binary files /dev/null and b/api/res/drawable-xxhdpi/warning_icon.png differ
diff --git a/api/res/drawable/warning_icon.xml b/api/res/drawable/warning_icon.xml
deleted file mode 100644
index b7f3969..0000000
--- a/api/res/drawable/warning_icon.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="12dp"
-    android:height="12dp"
-    android:viewportWidth="12"
-    android:viewportHeight="12">
-    <path
-        android:fillColor="#FFA000"
-        android:pathData="M0.5,10.5 L11.5,10.5 L6,1 L0.5,10.5 Z M6.5,9 L5.5,9 L5.5,8 L6.5,8 L6.5,9 Z M6.5,7 L5.5,7
-L5.5,5 L6.5,5 L6.5,7 Z" />
-</vector>
\ No newline at end of file
diff --git a/api/res/layout-v17/provider_item.xml b/api/res/layout-v17/provider_item.xml
new file mode 100644
index 0000000..87d8ec4
--- /dev/null
+++ b/api/res/layout-v17/provider_item.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="48sp"
+    android:paddingLeft="16sp"
+    android:paddingRight="16sp"
+    android:clickable="true"
+    android:focusable="true"
+    android:background="?attr/selectableItemBackground"
+    android:orientation="horizontal"
+    android:gravity="center_vertical">
+
+    <ImageView
+        android:focusable="false"
+        android:id="@+id/provider_icon"
+        android:layout_width="32sp"
+        android:layout_height="32sp"
+        tools:ignore="ContentDescription"/>
+
+    <LinearLayout
+        android:focusable="false"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:layout_marginStart="16sp"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/provider_name"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textDirection="locale"
+            android:textSize="16sp"
+            android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
+            tools:text="Provider Name"/>
+
+        <LinearLayout
+            android:id="@+id/unsafe_provider_warning"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layoutDirection="locale"
+            android:orientation="horizontal">
+
+            <ImageView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:scaleType="centerInside"
+                android:src="@drawable/warning_icon"
+                android:adjustViewBounds="true"
+                android:maxHeight="16sp"
+                tools:ignore="ContentDescription"/>
+
+            <TextView
+                android:layout_marginLeft="8sp"
+                android:layout_marginRight="8sp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/possibly_unsafe"
+                android:textDirection="locale"
+                android:textSize="12sp"
+                android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
+        </LinearLayout>
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/api/res/layout-v17/provider_picker_layout.xml b/api/res/layout-v17/provider_picker_layout.xml
new file mode 100644
index 0000000..96bd9d7
--- /dev/null
+++ b/api/res/layout-v17/provider_picker_layout.xml
@@ -0,0 +1,43 @@
+<LinearLayout
+    android:id="@+id/picker_container"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fitsSystemWindows="true"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:layout_gravity="bottom">
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="3dp"
+        android:background="@drawable/bottom_sheet_edge"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="8sp"
+        android:orientation="vertical"
+        android:background="@color/grey_100_opaque">
+
+        <TextView
+            android:focusable="false"
+            android:id="@+id/picker_title"
+            android:layout_width="match_parent"
+            android:layout_height="56sp"
+            android:paddingLeft="16sp"
+            android:paddingRight="16sp"
+            android:textDirection="locale"
+            android:gravity="center_vertical"
+            android:textAppearance="@style/TextAppearance.AppCompat.Title"
+            android:textColor="@color/black_54pc" />
+
+        <ListView
+            android:id="@+id/provider_list"
+            android:layout_width="match_parent"
+            android:layout_height="0sp"
+            android:layout_gravity="bottom"
+            android:layout_weight="1"
+            android:divider="@null"
+            android:dividerHeight="0sp" />
+    </LinearLayout>
+</LinearLayout>
diff --git a/api/res/layout/provider_item.xml b/api/res/layout/provider_item.xml
index 877ece1..905c38d 100644
--- a/api/res/layout/provider_item.xml
+++ b/api/res/layout/provider_item.xml
@@ -1,44 +1,66 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
-    android:layout_height="48dp"
+    android:layout_height="48sp"
+    android:paddingLeft="16sp"
+    android:paddingRight="16sp"
     android:clickable="true"
     android:focusable="true"
     android:background="?attr/selectableItemBackground"
     android:orientation="horizontal"
     android:gravity="center_vertical">
 
     <ImageView
+        android:focusable="false"
         android:id="@+id/provider_icon"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        android:contentDescription="@string/provider_icon_contentDescription" />
+        android:layout_width="32sp"
+        android:layout_height="32sp"
+        tools:ignore="ContentDescription"/>
 
     <LinearLayout
+        android:focusable="false"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1"
-        android:layout_marginLeft="32dp"
-        android:layout_marginStart="32dp"
+        android:layout_marginLeft="16sp"
+        android:layout_marginStart="16sp"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/provider_name"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:textSize="16sp"
             android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
             tools:text="Provider Name"/>
 
-        <TextView
+        <LinearLayout
             android:id="@+id/unsafe_provider_warning"
-            android:layout_width="match_parent"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:drawablePadding="4dp"
-            android:text="@string/possibly_unsafe"
-            android:textAppearance="@style/TextAppearance.AppCompat.Caption"
-            android:textColor="@color/amber_700_54pc"/>
+            android:orientation="horizontal">
+
+            <ImageView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:scaleType="centerInside"
+                android:src="@drawable/warning_icon"
+                android:adjustViewBounds="true"
+                android:maxHeight="16sp"
+                tools:ignore="ContentDescription"/>
+
+            <TextView
+                android:layout_marginLeft="8sp"
+                android:layout_marginRight="8sp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/possibly_unsafe"
+                android:textSize="12sp"
+                android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
+        </LinearLayout>
+
     </LinearLayout>
 
 </LinearLayout>
diff --git a/api/res/layout/picker_layout.xml b/api/res/layout/provider_picker_layout.xml
similarity index 65%
rename from api/res/layout/picker_layout.xml
rename to api/res/layout/provider_picker_layout.xml
index 13be7a0..ea59f08 100644
--- a/api/res/layout/picker_layout.xml
+++ b/api/res/layout/provider_picker_layout.xml
@@ -1,42 +1,42 @@
 <LinearLayout
+    android:id="@+id/picker_container"
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
+    android:fitsSystemWindows="true"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_gravity="bottom"
     android:orientation="vertical"
-    tools:ignore="Overdraw">
+    android:layout_gravity="bottom">
 
     <View
         android:layout_width="match_parent"
         android:layout_height="3dp"
-        android:background="@drawable/bottom_sheet_edge" />
+        android:background="@drawable/bottom_sheet_edge"/>
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/grey_100_opaque"
+        android:paddingBottom="8sp"
         android:orientation="vertical"
-        android:paddingLeft="16dp"
-        android:paddingRight="16dp"
-        android:paddingBottom="8dp">
+        android:background="@color/grey_100_opaque">
 
         <TextView
+            android:focusable="false"
             android:id="@+id/picker_title"
             android:layout_width="match_parent"
-            android:layout_height="56dp"
+            android:layout_height="56sp"
+            android:paddingLeft="16sp"
+            android:paddingRight="16sp"
             android:gravity="center_vertical"
             android:textAppearance="@style/TextAppearance.AppCompat.Title"
             android:textColor="@color/black_54pc" />
 
         <ListView
             android:id="@+id/provider_list"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
+            android:layout_height="0sp"
             android:layout_gravity="bottom"
             android:layout_weight="1"
             android:divider="@null"
-            android:dividerHeight="0dp" />
-
+            android:dividerHeight="0sp" />
     </LinearLayout>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/api/res/values/colors.xml b/api/res/values/colors.xml
index 3963b40..24ceebb 100644
--- a/api/res/values/colors.xml
+++ b/api/res/values/colors.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <color name="grey_100_opaque">#F5F5F5</color>
-    <color name="amber_700_54pc">#89FFA000</color>
     <color name="black_54pc">#89000000</color>
 </resources>
\ No newline at end of file
diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
index f8f6470..7f442ae 100644
--- a/api/res/values/strings.xml
+++ b/api/res/values/strings.xml
@@ -1,9 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <string name="retrieve_picker_prompt">Use account from:</string>
-    <string name="provider_icon_contentDescription">Provider icon</string>
+    <string name="provider_picker_activity_label">Credential provider picker</string>
+
     <string name="possibly_unsafe">Possibly unsafe</string>
+
+    <string name="retrieve_picker_prompt">Use account from:</string>
     <string name="save_picker_prompt">Save your account with:</string>
     <string name="hint_picker_prompt">Use account details stored in:</string>
     <string name="delete_picker_prompt">Delete credential from:</string>
 </resources>
\ No newline at end of file
diff --git a/testapp/AndroidManifest.xml b/testapp/AndroidManifest.xml
index ed37bec..b541964 100644
--- a/testapp/AndroidManifest.xml
+++ b/testapp/AndroidManifest.xml
@@ -1,35 +1,35 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package="org.openyolo.testapp" >
 
     <uses-permission android:name="android.permission.INTERNET" />
 
     <application
             android:allowBackup="false"
             android:fullBackupContent="false"
             android:icon="@mipmap/ic_launcher"
             android:label="@string/app_name_short"
             android:theme="@style/AppTheme"
-            android:supportsRtl="false" >
+            android:supportsRtl="true" >
 
         <activity
                 android:name=".OpenYoloTestActivity"
                 android:label="@string/app_name_short"
                 android:theme="@style/AppTheme.NoActionBar"
                 android:windowSoftInputMode="stateHidden"
                 android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:host="openyolo.demo-app.io"
                    android:scheme="https" />
             </intent-filter>
         </activity>
 
     </application>
 </manifest>

commit a32dc45b32dc89b868363d63b5b4b8768c86aee1
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Tue Aug 29 09:55:02 2017 -0700

    Only hold weak reference to main navigator (#83)

diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
index f05b3db..b3db543 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
@@ -23,2 +23,3 @@ import android.support.annotation.WorkerThread;
 import android.view.View;
+import java.lang.ref.WeakReference;
 import java.util.concurrent.ScheduledExecutorService;
@@ -29,82 +30,82 @@ import org.openyolo.demoapp.passwordlogin.userdata.UserDataSource;
 /**
  * The view model for the main activity, which is displayed when the user has authenticated
  * successfully.
  */
 @WorkerThread
 public final class MainViewModel extends ObservableViewModel {
 
     /**
      * The user's display name for display on screen, if known.
      */
     public final ObservableField<String> displayName = new ObservableField<>("");
 
     /**
      * The user's email address for display on screen.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The user's display picture for display on screen, if known.
      */
     public final ObservableField<String> displayPicture = new ObservableField<>("");
 
     private final AtomicBoolean mFirstLoad = new AtomicBoolean(true);
     private final UserDataSource mUserDataSource;
-    private MainNavigator mNavigator;
+    private WeakReference<MainNavigator> mNavigator;
 
     /**
      * Creates the view model, with the required application reference.
      */
     public MainViewModel(@NonNull Application application) {
         super(application);
         mUserDataSource = ((OpenYoloDemoApplication)application).getUserRepository();
     }
 
     /**
      * Specifies the navigator for use in communicating with the activity environment.
      */
     @MainThread
     public void setNavigator(@NonNull MainNavigator navigator) {
-        mNavigator = navigator;
+        mNavigator = new WeakReference<>(navigator);
     }
 
     /**
      * The entry point to the view model's behavior. Determines whether a user is currently
      * authenticated, and if not, redirects to the login activity. Otherwise, the currently
      * authenticated user is displayed on screen.
      */
     public void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         User currentUser = mUserDataSource.getCurrentUser();
         if (currentUser == null) {
             // no user available, go to login screen
-            mNavigator.goToLogin();
+            mNavigator.get().goToLogin();
             return;
         }
 
         this.email.set(currentUser.getEmail());
         this.displayName.set(currentUser.getName());
         this.displayPicture.set(currentUser.getProfilePictureUri());
     }
 
     /**
      * Delegates handling of sign-out to a background thread, which de-authenticates the current
      * user and redirects to the login activity.
      */
     @MainThread
     public void onSignOutClicked(View view) {
         getExecutor().execute(() -> {
             mUserDataSource.signOut();
-            mNavigator.goToLogin();
+            mNavigator.get().goToLogin();
         });
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return OpenYoloDemoApplication.getInstance(getApplication()).getExecutor();
     }
 }

commit 263ffa080affd6bba899a390b14c1e0b3c0d9bf7
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Aug 28 10:19:27 2017 -0700

    Demo app review comment fixes

diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
index f111ba5..9a6a33d 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -32,2 +32,3 @@ import android.util.Patterns;
 import android.view.View;
+import java.lang.ref.WeakReference;
 import java.util.concurrent.ScheduledExecutorService;
@@ -50,464 +51,475 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 /**
  * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
  * which an email address and password, including interacting with any available OpenYOLO provider
  * to directly retrieve or generate credentials.
  */
 @WorkerThread
 public final class LoginViewModel extends ObservableViewModel {
 
     private static final String TAG = "LoginViewModel";
 
     private static final int MIN_PASSWORD_LENGTH = 4;
 
     /**
      * Indicates whether a progress bar should be displayed to the user, while an asynchronous
      * request is made.
      */
-    public final ObservableBoolean loading = new ObservableBoolean(true);
+    public final ObservableBoolean showLoading = new ObservableBoolean(true);
 
     /**
      * Describes the asynchronous request that is occurring to the user.
      */
     public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
 
     /**
      * The prompt that is displayed to the user for manual authentication, instructing them what
      * to do next.
      */
     public final ObservableField<String> authPrompt = new ObservableField<>("");
 
     /**
      * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
      */
     public final ObservableField<String> email = new ObservableField<>("");
 
     /**
      * The error string displayed below the email text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> emailError = new ObservableField<>("");
 
     /**
      * Whether the password entry field should be displayed at this time.
      */
     public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
 
     /**
      * The password the user has entered.
      */
     public final ObservableField<String> password = new ObservableField<>("");
 
     /**
      * The error string displayed below the password text input element. If the string is empty,
      * the error is not displayed.
      */
     public final ObservableField<String> passwordError = new ObservableField<>("");
 
     /**
      * Whether to show a generic error message to the user - this happens when requests fail
      * in a way that we cannot recover from, other than asking the user to potentially try again.
      */
-    public final ObservableBoolean errorOccurred = new ObservableBoolean(false);
+    public final ObservableBoolean showError = new ObservableBoolean(false);
 
     @SuppressLint("StaticFieldLeak")
     private final OpenYoloDemoApplication mApplication;
     private final CredentialClient mCredentialClient;
     private final UserDataSource mUserDataSource;
 
-    private LoginNavigator mNavigator;
+    private WeakReference<LoginNavigator> mNavigator;
     private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
 
     /**
      * Creates the view model, with the required application reference.
      */
     @Keep
     public LoginViewModel(Application application) {
         super(application);
         mApplication = OpenYoloDemoApplication.getInstance(application);
         mUserDataSource = mApplication.getUserRepository();
-        mCredentialClient = CredentialClient.getApplicationBoundInstance(application);
+        mCredentialClient = CredentialClient.getInstance(mApplication);
     }
 
     /**
      * Specifies the navigator instance used by the view model to interact with the
      * activity environment.
      */
     @MainThread
     void setNavigator(LoginNavigator navigator) {
-        mNavigator = navigator;
+        mNavigator = new WeakReference<LoginNavigator>(navigator);
     }
 
     /**
      * The main entry point. If the model has not been previously started, it will attempt to
      * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
      * authentication attempts until success.
      */
     void start() {
         if (!mFirstLoad.compareAndSet(true, false)) {
             // already started
             return;
         }
 
         if (mUserDataSource.getCurrentUser() != null) {
             // already signed in, go straight to the main activity
-            mNavigator.goToMain();
+            mNavigator.get().goToMain();
             return;
         }
 
         tryRetrieveExistingCredential();
     }
 
     /**
      * Initiates an OpenYOLO credential retrieval request, and forwards the response to
      * {@link #handleRetrieveQueryResult(RetrieveBbqResponse, Throwable)} for processing.
      */
     private void tryRetrieveExistingCredential() {
-        setLoading("Looking for an existing account…");
+        setShowLoading(R.string.existing_account_search_prompt);
         mCredentialClient.retrieve(
                 CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL),
                 (queryResponse, queryError) ->
                     getExecutor().execute(
                             () -> handleRetrieveQueryResult(queryResponse, queryError)));
     }
 
     /**
      * Inspects the initial response from the OpenYOLO retrieve request. If a retrieve intent
      * is available, this is used to attempt to source a credential from the provider. The result
      * of this is indirectly routed to {@link #handleRetrieveResult(Intent)}.
      *
      * If no intent is returned, an attempt is made to source an account hint instead.
      */
     private void handleRetrieveQueryResult(
             RetrieveBbqResponse queryResponse,
             Throwable queryError) {
         if (queryResponse != null && queryResponse.getRetrieveIntent() != null) {
             Log.i(TAG, "retrieving credential from provider");
-            mNavigator.startOpenYoloRetrieve(queryResponse.getRetrieveIntent());
+            mNavigator.get().startOpenYoloRetrieve(queryResponse.getRetrieveIntent());
             return;
         }
 
         Log.i(TAG, "no OpenYOLO providers for retrieve");
         tryRetrieveHint();
     }
 
     /**
      * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
      * the credential retrieve request, potentially with user input.
      *
      * If a credential is returned, an authentication attempt is made using it. If this fails, the
      * user is prompted to manually authenticate.
      *
      * If no credential is returned, an attempt is made to source an account hint instead.
      */
     public void handleRetrieveResult(Intent data) {
         CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
                 Log.i(TAG, "Credential was returned by OpenYOLO provider");
                 Credential credential = result.getCredential();
-                if (mUserDataSource.authWithPassword(
+                boolean authenticated = mUserDataSource.authWithPassword(
                         credential.getIdentifier(),
-                        credential.getPassword())) {
+                        credential.getPassword());
+                if (authenticated) {
                     // save the credential back to the provider, as a signal that it still works.
                     trySaveCredential(credential);
                 } else {
                     doManualAuthentication(
                             R.string.incorrect_stored_password,
                             credential.getIdentifier());
                 }
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 Log.i(TAG, "Provider indicated that no credentials are available");
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "The user canceled selection of an existing credential");
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "The user requests manual authentication");
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated that the request was malformed");
                 break;
             case CredentialRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
-                null);
+                null); // userEmail
     }
 
     /**
      * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
      * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
      * available, then the user is prompted to manually authenticate.
      */
     private void tryRetrieveHint() {
         Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         if (hintIntent != null) {
-            setLoading("Asking your credential manager for account details…");
-            mNavigator.startOpenYoloHint(hintIntent);
+            setShowLoading(R.string.requesting_hint_prompt);
+            mNavigator.get().startOpenYoloHint(hintIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers for hint");
         doManualAuthentication(
                 R.string.enter_email_prompt,
-                null);
+                null); // userEmail
     }
 
     /**
      * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
      * check is made to determine whether an account already exists for the returned identifier.
      * If it is, the user is prompted to enter their password for that account. Otherwise, an
      * account is automatically created using the returned hint details.
      *
      * If no hint is returned, the user is prompted to manually authenticate.
      */
     public void handleHintResult(Intent data) {
         HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
 
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_HINT_SELECTED:
                 Log.i(TAG, "User selected a hint from the OpenYOLO provider");
                 Hint hint = result.getHint();
 
                 if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
                     doManualAuthentication(
                             R.string.existing_account_enter_password,
                             hint.getIdentifier());
                     return;
                 }
 
                 String hintEmail = hint.getIdentifier();
                 String displayName = normalizeDisplayName(hint.getDisplayName());
                 String displayPicture = normalizeDisplayPictureUri(
                         hint.getIdentifier(),
                         hint.getDisplayPictureUri());
                 String hintPassword = hint.getGeneratedPassword();
 
+
                 // attempt to create an account with the returned hint. If this fails, ask the
                 // user to manually authenticate.
-                if (hintPassword != null && mUserDataSource.createPasswordAccount(
-                        hintEmail, displayName, displayPicture, hintPassword)) {
-                    // account created, attempt to save it back to the OpenYOLO provider
-                    trySaveCredential(
-                            new Credential.Builder(
-                                    hintEmail,
-                                    AuthenticationMethods.EMAIL,
-                                    AuthenticationDomain.getSelfAuthDomain(mApplication))
-                                    .setDisplayName(displayName)
-                                    .setDisplayPicture(displayPicture)
-                                    .setPassword(hintPassword)
-                                    .build());
-                } else {
+                boolean authenticated = false;
+
+                if (hintPassword != null) {
+                    authenticated = mUserDataSource.createPasswordAccount(
+                            hintEmail, displayName, displayPicture, hintPassword);
+
+                    if (authenticated) {
+                        // account created, attempt to save it back to the OpenYOLO provider
+                        trySaveCredential(
+                                new Credential.Builder(
+                                        hintEmail,
+                                        AuthenticationMethods.EMAIL,
+                                        AuthenticationDomain.getSelfAuthDomain(mApplication))
+                                        .setDisplayName(displayName)
+                                        .setDisplayPicture(displayPicture)
+                                        .setPassword(hintPassword)
+                                        .build());
+                    }
+                }
+
+                if (!authenticated) {
                     doManualAuthentication(
                             R.string.new_account_enter_password,
                             hint.getIdentifier());
                 }
+
                 return;
 
             // you may wish to behave differently in your own application in response to each of
             // the following cases (which are enumerated here to demonstrate the possible
             // responses), but for simplicity in this demo app we treat them all as requiring
             // manual authentication by the user
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 Log.i(TAG, "Provider indicated there are no hints available");
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled the hint selection flow");
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 Log.i(TAG, "User requests manual authentication");
                 break;
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Proivder indicates that the request was malformed");
                 break;
             case HintRetrieveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
                 break;
         }
 
         doManualAuthentication(
                 R.string.enter_email_prompt,
-                null);
+                null); // userEmail
     }
 
     /**
      * Prompts the user to manually authenticate, with a context-specific message.
      */
     private void doManualAuthentication(
             @StringRes int authPromptId,
             @Nullable String userEmail) {
         this.authPrompt.set(getResourceString(authPromptId));
         this.email.set(userEmail != null ? userEmail : "");
         this.showPasswordField.set(userEmail != null);
         this.password.set("");
         setLoaded();
     }
 
     /**
      * Pushes handling of a sign in button click on the form to a background thread for processing.
      */
     @MainThread
     public void signInButtonClicked(View view) {
         getExecutor().execute(this::tryManualAuthentication);
     }
 
     /**
      * Processes an attempt to manually authenticate.
      */
     private void tryManualAuthentication() {
         String userEmail = this.email.get().trim();
         String userPassword = this.password.get();
 
         if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
             emailError.set(getResourceString(R.string.error_invalid_email));
             return;
         } else {
             emailError.set("");
         }
 
         if (userPassword.length() < MIN_PASSWORD_LENGTH) {
             passwordError.set(getResourceString(R.string.error_password_too_short));
             return;
         } else {
             emailError.set("");
         }
 
         if (mUserDataSource.isExistingAccount(userEmail)) {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.existing_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
                 passwordError.set(getResourceString(R.string.error_incorrect_password));
             }
         } else {
             if (userPassword.isEmpty()) {
                 authPrompt.set(getResourceString(R.string.new_account_enter_password));
                 showPasswordField.set(true);
             } else if (mUserDataSource.createPasswordAccount(
                     userEmail,
-                    null,
-                    null,
+                    null, // name
+                    null, // profilePictureUri
                     userPassword)) {
                 trySaveCredential(
                         new Credential.Builder(
                                 userEmail,
                                 AuthenticationMethods.EMAIL,
                                 AuthenticationDomain.getSelfAuthDomain(mApplication))
                                 .setPassword(userPassword)
                                 .build());
             } else {
-                errorOccurred.set(true);
+                showError.set(true);
             }
         }
     }
 
     private void trySaveCredential(Credential credential) {
         Intent saveIntent =
                 mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
 
         if (saveIntent != null) {
             Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
-            mNavigator.startSave(saveIntent);
+            mNavigator.get().startSave(saveIntent);
             return;
         }
 
         Log.i(TAG, "No OpenYOLO providers to save credential");
-        mNavigator.goToMain();
+        mNavigator.get().goToMain();
     }
 
     /**
      * Handles the credential save result from the OpenYOLO provider, returned via
      * {@link LoginActivity}.
      */
     public void handleSaveResult(Intent data) {
         CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
 
         // you may wish to handle the outcomes of save differently in your own application; for this
         // demo, the outcome of the save request is mostly irrelevant.
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 Log.i(TAG, "User saved credential");
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 Log.i(TAG, "User canceled credential save");
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 Log.i(TAG, "User refused to save credential");
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 Log.i(TAG, "Provider refused to save credential");
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 Log.i(TAG, "Provider indicated the save request was malformed");
                 break;
             case CredentialSaveResult.CODE_UNKNOWN:
             default:
                 Log.i(TAG, "An unknown error occurred while saving the credential");
                 break;
         }
 
-        mNavigator.goToMain();
+        mNavigator.get().goToMain();
     }
 
-    private void setLoading(@StringRes int loadingLabelId) {
-        setLoading(getApplication().getResources().getString(loadingLabelId));
+    private void setShowLoading(@StringRes int loadingLabelId) {
+        setShowLoading(getApplication().getResources().getString(loadingLabelId));
     }
 
-    private void setLoading(String reason) {
+    private void setShowLoading(String reason) {
         this.loadingLabel.set(reason);
-        loading.set(true);
+        showLoading.set(true);
     }
 
     private void setLoaded() {
         loadingLabel.set("");
-        loading.set(false);
+        showLoading.set(false);
     }
 
     @AnyThread
     private String getResourceString(@StringRes int stringId, Object... formatArgs) {
         return getApplication().getResources().getString(stringId, formatArgs);
     }
 
     @AnyThread
     private ScheduledExecutorService getExecutor() {
         return ((OpenYoloDemoApplication)getApplication()).getExecutor();
     }
 
     @NonNull
     private String normalizeDisplayName(@Nullable String displayName) {
         return displayName != null ? displayName : "J Doe";
     }
 
     @NonNull
     private String normalizeDisplayPictureUri(
             @NonNull String userEmail,
             @Nullable Uri displayPictureUri) {
         if (displayPictureUri != null) {
             return displayPictureUri.toString();
         }
 
         return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
     }
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java
index 46908a1..97b226b 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java
@@ -20,35 +20,37 @@ import android.support.annotation.Nullable;
 /**
  * A service which can authenticate users, and remember who the current user is.
  */
 public interface UserDataSource {
 
     /**
      * The currently authenticated user, if any.
      */
     @Nullable
     User getCurrentUser();
 
     /**
      * Whether an account exists for the specified email address.
      */
     boolean isExistingAccount(@NonNull String email);
 
     /**
-     * Attempts to create and persist a new user account account with the specified properties.
+     * Attempts to create and persist a new user account account with the specified properties;
+     * returns true if a new account is created.
      */
     boolean createPasswordAccount(
             @NonNull String email,
             @NonNull String name,
             @NonNull String profilePictureUri,
             @NonNull String password);
 
     /**
-     * Attempts to authenticate an existing user with the provided credentials.
+     * Attempts to authenticate an existing user with the provided credentials; returns true if
+     * authentication succeeds.
      */
     boolean authWithPassword(@NonNull String email, @NonNull String password);
 
     /**
      * De-authenticates the current user.
      */
     void signOut();
 }
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java
index 074fa15..550dfa1 100644
--- a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java
@@ -26,93 +26,98 @@ import org.openyolo.demoapp.passwordlogin.OpenYoloDemoApplication;
 /**
  * A local implementation of UserDataSource for the purposes of this demo. This could be
  * replaced with a more realistic implementation that makes network requests in order to
  * authenticate the user.
  */
 @WorkerThread
 public class UserRepository implements UserDataSource {
 
+    private static final String USER_DB_NAME = "userdb";
+    private static final String AUTH_INFO_SHARED_PREFS = "authInfo";
     private static final String KEY_CURRENT_USER = "user";
 
     private final UserDatabase mUserDatabase;
     private final SharedPreferences mSharedPrefs;
 
     /**
      * Creates the user repository, with the required application reference.
      */
     public UserRepository(@NonNull OpenYoloDemoApplication application) {
-        mUserDatabase = Room.databaseBuilder(application, UserDatabase.class, "userdb")
+        mUserDatabase = Room.databaseBuilder(application, UserDatabase.class, USER_DB_NAME)
                 .build();
-        mSharedPrefs = application.getSharedPreferences("authInfo", Context.MODE_PRIVATE);
+        mSharedPrefs = application.getSharedPreferences(
+                AUTH_INFO_SHARED_PREFS,
+                Context.MODE_PRIVATE);
     }
 
     @Override
     @Nullable
     public User getCurrentUser() {
         String currentUserEmail = getCurrentUserEmail();
         if (currentUserEmail == null) {
             return null;
         }
 
         return mUserDatabase.userDao().getUserByEmail(currentUserEmail);
     }
 
     @Override
     public boolean isExistingAccount(String email) {
         return mUserDatabase.userDao().getUserByEmail(email) != null;
     }
 
     @Override
     public boolean createPasswordAccount(
             @NonNull String email,
-            String name,
-            String profilePictureUri,
-            String password) {
+            @Nullable String name,
+            @Nullable String profilePictureUri,
+            @NonNull String password) {
         if (isExistingAccount(email)) {
             return false;
         }
 
         String salt = HashUtil.generateSalt();
         String hash = HashUtil.hashPassword(salt, password);
 
         mUserDatabase.userDao().createUser(new User(email, name, salt, hash, profilePictureUri));
         setCurrentUserEmail(email);
         return true;
     }
 
     @Override
-    public boolean authWithPassword(String email, String password) {
+    public boolean authWithPassword(@NonNull String email, @NonNull String password) {
         User user = mUserDatabase.userDao().getUserByEmail(email);
         if (user == null) {
             return false;
         }
 
         String salt = user.getPasswordSalt();
         String hash = HashUtil.hashPassword(salt, password);
 
         if (hash.equals(user.getPasswordHash())) {
             setCurrentUserEmail(email);
             return true;
         } else {
             return false;
         }
     }
 
     @Override
     public void signOut() {
         setCurrentUserEmail(null);
     }
 
+    @Nullable
     private String getCurrentUserEmail() {
         return mSharedPrefs.getString(KEY_CURRENT_USER, null);
     }
 
-    private void setCurrentUserEmail(String email) {
+    private void setCurrentUserEmail(@Nullable String email) {
         Editor editor = mSharedPrefs.edit();
         if (email == null) {
             editor.remove(KEY_CURRENT_USER);
         } else {
             editor.putString(KEY_CURRENT_USER, email);
         }
         editor.apply();
     }
 }
diff --git a/demoapps/passwordlogin/res/layout/login_layout.xml b/demoapps/passwordlogin/res/layout/login_layout.xml
index be4f737..e4065d3 100644
--- a/demoapps/passwordlogin/res/layout/login_layout.xml
+++ b/demoapps/passwordlogin/res/layout/login_layout.xml
@@ -1,136 +1,136 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout>
 
   <data>
 
     <import type="android.text.InputType" />
     <import type="android.view.View" />
 
     <variable
         name="viewmodel"
         type="org.openyolo.demoapp.passwordlogin.LoginViewModel" />
   </data>
 
   <android.support.design.widget.CoordinatorLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:id="@+id/contentFrame"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       tools:context=".LoginActivity">
 
     <LinearLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         xmlns:tools="http://schemas.android.com/tools"
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:padding="16dp">
 
       <ImageView
           android:layout_width="128dp"
           android:layout_height="128dp"
           android:layout_gravity="center"
           app:srcCompat="@drawable/openyolo_logo"
           android:contentDescription="@string/openyolo_logo_contentDescription" />
 
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           android:layout_marginTop="8dp"
           android:layout_marginBottom="16dp"
           android:textAppearance="@style/TextAppearance.AppCompat.Title"
           android:text="@string/login_header"/>
 
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:orientation="vertical"
-          android:visibility="@{viewmodel.loading ? View.VISIBLE : View.GONE}"
+          android:visibility="@{viewmodel.showLoading ? View.VISIBLE : View.GONE}"
           android:gravity="center">
 
         <ProgressBar
             style="@style/Base.Widget.AppCompat.ProgressBar"
             android:layout_width="64dp"
             android:layout_height="64dp"
             android:indeterminate="true"/>
 
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@{viewmodel.loadingLabel}"
             tools:text="Loading..."/>
 
       </LinearLayout>
 
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:paddingBottom="16dp"
           android:orientation="vertical"
-          android:visibility="@{viewmodel.loading ? View.GONE : View.VISIBLE}">
+          android:visibility="@{viewmodel.showLoading ? View.GONE : View.VISIBLE}">
 
         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center_horizontal"
             android:text="@{viewmodel.authPrompt}"
             android:layout_marginBottom="16dp"/>
 
         <android.support.design.widget.TextInputLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             app:errorEnabled="true"
             app:errorText="@{viewmodel.emailError}">
 
           <android.support.design.widget.TextInputEditText
               android:id="@+id/email"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:hint="@string/email_field_hint"
               android:inputType="textEmailAddress"
               android:text="@={viewmodel.email}"/>
 
         </android.support.design.widget.TextInputLayout>
 
         <android.support.design.widget.TextInputLayout
             android:id="@+id/password"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:visibility="@{viewmodel.showPasswordField ? View.VISIBLE : View.GONE}"
             app:passwordToggleEnabled="true"
             app:errorEnabled="true"
             app:errorText="@{viewmodel.passwordError}">
 
           <android.support.design.widget.TextInputEditText
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:text="@={viewmodel.password}"
               android:inputType="textPassword"
               android:hint="@string/password_field_hint" />
 
         </android.support.design.widget.TextInputLayout>
 
         <android.support.design.widget.FloatingActionButton
             android:layout_width="72dp"
             android:layout_height="72dp"
             android:layout_gravity="center"
             android:layout_margin="8dp"
             android:onClick="@{viewmodel::signInButtonClicked}"
             app:srcCompat="@drawable/ic_done" />
 
         <TextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="8dp"
             android:text="@string/error_prompt"
             android:textAlignment="center"
-            android:visibility="@{viewmodel.errorOccurred ? View.VISIBLE : View.GONE}"/>
+            android:visibility="@{viewmodel.showError ? View.VISIBLE : View.GONE}"/>
 
       </LinearLayout>
     </LinearLayout>
   </android.support.design.widget.CoordinatorLayout>
 
 </layout>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/values/strings.xml b/demoapps/passwordlogin/res/values/strings.xml
index 3ffb624..99a7e22 100644
--- a/demoapps/passwordlogin/res/values/strings.xml
+++ b/demoapps/passwordlogin/res/values/strings.xml
@@ -1,19 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
   <string name="app_name_short">OpenYOLO</string>
   <string name="email_field_hint">Email</string>
   <string name="password_field_hint">Password</string>
   <string name="login_header">OpenYOLO Demo - Password Login</string>
   <string name="sign_out_label">Sign out</string>
   <string name="openyolo_logo_contentDescription">OpenYOLO logo</string>
   <string name="enter_email_prompt">Enter your email address:</string>
   <string name="incorrect_stored_password">Incorrect stored password in credential provider. Please re-enter your password:</string>
   <string name="existing_account_enter_password">Welcome back! Please enter your password:</string>
   <string name="new_account_enter_password">Hey, you\'re new! Please choose a password for your account</string>
   <string name="error_prompt">Oops, that didn\'t work. Maybe try again?</string>
   <string name="signed_in_prompt">You are signed in as:</string>
   <string name="error_invalid_email">Invalid email address</string>
   <string name="error_password_too_short">Password is too short</string>
   <string name="error_incorrect_password">Wrong password, please try again</string>
   <string name="user_profile_picture">User profile picture</string>
+  <string name="existing_account_search_prompt">Looking for an existing account…</string>
+  <string name="requesting_hint_prompt">Asking your credential manager for account details…</string>
 </resources>

commit 50a16bff3d0820832def7be5520a354887a0306e
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Sat Aug 26 13:02:29 2017 -0700

    Added a representative demo app (#69)

diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 63dc7ef..3a6d783 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -6,477 +6,471 @@ Checkstyle-Configuration: Android Style
 Description: https://source.android.com/source/code-style.html
 -->
 <module name="Checker">
   <property name="fileExtensions" value="java, properties, xml"/>
 
   <!-- Require UTF-8 encoding for all files -->
   <property name="charset" value="UTF-8"/>
 
   <!-- Default severity is error -->
   <property name="severity" value="warning"/>
 
   <!-- Warnings can be suppressed by adding them to this file -->
   <module name="SuppressionFilter">
     <property name="file" value="${checkstyle.suppressions}"/>
   </module>
 
   <module name="TreeWalker">
 
     <!--#################################################################-->
     <!--################ NAMING CHECKS ##################################-->
     <!--#################################################################-->
 
     <!-- Require package names to be all lower-case -->
     <module name="PackageName">
         <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
         <message key="name.invalidPattern"
                  value="Package name ''{0}'' must be lower-case."/>
     </module>
 
     <!-- Require standard type names -->
     <module name="TypeName">
         <message key="name.invalidPattern"
          value="Type name ''{0}'' must begin with a capital letter."/>
     </module>
 
     <!--
     Type parameters must either be a single upper-case character, or must begin
     with an upper-case character and end with "T" (e.g. DataT).
     -->
     <module name="ClassTypeParameterName">
       <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
       <message key="name.invalidPattern"
                value="Class type parameter ''{0}'' must either be a single upper-case character, or begin with an upper-case character and end with 'T'."/>
     </module>
 
     <!-- Non-public, non-static members must start with "m" -->
     <module name="MemberName">
       <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
       <property name="applyToPublic" value="false"/>
       <message key="name.invalidPattern"
                value="Member name ''{0}'' must be prefixed with m and be at least two characters long."/>
     </module>
 
     <!--
     Require method names to be at least two characters long, and start with a
     lower case letter.
     -->
     <module name="MethodName">
       <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
       <message key="name.invalidPattern"
                value="Method name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!--
     Type parameters must either be a single upper-case character, or must begin
     with an upper-case character and end with "T" (e.g. DataT).
     -->
     <module name="MethodTypeParameterName">
       <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
       <message key="name.invalidPattern"
                value="Method type parameter ''{0}'' must either be a single upper-case character or begin with an upper-case character and end with 'T'."/>
     </module>
 
     <!-- Require parameter names to be at least two characters long -->
     <module name="ParameterName">
         <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
         <message key="name.invalidPattern"
                  value="Parameter name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!--
     Require local variables to be at least two characters long,
     unless they are counters on a for loop.
     -->
     <module name="LocalVariableName">
         <property name="tokens" value="VARIABLE_DEF"/>
         <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
         <property name="allowOneCharVarInForLoop" value="true"/>
         <message key="name.invalidPattern"
                  value="Local variable name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!-- Require that constants be capitalized. -->
     <module name="ConstantName"/>
 
     <module name="LocalFinalVariableName"/>
 
     <!--
     Require that static, non-public, non-final variable names be prefixed
     with "s".
     -->
     <module name="StaticVariableName">
       <property name="format" value="^s[A-Z][a-zA-Z0-9]*$"/>
       <message key="name.invalidPattern"
                value="Static variable name ''{0}'' must be prefixed with s and be at least two characters long."/>
     </module>
 
     <!-- Capitalized abbreviations are forbidden (e.g. URL, XML, HTTP) -->
     <module name="AbbreviationAsWordInName">
         <property name="ignoreFinal" value="false"/>
         <property name="allowedAbbreviationLength" value="1"/>
     </module>
 
     <!-- Forbid unnecessary escaping. -->
     <module name="IllegalTokenText">
       <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
       <property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
       <property name="message" value="Avoid using corresponding octal or Unicode escape."/>
     </module>
 
     <!-- Forbid unnecessary unicode escapes -->
     <module name="AvoidEscapedUnicodeCharacters">
         <property name="allowEscapesForControlCharacters" value="true"/>
         <property name="allowByTailComment" value="true"/>
         <property name="allowNonPrintableEscapes" value="true"/>
     </module>
 
     <!-- Require array notation on type (e.g. int[] x, not int x[]) -->
     <module name="ArrayTypeStyle"/>
 
     <!--###################################################-->
     <!--################ IMPORTS ##########################-->
     <!--###################################################-->
 
     <!-- Star imports are forbidden. -->
     <module name="AvoidStarImport"/>
 
     <!--
     Imports should be ordered such that static imports come before normal
     imports. Within these groups (separated by an empty line), imports should
     be lexicographially sorted with no further subcategorization required.
      -->
     <module name="CustomImportOrder">
         <property name="sortImportsInGroupAlphabetically" value="true"/>
         <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
     </module>
 
     <!-- Forbid imports from sun.* -->
     <module name="IllegalImport"/>
 
     <!-- Forbid redudant imports (e.g. import java.lang.String;) -->
     <module name="RedundantImport"/>
 
     <!-- Forbid unused imports -->
     <module name="UnusedImports"/>
 
     <!-- Forbid redundant modifiers -->
     <module name="RedundantModifier"/>
 
     <!--##############################################################-->
     <!--################ STRUCTURAL / WRAPPING CHECKS ################-->
     <!--##############################################################-->
 
     <!-- Require One top-level class per file -->
     <module name="OneTopLevelClass"/>
 
     <!-- Line-wrapping in import statements is forbidden. -->
     <module name="NoLineWrap"/>
 
     <!-- Empty catch blocks are forbidden. -->
     <module name="EmptyCatchBlock">
       <property name="exceptionVariableName" value="expected|ignore"/>
     </module>
 
     <!-- Require braces for all code blocks -->
     <module name="NeedBraces"/>
 
     <!-- Require One statement per line (e.g. no "a = b; c = d;") -->
     <module name="OneStatementPerLine"/>
 
     <!-- Multiple variable declarations on one line is forbidden. -->
     <module name="MultipleVariableDeclarations"/>
 
     <!-- Require switch statements to have default clause -->
     <module name="MissingSwitchDefault"/>
 
     <!--
     Case fall-through in switch statements is forbidden, except where an
     explicit "// fall-through" comment exists.
     -->
     <module name="FallThrough">
       <property name="reliefPattern" value="fall-through"/>
     </module>
 
     <!-- Require empty lines between definitions -->
     <module name="EmptyLineSeparator">
         <property name="allowNoEmptyLineBetweenFields" value="true"/>
     </module>
 
     <!-- Wrap only permitted before dot, e.g.
     fluentInterface.doX()
         .doY()
         .doZ();
     -->
     <module name="SeparatorWrap">
       <property name="tokens" value="DOT"/>
       <property name="option" value="nl"/>
     </module>
 
     <!-- Wrap only permitted after comma, e.g.
     doThings(withA,
         withB,
         withC);
     -->
     <module name="SeparatorWrap">
         <property name="tokens" value="COMMA"/>
         <property name="option" value="EOL"/>
     </module>
 
     <!-- require line breaks before common binary operators -->
     <module name="OperatorWrap">
         <property name="option" value="NL"/>
         <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
     </module>
 
     <!--
     Require that annotations on type, method and constructor definitions be on
     a separate line.
     -->
     <module name="AnnotationLocation">
       <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
     </module>
 
     <!--
     Variable declarations may have annotations on the same line.
     -->
     <module name="AnnotationLocation">
         <property name="tokens" value="VARIABLE_DEF"/>
         <property name="allowSamelineMultipleAnnotations" value="true"/>
     </module>
 
     <!-- Forbid empty statements -->
     <module name="EmptyStatement"/>
 
     <!--#################################################################-->
     <!--################ WHITESPACE / LINE LENGTH CHECKS ################-->
     <!--#################################################################-->
 
     <!-- Forbid whitespace after prefix unary operators and accessors -->
     <module name="NoWhitespaceAfter">
       <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
     </module>
 
     <!--
     Forbid whitespace before comma, semi-colon, and postfix unary operators
     -->
     <module name="NoWhitespaceBefore"/>
 
     <!-- Require whitespace around common tokens (=, if, etc.) -->
     <module name="WhitespaceAround">
       <property name="allowEmptyConstructors" value="true"/>
       <property name="allowEmptyMethods" value="true"/>
       <property name="allowEmptyTypes" value="true"/>
       <property name="allowEmptyLoops" value="true"/>
       <message key="ws.notFollowed"
        value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
        <message key="ws.notPreceded"
        value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
     </module>
 
     <!-- Require standard whitespace around type parameters -->
     <module name="GenericWhitespace">
       <message key="ws.followed"
                value="GenericWhitespace ''{0}'' is followed by whitespace."/>
        <message key="ws.preceded"
                 value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
        <message key="ws.illegalFollow"
                 value="GenericWhitespace ''{0}'' should followed by whitespace."/>
        <message key="ws.notPreceded"
                 value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
     </module>
 
     <!-- Require Android standard indentation. -->
     <module name="Indentation">
         <property name="basicOffset" value="4"/>
         <property name="braceAdjustment" value="0"/>
         <property name="caseIndent" value="4"/>
         <property name="throwsIndent" value="8"/>
         <property name="lineWrappingIndentation" value="8"/>
         <property name="arrayInitIndent" value="4"/>
     </module>
 
     <!--
     Require that comments be placed at the same level of indentation as
     surrounding code.
     -->
     <module name="CommentsIndentation"/>
 
     <!-- 100 char per line max, unless unavoidable -->
     <module name="LineLength">
       <property name="max" value="100"/>
       <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
     </module>
 
     <!--################################################-->
     <!--################ JAVADOC CHECKS ################-->
     <!--################################################-->
 
     <!--
     Require Javadoc for public methods:
     https://source.android.com/source/code-style.html#use-javadoc-standard-comments
     -->
     <module name="JavadocMethod">
       <property name="scope" value="public"/>
       <!-- exception: property methods (getX, setX, isX) -->
       <property name="allowMissingPropertyJavadoc" value="true"/>
       <!-- exception: method overrides, test methods -->
       <property name="allowedAnnotations" value="Override, Test, Before, After"/>
 
       <!--
       Every parameter need not be documented. This is to avoid the need for
       redundant descriptions between the main description and the parameter
       descriptions.
       -->
       <property name="allowMissingParamTags" value="true"/>
       <!--
       The return value need not be documented. This is to avoid the need for
       redundant descriptions between the main description and the return value
       descriptions.
       -->
       <property name="allowMissingReturnTag" value="true"/>
       <property name="allowThrowsTagsForSubclasses" value="true"/>
       <property name="suppressLoadErrors" value="true"/>
     </module>
 
     <!-- Javadoc required for public fields (part of API) -->
     <module name="JavadocVariable">
       <property name="scope" value="public"/>
     </module>
 
-    <!-- Javadoc must be well-formed -->
-    <module name="JavadocStyle"/>
-
     <!--
     Require descriptions for all included @param / @return / @throws /
     @deprecated tags in Javadoc comments.
     -->
     <module name="NonEmptyAtclauseDescription"/>
 
     <!--
     Require 4-character indentation of @param / @return / @throws / @deprecated
     descriptions which span more than one line.
     -->
     <module name="JavadocTagContinuationIndentation"/>
 
     <!--
     Forbid pointless Javadoc summary sentences.
     -->
     <module name="SummaryJavadocCheck">
       <property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
     </module>
 
-    <!-- Require correct use of whitespace and <p> tags for Javadoc comments -->
-    <module name="JavadocParagraph"/>
-
     <!-- Require correct order of Javadoc comment tags -->
     <module name="AtclauseOrder">
         <property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
         <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
     </module>
 
     <!-- Single line Javadoc comments with a tag are forbidden. -->
     <module name="SingleLineJavadoc">
       <property name="ignoreInlineTags" value="false"/>
     </module>
 
     <!--
     Require @deprecated Javadoc tag and @Deprecated annotation to be used
     together.
     -->
     <module name="MissingDeprecated"/>
 
     <!--#################################################################-->
     <!--################ MISC. LANGUAGE CHECKS ##########################-->
     <!--#################################################################-->
 
     <!-- File name must correspond to contained class -->
     <module name="OuterTypeFilename"/>
 
     <!--
     Long constants must be suffixed with L:
     "The suffix L is preferred, because the letter l (ell) is often hard to
     distinguish from the digit 1 (one)."
     http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.1
     -->
     <module name="UpperEll"/>
 
     <!--
     Require modifier order consistent with recommends in JLS:
     http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html
     -->
     <module name="ModifierOrder"/>
 
     <!-- Finalizers are forbidden. -->
     <module name="NoFinalizer"/>
 
     <!-- overloaded methods must be grouped together -->
     <module name="OverloadMethodsDeclarationOrder"/>
 
     <!-- Require variables to be declared close to where they are used -->
     <module name="VariableDeclarationUsageDistance"/>
 
     <!-- Require that equals() and hashCode() are overridden together -->
     <module name="EqualsHashCode"/>
 
     <!-- Forbid shadowing fields or variables -->
     <module name="HiddenField">
       <!-- exception: constructor parameters -->
       <property name="ignoreConstructorParameter" value="true"/>
       <!-- exception: setter method parameters -->
       <property name="ignoreSetter" value="true"/>
     </module>
 
     <!--
     Forbid assignments in expressions, with the exception of loop conditions
     -->
     <module name="InnerAssignment"/>
 
     <!-- Require @Override on overridden methods -->
     <module name="MissingOverride"/>
 
     <!-- Forbid arbitrarily nested blocks -->
     <module name="AvoidNestedBlocks"/>
 
     <!-- Forbid the use of arbitrary numeric literals -->
     <module name="MagicNumber"/>
 
     <!-- Require boolean expressions to be simplifed -->
     <module name="SimplifyBooleanExpression"/>
 
     <!-- Require boolean returns to be simplified -->
     <module name="SimplifyBooleanReturn"/>
 
     <!-- Forbid interfaces with no methods -->
     <module name="InterfaceIsType"/>
 
   </module>
 
   <!--################################################-->
   <!--################ Non-AST checks ################-->
   <!--################################################-->
 
   <!-- Ensure the copyright header appears in every java source file -->
   <module name="RegexpHeader">
     <property name="headerFile" value="${checkstyle.java.header}"/>
     <property name="fileExtensions" value="java"/>
   </module>
 
   <!-- Report every line containing a tab character" -->
   <module name="FileTabCharacter">
     <property name="eachLine" value="true"/>
   </module>
 
   <!-- Forbid trailing whitespace -->
   <module name="RegexpSingleline">
     <property name="format" value="\s+$"/>
     <property name="message" value="Line has trailing whitespace."/>
   </module>
 
   <!-- require Javadoc for all packages -->
   <module name="JavadocPackage"/>
 
   <!-- Require a new line at the end of all files -->
   <module name="NewlineAtEndOfFile">
     <property name="lineSeparator" value="lf"/>
   </module>
 </module>
diff --git a/demoapps/passwordlogin/AndroidManifest.xml b/demoapps/passwordlogin/AndroidManifest.xml
new file mode 100644
index 0000000..9e0dfcf
--- /dev/null
+++ b/demoapps/passwordlogin/AndroidManifest.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="org.openyolo.demoapp.passwordlogin">
+
+    <uses-permission android:name="android.permission.INTERNET" />
+
+    <application
+        android:allowBackup="false"
+        android:fullBackupContent="false"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name_short"
+        android:supportsRtl="false"
+        android:theme="@style/AppTheme"
+        android:name="org.openyolo.demoapp.passwordlogin.OpenYoloDemoApplication">
+
+        <activity
+            android:name="org.openyolo.demoapp.passwordlogin.MainActivity"
+            android:theme="@style/AppTheme"
+            android:label="@string/app_name_short"
+            android:windowSoftInputMode="stateHidden"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <data
+                    android:host="barbican.openyolo.org"
+                    android:scheme="https" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name="org.openyolo.demoapp.passwordlogin.LoginActivity"
+            android:theme="@style/AppTheme"
+            android:windowSoftInputMode="adjustResize|stateVisible"
+            android:exported="false" />
+    </application>
+</manifest>
diff --git a/demoapps/passwordlogin/build.gradle b/demoapps/passwordlogin/build.gradle
new file mode 100644
index 0000000..deef4b8
--- /dev/null
+++ b/demoapps/passwordlogin/build.gradle
@@ -0,0 +1,49 @@
+apply plugin: 'com.android.application'
+apply plugin: 'checkstyle'
+
+apply from: "${rootDir}/config/android-common.gradle"
+
+android {
+    defaultConfig {
+        applicationId 'org.openyolo.demoapp.passwordonly'
+        project.archivesBaseName = 'openyolo-demoapp-passwordonly'
+        vectorDrawables.useSupportLibrary = true
+    }
+
+    dataBinding {
+        enabled = true
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+    }
+    compileOptions {
+        targetCompatibility 1.8
+        sourceCompatibility 1.8
+    }
+}
+
+dependencies {
+    implementation project(':api')
+    implementation "android.arch.lifecycle:runtime:${rootProject.archVersion}"
+    implementation "android.arch.lifecycle:extensions:${rootProject.archVersion}"
+    implementation "android.arch.persistence.room:runtime:${rootProject.archVersion}"
+    implementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    implementation "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    implementation "com.android.support:design:${rootProject.supportLibVersion}"
+
+    implementation "com.github.bumptech.glide:glide:${rootProject.glideVersion}"
+
+    annotationProcessor "android.arch.lifecycle:compiler:${rootProject.archVersion}"
+    annotationProcessor "android.arch.persistence.room:compiler:${rootProject.archVersion}"
+    annotationProcessor "com.github.bumptech.glide:compiler:${rootProject.glideVersion}"
+
+    apply from: "${rootDir}/config/testdeps.gradle", to:it
+    testImplementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+}
+
+apply from: "${rootDir}/config/style.gradle"
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java
new file mode 100644
index 0000000..b32ed7e
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/DataBindingAdapters.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.databinding.BindingAdapter;
+import android.support.design.widget.TextInputLayout;
+import android.widget.ImageView;
+
+/**
+ * Android data binding extensions which make facilitate binding to more advanced field types.
+ */
+public final class DataBindingAdapters {
+
+    private DataBindingAdapters() {}
+
+    /**
+     * Facilitates loading images into an ImageView using Glide, by binding a string URI.
+     */
+    @BindingAdapter("android:src")
+    public static void setImageUri(ImageView view, String imageUri) {
+        GlideApp.with(view)
+                .load(imageUri)
+                .fitCenter()
+                .into(view);
+    }
+
+    /**
+     * Facilitates binding error text to a TextInputLayout.
+     */
+    @BindingAdapter("errorText")
+    public static void setErrorText(TextInputLayout layout, String errorText) {
+        layout.setError(errorText);
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/GlideModule.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/GlideModule.java
new file mode 100644
index 0000000..ac8bb88
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/GlideModule.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import com.bumptech.glide.module.AppGlideModule;
+
+/**
+ * Required definition for use of the Glide generated API.
+ * @see "http://bumptech.github.io/glide/doc/generatedapi.html"
+ */
+@com.bumptech.glide.annotation.GlideModule
+public final class GlideModule extends AppGlideModule {}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginActivity.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginActivity.java
new file mode 100644
index 0000000..4ad4e4d
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginActivity.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.arch.lifecycle.ViewModelProviders;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.AnyThread;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import java.util.concurrent.ScheduledExecutorService;
+import org.openyolo.demoapp.passwordlogin.databinding.LoginLayoutBinding;
+
+public final class LoginActivity extends AppCompatActivity implements LoginNavigator {
+
+    private static final String TAG = "LoginActivity";
+
+    private static final int RC_RETRIEVE = 100;
+    private static final int RC_HINT = 101;
+    private static final int RC_SAVE = 102;
+
+    private LoginViewModel mViewModel;
+    private LoginLayoutBinding mViewDataBinding;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.login_layout);
+
+        if (mViewDataBinding == null) {
+            mViewDataBinding = LoginLayoutBinding.bind(findViewById(R.id.contentFrame));
+        }
+
+        mViewModel = ViewModelProviders.of(this).get(LoginViewModel.class);
+        mViewModel.setNavigator(this);
+        mViewDataBinding.setViewmodel(mViewModel);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        getExecutorService().execute(mViewModel::start);
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        switch (requestCode) {
+            case RC_RETRIEVE:
+                getExecutorService().execute(() -> mViewModel.handleRetrieveResult(data));
+                break;
+            case RC_HINT:
+                getExecutorService().execute(() -> mViewModel.handleHintResult(data));
+                break;
+            case RC_SAVE:
+                getExecutorService().execute(() -> mViewModel.handleSaveResult(data));
+                break;
+            default:
+                Log.w(TAG, "Unexpected request code, ignoring");
+        }
+    }
+
+    @AnyThread
+    @Override
+    public void startOpenYoloRetrieve(Intent retrieveIntent) {
+        runOnUiThread(() -> startActivityForResult(retrieveIntent, RC_RETRIEVE));
+    }
+
+    @AnyThread
+    @Override
+    public void startOpenYoloHint(Intent hintIntent) {
+        runOnUiThread(() -> startActivityForResult(hintIntent, RC_HINT));
+    }
+
+    @AnyThread
+    @Override
+    public void startSave(Intent saveIntent) {
+        runOnUiThread(() -> startActivityForResult(saveIntent, RC_SAVE));
+    }
+
+    @AnyThread
+    @Override
+    public void goToMain() {
+        runOnUiThread(() -> {
+            startActivity(new Intent(this, MainActivity.class));
+            finish();
+        });
+    }
+
+    @AnyThread
+    private ScheduledExecutorService getExecutorService() {
+        return ((OpenYoloDemoApplication) getApplication()).getExecutor();
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginNavigator.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginNavigator.java
new file mode 100644
index 0000000..7e72f72
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginNavigator.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.content.Intent;
+import android.support.annotation.AnyThread;
+
+/**
+ * Hides the details of activity transitions from {@link LoginViewModel}.
+ */
+@AnyThread
+public interface LoginNavigator {
+
+    /**
+     * Requests the retrieval of a credential from an OpenYOLO provider using the supplied intent.
+     */
+    void startOpenYoloRetrieve(Intent retrieveIntent);
+
+    /**
+     * Requests the retrieval of a hint from an OpenYOLO provider using the supplied intent.
+     */
+    void startOpenYoloHint(Intent hintIntent);
+
+    /**
+     * Requests the storage of a credential to an OpenYOLO provider using the supplied intent.
+     */
+    void startSave(Intent saveIntent);
+
+    /**
+     * Transitions to the main activity.
+     */
+    void goToMain();
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
new file mode 100644
index 0000000..f111ba5
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/LoginViewModel.java
@@ -0,0 +1,513 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.annotation.SuppressLint;
+import android.app.Application;
+import android.content.Intent;
+import android.databinding.ObservableBoolean;
+import android.databinding.ObservableField;
+import android.net.Uri;
+import android.support.annotation.AnyThread;
+import android.support.annotation.Keep;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.annotation.WorkerThread;
+import android.util.Log;
+import android.util.Patterns;
+import android.view.View;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.demoapp.passwordlogin.userdata.HashUtil;
+import org.openyolo.demoapp.passwordlogin.userdata.UserDataSource;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.CredentialSaveRequest;
+import org.openyolo.protocol.CredentialSaveResult;
+import org.openyolo.protocol.Hint;
+import org.openyolo.protocol.HintRetrieveRequest;
+import org.openyolo.protocol.HintRetrieveResult;
+import org.openyolo.protocol.RetrieveBbqResponse;
+
+/**
+ * The view model for {@link LoginActivity}. Defines all the logic for authenticating a user
+ * which an email address and password, including interacting with any available OpenYOLO provider
+ * to directly retrieve or generate credentials.
+ */
+@WorkerThread
+public final class LoginViewModel extends ObservableViewModel {
+
+    private static final String TAG = "LoginViewModel";
+
+    private static final int MIN_PASSWORD_LENGTH = 4;
+
+    /**
+     * Indicates whether a progress bar should be displayed to the user, while an asynchronous
+     * request is made.
+     */
+    public final ObservableBoolean loading = new ObservableBoolean(true);
+
+    /**
+     * Describes the asynchronous request that is occurring to the user.
+     */
+    public final ObservableField<String> loadingLabel = new ObservableField<>("Loading…");
+
+    /**
+     * The prompt that is displayed to the user for manual authentication, instructing them what
+     * to do next.
+     */
+    public final ObservableField<String> authPrompt = new ObservableField<>("");
+
+    /**
+     * The email address the user has entered, or that was retrieved from their OpenYOLO provider.
+     */
+    public final ObservableField<String> email = new ObservableField<>("");
+
+    /**
+     * The error string displayed below the email text input element. If the string is empty,
+     * the error is not displayed.
+     */
+    public final ObservableField<String> emailError = new ObservableField<>("");
+
+    /**
+     * Whether the password entry field should be displayed at this time.
+     */
+    public final ObservableBoolean showPasswordField = new ObservableBoolean(false);
+
+    /**
+     * The password the user has entered.
+     */
+    public final ObservableField<String> password = new ObservableField<>("");
+
+    /**
+     * The error string displayed below the password text input element. If the string is empty,
+     * the error is not displayed.
+     */
+    public final ObservableField<String> passwordError = new ObservableField<>("");
+
+    /**
+     * Whether to show a generic error message to the user - this happens when requests fail
+     * in a way that we cannot recover from, other than asking the user to potentially try again.
+     */
+    public final ObservableBoolean errorOccurred = new ObservableBoolean(false);
+
+    @SuppressLint("StaticFieldLeak")
+    private final OpenYoloDemoApplication mApplication;
+    private final CredentialClient mCredentialClient;
+    private final UserDataSource mUserDataSource;
+
+    private LoginNavigator mNavigator;
+    private AtomicBoolean mFirstLoad = new AtomicBoolean(true);
+
+    /**
+     * Creates the view model, with the required application reference.
+     */
+    @Keep
+    public LoginViewModel(Application application) {
+        super(application);
+        mApplication = OpenYoloDemoApplication.getInstance(application);
+        mUserDataSource = mApplication.getUserRepository();
+        mCredentialClient = CredentialClient.getApplicationBoundInstance(application);
+    }
+
+    /**
+     * Specifies the navigator instance used by the view model to interact with the
+     * activity environment.
+     */
+    @MainThread
+    void setNavigator(LoginNavigator navigator) {
+        mNavigator = navigator;
+    }
+
+    /**
+     * The main entry point. If the model has not been previously started, it will attempt to
+     * authenticate the user with the help of OpenYOLO, and if this fails, facilitate manual
+     * authentication attempts until success.
+     */
+    void start() {
+        if (!mFirstLoad.compareAndSet(true, false)) {
+            // already started
+            return;
+        }
+
+        if (mUserDataSource.getCurrentUser() != null) {
+            // already signed in, go straight to the main activity
+            mNavigator.goToMain();
+            return;
+        }
+
+        tryRetrieveExistingCredential();
+    }
+
+    /**
+     * Initiates an OpenYOLO credential retrieval request, and forwards the response to
+     * {@link #handleRetrieveQueryResult(RetrieveBbqResponse, Throwable)} for processing.
+     */
+    private void tryRetrieveExistingCredential() {
+        setLoading("Looking for an existing account…");
+        mCredentialClient.retrieve(
+                CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL),
+                (queryResponse, queryError) ->
+                    getExecutor().execute(
+                            () -> handleRetrieveQueryResult(queryResponse, queryError)));
+    }
+
+    /**
+     * Inspects the initial response from the OpenYOLO retrieve request. If a retrieve intent
+     * is available, this is used to attempt to source a credential from the provider. The result
+     * of this is indirectly routed to {@link #handleRetrieveResult(Intent)}.
+     *
+     * If no intent is returned, an attempt is made to source an account hint instead.
+     */
+    private void handleRetrieveQueryResult(
+            RetrieveBbqResponse queryResponse,
+            Throwable queryError) {
+        if (queryResponse != null && queryResponse.getRetrieveIntent() != null) {
+            Log.i(TAG, "retrieving credential from provider");
+            mNavigator.startOpenYoloRetrieve(queryResponse.getRetrieveIntent());
+            return;
+        }
+
+        Log.i(TAG, "no OpenYOLO providers for retrieve");
+        tryRetrieveHint();
+    }
+
+    /**
+     * Invoked by {@link LoginActivity} when an OpenYOLO provider completes its processing of
+     * the credential retrieve request, potentially with user input.
+     *
+     * If a credential is returned, an authentication attempt is made using it. If this fails, the
+     * user is prompted to manually authenticate.
+     *
+     * If no credential is returned, an attempt is made to source an account hint instead.
+     */
+    public void handleRetrieveResult(Intent data) {
+        CredentialRetrieveResult result = mCredentialClient.getCredentialRetrieveResult(data);
+
+        switch (result.getResultCode()) {
+            case CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED:
+                Log.i(TAG, "Credential was returned by OpenYOLO provider");
+                Credential credential = result.getCredential();
+                if (mUserDataSource.authWithPassword(
+                        credential.getIdentifier(),
+                        credential.getPassword())) {
+                    // save the credential back to the provider, as a signal that it still works.
+                    trySaveCredential(credential);
+                } else {
+                    doManualAuthentication(
+                            R.string.incorrect_stored_password,
+                            credential.getIdentifier());
+                }
+                return;
+
+            // you may wish to behave differently in your own application in response to each of
+            // the following cases (which are enumerated here to demonstrate the possible
+            // responses), but for simplicity in this demo app we treat them all as requiring
+            // manual authentication by the user
+            case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
+                Log.i(TAG, "Provider indicated that no credentials are available");
+                break;
+            case CredentialRetrieveResult.CODE_USER_CANCELED:
+                Log.i(TAG, "The user canceled selection of an existing credential");
+                break;
+            case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
+                Log.i(TAG, "The user requests manual authentication");
+                break;
+            case CredentialRetrieveResult.CODE_BAD_REQUEST:
+                Log.i(TAG, "Provider indicated that the request was malformed");
+                break;
+            case CredentialRetrieveResult.CODE_UNKNOWN:
+            default:
+                Log.i(TAG, "An unknown error occurred in the credential retrieval flow");
+                break;
+        }
+
+        doManualAuthentication(
+                R.string.enter_email_prompt,
+                null);
+    }
+
+    /**
+     * Attempts to retrieve an account hint from the OpenYOLO provider. Hint responses are
+     * indirectly routed to {@link #handleHintResult(Intent)}. If no hint provider is
+     * available, then the user is prompted to manually authenticate.
+     */
+    private void tryRetrieveHint() {
+        Intent hintIntent = mCredentialClient.getHintRetrieveIntent(
+                HintRetrieveRequest.forEmailAndPasswordAccount());
+
+        if (hintIntent != null) {
+            setLoading("Asking your credential manager for account details…");
+            mNavigator.startOpenYoloHint(hintIntent);
+            return;
+        }
+
+        Log.i(TAG, "No OpenYOLO providers for hint");
+        doManualAuthentication(
+                R.string.enter_email_prompt,
+                null);
+    }
+
+    /**
+     * Handles the hint retrieval result from the OpenYOLO provider. If a hint is returned, a
+     * check is made to determine whether an account already exists for the returned identifier.
+     * If it is, the user is prompted to enter their password for that account. Otherwise, an
+     * account is automatically created using the returned hint details.
+     *
+     * If no hint is returned, the user is prompted to manually authenticate.
+     */
+    public void handleHintResult(Intent data) {
+        HintRetrieveResult result = mCredentialClient.getHintRetrieveResult(data);
+
+        switch (result.getResultCode()) {
+            case HintRetrieveResult.CODE_HINT_SELECTED:
+                Log.i(TAG, "User selected a hint from the OpenYOLO provider");
+                Hint hint = result.getHint();
+
+                if (mUserDataSource.isExistingAccount(hint.getIdentifier())) {
+                    doManualAuthentication(
+                            R.string.existing_account_enter_password,
+                            hint.getIdentifier());
+                    return;
+                }
+
+                String hintEmail = hint.getIdentifier();
+                String displayName = normalizeDisplayName(hint.getDisplayName());
+                String displayPicture = normalizeDisplayPictureUri(
+                        hint.getIdentifier(),
+                        hint.getDisplayPictureUri());
+                String hintPassword = hint.getGeneratedPassword();
+
+                // attempt to create an account with the returned hint. If this fails, ask the
+                // user to manually authenticate.
+                if (hintPassword != null && mUserDataSource.createPasswordAccount(
+                        hintEmail, displayName, displayPicture, hintPassword)) {
+                    // account created, attempt to save it back to the OpenYOLO provider
+                    trySaveCredential(
+                            new Credential.Builder(
+                                    hintEmail,
+                                    AuthenticationMethods.EMAIL,
+                                    AuthenticationDomain.getSelfAuthDomain(mApplication))
+                                    .setDisplayName(displayName)
+                                    .setDisplayPicture(displayPicture)
+                                    .setPassword(hintPassword)
+                                    .build());
+                } else {
+                    doManualAuthentication(
+                            R.string.new_account_enter_password,
+                            hint.getIdentifier());
+                }
+                return;
+
+            // you may wish to behave differently in your own application in response to each of
+            // the following cases (which are enumerated here to demonstrate the possible
+            // responses), but for simplicity in this demo app we treat them all as requiring
+            // manual authentication by the user
+            case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
+                Log.i(TAG, "Provider indicated there are no hints available");
+                break;
+            case HintRetrieveResult.CODE_USER_CANCELED:
+                Log.i(TAG, "User canceled the hint selection flow");
+                break;
+            case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
+                Log.i(TAG, "User requests manual authentication");
+                break;
+            case HintRetrieveResult.CODE_BAD_REQUEST:
+                Log.i(TAG, "Proivder indicates that the request was malformed");
+                break;
+            case HintRetrieveResult.CODE_UNKNOWN:
+            default:
+                Log.i(TAG, "An unknown error occurred in the hint retrieval flow");
+                break;
+        }
+
+        doManualAuthentication(
+                R.string.enter_email_prompt,
+                null);
+    }
+
+    /**
+     * Prompts the user to manually authenticate, with a context-specific message.
+     */
+    private void doManualAuthentication(
+            @StringRes int authPromptId,
+            @Nullable String userEmail) {
+        this.authPrompt.set(getResourceString(authPromptId));
+        this.email.set(userEmail != null ? userEmail : "");
+        this.showPasswordField.set(userEmail != null);
+        this.password.set("");
+        setLoaded();
+    }
+
+    /**
+     * Pushes handling of a sign in button click on the form to a background thread for processing.
+     */
+    @MainThread
+    public void signInButtonClicked(View view) {
+        getExecutor().execute(this::tryManualAuthentication);
+    }
+
+    /**
+     * Processes an attempt to manually authenticate.
+     */
+    private void tryManualAuthentication() {
+        String userEmail = this.email.get().trim();
+        String userPassword = this.password.get();
+
+        if (!Patterns.EMAIL_ADDRESS.matcher(userEmail).matches()) {
+            emailError.set(getResourceString(R.string.error_invalid_email));
+            return;
+        } else {
+            emailError.set("");
+        }
+
+        if (userPassword.length() < MIN_PASSWORD_LENGTH) {
+            passwordError.set(getResourceString(R.string.error_password_too_short));
+            return;
+        } else {
+            emailError.set("");
+        }
+
+        if (mUserDataSource.isExistingAccount(userEmail)) {
+            if (userPassword.isEmpty()) {
+                authPrompt.set(getResourceString(R.string.existing_account_enter_password));
+                showPasswordField.set(true);
+            } else if (mUserDataSource.authWithPassword(userEmail, userPassword)) {
+                trySaveCredential(
+                        new Credential.Builder(
+                                userEmail,
+                                AuthenticationMethods.EMAIL,
+                                AuthenticationDomain.getSelfAuthDomain(mApplication))
+                                .setPassword(userPassword)
+                                .build());
+            } else {
+                passwordError.set(getResourceString(R.string.error_incorrect_password));
+            }
+        } else {
+            if (userPassword.isEmpty()) {
+                authPrompt.set(getResourceString(R.string.new_account_enter_password));
+                showPasswordField.set(true);
+            } else if (mUserDataSource.createPasswordAccount(
+                    userEmail,
+                    null,
+                    null,
+                    userPassword)) {
+                trySaveCredential(
+                        new Credential.Builder(
+                                userEmail,
+                                AuthenticationMethods.EMAIL,
+                                AuthenticationDomain.getSelfAuthDomain(mApplication))
+                                .setPassword(userPassword)
+                                .build());
+            } else {
+                errorOccurred.set(true);
+            }
+        }
+    }
+
+    private void trySaveCredential(Credential credential) {
+        Intent saveIntent =
+                mCredentialClient.getSaveIntent(CredentialSaveRequest.fromCredential(credential));
+
+        if (saveIntent != null) {
+            Log.i(TAG, "Attempting to save credential to OpenYOLO provider");
+            mNavigator.startSave(saveIntent);
+            return;
+        }
+
+        Log.i(TAG, "No OpenYOLO providers to save credential");
+        mNavigator.goToMain();
+    }
+
+    /**
+     * Handles the credential save result from the OpenYOLO provider, returned via
+     * {@link LoginActivity}.
+     */
+    public void handleSaveResult(Intent data) {
+        CredentialSaveResult result = mCredentialClient.getCredentialSaveResult(data);
+
+        // you may wish to handle the outcomes of save differently in your own application; for this
+        // demo, the outcome of the save request is mostly irrelevant.
+        switch (result.getResultCode()) {
+            case CredentialSaveResult.CODE_SAVED:
+                Log.i(TAG, "User saved credential");
+                break;
+            case CredentialSaveResult.CODE_USER_CANCELED:
+                Log.i(TAG, "User canceled credential save");
+                break;
+            case CredentialSaveResult.CODE_USER_REFUSED:
+                Log.i(TAG, "User refused to save credential");
+                break;
+            case CredentialSaveResult.CODE_PROVIDER_REFUSED:
+                Log.i(TAG, "Provider refused to save credential");
+                break;
+            case CredentialSaveResult.CODE_BAD_REQUEST:
+                Log.i(TAG, "Provider indicated the save request was malformed");
+                break;
+            case CredentialSaveResult.CODE_UNKNOWN:
+            default:
+                Log.i(TAG, "An unknown error occurred while saving the credential");
+                break;
+        }
+
+        mNavigator.goToMain();
+    }
+
+    private void setLoading(@StringRes int loadingLabelId) {
+        setLoading(getApplication().getResources().getString(loadingLabelId));
+    }
+
+    private void setLoading(String reason) {
+        this.loadingLabel.set(reason);
+        loading.set(true);
+    }
+
+    private void setLoaded() {
+        loadingLabel.set("");
+        loading.set(false);
+    }
+
+    @AnyThread
+    private String getResourceString(@StringRes int stringId, Object... formatArgs) {
+        return getApplication().getResources().getString(stringId, formatArgs);
+    }
+
+    @AnyThread
+    private ScheduledExecutorService getExecutor() {
+        return ((OpenYoloDemoApplication)getApplication()).getExecutor();
+    }
+
+    @NonNull
+    private String normalizeDisplayName(@Nullable String displayName) {
+        return displayName != null ? displayName : "J Doe";
+    }
+
+    @NonNull
+    private String normalizeDisplayPictureUri(
+            @NonNull String userEmail,
+            @Nullable Uri displayPictureUri) {
+        if (displayPictureUri != null) {
+            return displayPictureUri.toString();
+        }
+
+        return "https://robohash.org/" + HashUtil.base64Hash(userEmail) + "?set=set3";
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainActivity.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainActivity.java
new file mode 100644
index 0000000..c41f0a5
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainActivity.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.arch.lifecycle.ViewModelProviders;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.AnyThread;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import java.util.concurrent.ScheduledExecutorService;
+import org.openyolo.demoapp.passwordlogin.databinding.MainLayoutBinding;
+
+public final class MainActivity extends AppCompatActivity implements MainNavigator {
+
+    private MainLayoutBinding mViewDataBinding;
+    private MainViewModel mViewModel;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main_layout);
+
+        if (mViewDataBinding == null) {
+            mViewDataBinding = MainLayoutBinding.bind(findViewById(R.id.contentFrame));
+        }
+
+        mViewModel = ViewModelProviders.of(this).get(MainViewModel.class);
+        mViewModel.setNavigator(this);
+        mViewDataBinding.setViewmodel(mViewModel);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        getExecutorService().execute(mViewModel::start);
+    }
+
+    @AnyThread
+    @Override
+    public void goToLogin() {
+        runOnUiThread(() -> {
+            startActivity(new Intent(this, LoginActivity.class));
+            finish();
+        });
+    }
+
+    @AnyThread
+    private ScheduledExecutorService getExecutorService() {
+        return ((OpenYoloDemoApplication) getApplication()).getExecutor();
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainNavigator.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainNavigator.java
new file mode 100644
index 0000000..6a1c444
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainNavigator.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+/**
+ * Hides the details of activity transitions from {@link MainViewModel}.
+ */
+public interface MainNavigator {
+
+    /**
+     * Transitions to the login activity.
+     */
+    void goToLogin();
+
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
new file mode 100644
index 0000000..f05b3db
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/MainViewModel.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.app.Application;
+import android.databinding.ObservableField;
+import android.support.annotation.AnyThread;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.WorkerThread;
+import android.view.View;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.openyolo.demoapp.passwordlogin.userdata.User;
+import org.openyolo.demoapp.passwordlogin.userdata.UserDataSource;
+
+/**
+ * The view model for the main activity, which is displayed when the user has authenticated
+ * successfully.
+ */
+@WorkerThread
+public final class MainViewModel extends ObservableViewModel {
+
+    /**
+     * The user's display name for display on screen, if known.
+     */
+    public final ObservableField<String> displayName = new ObservableField<>("");
+
+    /**
+     * The user's email address for display on screen.
+     */
+    public final ObservableField<String> email = new ObservableField<>("");
+
+    /**
+     * The user's display picture for display on screen, if known.
+     */
+    public final ObservableField<String> displayPicture = new ObservableField<>("");
+
+    private final AtomicBoolean mFirstLoad = new AtomicBoolean(true);
+    private final UserDataSource mUserDataSource;
+    private MainNavigator mNavigator;
+
+    /**
+     * Creates the view model, with the required application reference.
+     */
+    public MainViewModel(@NonNull Application application) {
+        super(application);
+        mUserDataSource = ((OpenYoloDemoApplication)application).getUserRepository();
+    }
+
+    /**
+     * Specifies the navigator for use in communicating with the activity environment.
+     */
+    @MainThread
+    public void setNavigator(@NonNull MainNavigator navigator) {
+        mNavigator = navigator;
+    }
+
+    /**
+     * The entry point to the view model's behavior. Determines whether a user is currently
+     * authenticated, and if not, redirects to the login activity. Otherwise, the currently
+     * authenticated user is displayed on screen.
+     */
+    public void start() {
+        if (!mFirstLoad.compareAndSet(true, false)) {
+            // already started
+            return;
+        }
+
+        User currentUser = mUserDataSource.getCurrentUser();
+        if (currentUser == null) {
+            // no user available, go to login screen
+            mNavigator.goToLogin();
+            return;
+        }
+
+        this.email.set(currentUser.getEmail());
+        this.displayName.set(currentUser.getName());
+        this.displayPicture.set(currentUser.getProfilePictureUri());
+    }
+
+    /**
+     * Delegates handling of sign-out to a background thread, which de-authenticates the current
+     * user and redirects to the login activity.
+     */
+    @MainThread
+    public void onSignOutClicked(View view) {
+        getExecutor().execute(() -> {
+            mUserDataSource.signOut();
+            mNavigator.goToLogin();
+        });
+    }
+
+    @AnyThread
+    private ScheduledExecutorService getExecutor() {
+        return OpenYoloDemoApplication.getInstance(getApplication()).getExecutor();
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/ObservableViewModel.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/ObservableViewModel.java
new file mode 100644
index 0000000..ca95905
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/ObservableViewModel.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.app.Application;
+import android.arch.lifecycle.AndroidViewModel;
+import android.databinding.Observable;
+import android.databinding.PropertyChangeRegistry;
+import android.support.annotation.NonNull;
+
+/**
+ * A base class for use by view models that utilize Android data binding.
+ */
+public abstract class ObservableViewModel extends AndroidViewModel implements Observable {
+
+    private final PropertyChangeRegistry mRegistry = new PropertyChangeRegistry();
+
+    /**
+     * Creates the view model, with the required application reference.
+     */
+    public ObservableViewModel(@NonNull Application application) {
+        super(application);
+    }
+
+    @Override
+    public void addOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) {
+        mRegistry.add(callback);
+    }
+
+    @Override
+    public void removeOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) {
+        mRegistry.remove(callback);
+    }
+
+    /**
+     * Notify listeners that the view model has changed.
+     */
+    public void notifyChange() {
+        mRegistry.notifyCallbacks(this, 0, null);
+    }
+
+    /**
+     * Notify listeners that a specific property in the view model has changed.
+     */
+    public void notifyPropertyChanged(int fieldId) {
+        mRegistry.notifyCallbacks(this, fieldId, null);
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/OpenYoloDemoApplication.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/OpenYoloDemoApplication.java
new file mode 100644
index 0000000..34c6843
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/OpenYoloDemoApplication.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin;
+
+import android.app.Application;
+import android.support.annotation.AnyThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.WorkerThread;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import org.openyolo.demoapp.passwordlogin.userdata.UserRepository;
+
+/**
+ * Application instance that holds global state. This is essentially a service locator, to avoid
+ * the complexity of adding dependency injection to the demo.
+ */
+public final class OpenYoloDemoApplication extends Application {
+
+    private final ScheduledExecutorService mExecutorService;
+    private UserRepository mUserRepository;
+
+    /**
+     * Convenience method for converting a raw Application instance to the appropriate type.
+     */
+    @NonNull
+    public static OpenYoloDemoApplication getInstance(@NonNull Application application) {
+        return (OpenYoloDemoApplication) application;
+    }
+
+    /**
+     * Creates and initializes the necessary global components of the application.
+     */
+    public OpenYoloDemoApplication() {
+        mExecutorService = Executors.newScheduledThreadPool(1);
+    }
+
+    /**
+     * An application-wide shared executor for background processing.
+     */
+    @AnyThread
+    public ScheduledExecutorService getExecutor() {
+        return mExecutorService;
+    }
+
+    /**
+     * An interface to user account state and authentication related operations.
+     */
+    @WorkerThread
+    public synchronized UserRepository getUserRepository() {
+        if (mUserRepository == null) {
+            mUserRepository = new UserRepository(this);
+        }
+        return mUserRepository;
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/package-info.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/package-info.java
new file mode 100644
index 0000000..9b47146
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Demonstrates the usage of OpenYOLO to facilitate sign-in and sign-up using passwords.
+ */
+package org.openyolo.demoapp.passwordlogin;
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/HashUtil.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/HashUtil.java
new file mode 100644
index 0000000..062b91f
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/HashUtil.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin.userdata;
+
+import android.util.Base64;
+import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+/**
+ * Generates salts and hashes for password storage and verification.
+ * *NOTE*: This implementation is *NOT SECURE ENOUGH* for a real implementation of a password
+ * database, but is sufficient for a demo. For more information, see:
+ * https://en.wikipedia.org/wiki/Cryptographic_hash_function#Password_verification
+ */
+public final class HashUtil {
+
+    private static final int SALT_ENTROPY = 16;
+
+    private static final SecureRandom RANDOM = new SecureRandom();
+
+    /**
+     * Generates a salt from a cryptographically secure source of randomness.
+     */
+    public static String generateSalt() {
+        byte[] saltBytes = new byte[SALT_ENTROPY];
+        RANDOM.nextBytes(saltBytes);
+        return Base64.encodeToString(saltBytes, Base64.NO_WRAP | Base64.URL_SAFE);
+    }
+
+    /**
+     * Creates a salted hash of a password.
+     */
+    public static String hashPassword(String salt, String password) {
+        return base64Hash(salt + password);
+    }
+
+    /**
+     * Creates a Base64 encoded, SHA-256 hash of the provided string.
+     */
+    public static String base64Hash(String str) {
+        MessageDigest digest;
+        try {
+            digest = MessageDigest.getInstance("SHA-256");
+        } catch (NoSuchAlgorithmException ex) {
+            throw new IllegalStateException("Platform does not support SHA-256");
+        }
+
+        byte[] hashBytes = digest.digest(str.getBytes(Charset.forName("UTF-8")));
+        return Base64.encodeToString(hashBytes, Base64.NO_WRAP | Base64.URL_SAFE);
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java
new file mode 100644
index 0000000..bcfa4af
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/User.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin.userdata;
+
+import android.arch.persistence.room.ColumnInfo;
+import android.arch.persistence.room.Entity;
+import android.arch.persistence.room.Index;
+import android.arch.persistence.room.PrimaryKey;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * A simple model of a user, with information to attempt authentication.
+ */
+@Entity(tableName = "users", indices = {@Index(value = "email", unique = true)})
+public final class User {
+
+    @PrimaryKey
+    @ColumnInfo(name = "email")
+    private final String mEmail;
+
+    @ColumnInfo(name = "first_name")
+    private final String mName;
+
+    @ColumnInfo(name = "passwordSalt")
+    private final String mPasswordSalt;
+
+    @ColumnInfo(name = "passwordHash")
+    private final String mPasswordHash;
+
+    @ColumnInfo(name = "profile_picture_uri")
+    private final String mProfilePictureUri;
+
+    /**
+     * Creates a user from their core attributes.
+     */
+    public User(
+            @NonNull String email,
+            @Nullable String name,
+            @NonNull String passwordSalt,
+            @NonNull String passwordHash,
+            @Nullable String profilePictureUri) {
+        mName = name;
+        mEmail = email;
+        mPasswordSalt = passwordSalt;
+        mPasswordHash = passwordHash;
+        mProfilePictureUri = profilePictureUri;
+    }
+
+    @NonNull
+    public String getEmail() {
+        return mEmail;
+    }
+
+    @Nullable
+    public String getName() {
+        return mName;
+    }
+
+    @NonNull
+    public String getPasswordSalt() {
+        return mPasswordSalt;
+    }
+
+    @NonNull
+    public String getPasswordHash() {
+        return mPasswordHash;
+    }
+
+    @Nullable
+    public String getProfilePictureUri() {
+        return mProfilePictureUri;
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDao.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDao.java
new file mode 100644
index 0000000..4f75fbc
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDao.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin.userdata;
+
+import android.arch.persistence.room.Dao;
+import android.arch.persistence.room.Delete;
+import android.arch.persistence.room.Insert;
+import android.arch.persistence.room.OnConflictStrategy;
+import android.arch.persistence.room.Query;
+import android.arch.persistence.room.Update;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * A Room data access object for basic data manipulation operations on users.
+ */
+@Dao
+public interface UserDao {
+
+    /**
+     * Creates a new user in the database.
+     */
+    @Insert(onConflict = OnConflictStrategy.FAIL)
+    void createUser(@NonNull User user);
+
+    /**
+     * Updates an existing user entry in the database.
+     */
+    @Update
+    void updateUser(@NonNull User user);
+
+    /**
+     * Deletes a user from the database.
+     */
+    @Delete
+    void deleteUser(@NonNull User user);
+
+    /**
+     * Finds a user by their email address.
+     */
+    @Nullable
+    @Query("SELECT * FROM users WHERE email = :email")
+    User getUserByEmail(@NonNull String email);
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java
new file mode 100644
index 0000000..46908a1
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDataSource.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin.userdata;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * A service which can authenticate users, and remember who the current user is.
+ */
+public interface UserDataSource {
+
+    /**
+     * The currently authenticated user, if any.
+     */
+    @Nullable
+    User getCurrentUser();
+
+    /**
+     * Whether an account exists for the specified email address.
+     */
+    boolean isExistingAccount(@NonNull String email);
+
+    /**
+     * Attempts to create and persist a new user account account with the specified properties.
+     */
+    boolean createPasswordAccount(
+            @NonNull String email,
+            @NonNull String name,
+            @NonNull String profilePictureUri,
+            @NonNull String password);
+
+    /**
+     * Attempts to authenticate an existing user with the provided credentials.
+     */
+    boolean authWithPassword(@NonNull String email, @NonNull String password);
+
+    /**
+     * De-authenticates the current user.
+     */
+    void signOut();
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDatabase.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDatabase.java
new file mode 100644
index 0000000..3bc6e3d
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserDatabase.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin.userdata;
+
+import android.arch.persistence.room.Database;
+import android.arch.persistence.room.RoomDatabase;
+
+/**
+ * A Room database for user data.
+ */
+@Database(entities = {User.class}, version = 1, exportSchema = false)
+public abstract class UserDatabase extends RoomDatabase {
+
+    /**
+     * The user data access object.
+     */
+    public abstract UserDao userDao();
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java
new file mode 100644
index 0000000..074fa15
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/UserRepository.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp.passwordlogin.userdata;
+
+import android.arch.persistence.room.Room;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.WorkerThread;
+import org.openyolo.demoapp.passwordlogin.OpenYoloDemoApplication;
+
+/**
+ * A local implementation of UserDataSource for the purposes of this demo. This could be
+ * replaced with a more realistic implementation that makes network requests in order to
+ * authenticate the user.
+ */
+@WorkerThread
+public class UserRepository implements UserDataSource {
+
+    private static final String KEY_CURRENT_USER = "user";
+
+    private final UserDatabase mUserDatabase;
+    private final SharedPreferences mSharedPrefs;
+
+    /**
+     * Creates the user repository, with the required application reference.
+     */
+    public UserRepository(@NonNull OpenYoloDemoApplication application) {
+        mUserDatabase = Room.databaseBuilder(application, UserDatabase.class, "userdb")
+                .build();
+        mSharedPrefs = application.getSharedPreferences("authInfo", Context.MODE_PRIVATE);
+    }
+
+    @Override
+    @Nullable
+    public User getCurrentUser() {
+        String currentUserEmail = getCurrentUserEmail();
+        if (currentUserEmail == null) {
+            return null;
+        }
+
+        return mUserDatabase.userDao().getUserByEmail(currentUserEmail);
+    }
+
+    @Override
+    public boolean isExistingAccount(String email) {
+        return mUserDatabase.userDao().getUserByEmail(email) != null;
+    }
+
+    @Override
+    public boolean createPasswordAccount(
+            @NonNull String email,
+            String name,
+            String profilePictureUri,
+            String password) {
+        if (isExistingAccount(email)) {
+            return false;
+        }
+
+        String salt = HashUtil.generateSalt();
+        String hash = HashUtil.hashPassword(salt, password);
+
+        mUserDatabase.userDao().createUser(new User(email, name, salt, hash, profilePictureUri));
+        setCurrentUserEmail(email);
+        return true;
+    }
+
+    @Override
+    public boolean authWithPassword(String email, String password) {
+        User user = mUserDatabase.userDao().getUserByEmail(email);
+        if (user == null) {
+            return false;
+        }
+
+        String salt = user.getPasswordSalt();
+        String hash = HashUtil.hashPassword(salt, password);
+
+        if (hash.equals(user.getPasswordHash())) {
+            setCurrentUserEmail(email);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public void signOut() {
+        setCurrentUserEmail(null);
+    }
+
+    private String getCurrentUserEmail() {
+        return mSharedPrefs.getString(KEY_CURRENT_USER, null);
+    }
+
+    private void setCurrentUserEmail(String email) {
+        Editor editor = mSharedPrefs.edit();
+        if (email == null) {
+            editor.remove(KEY_CURRENT_USER);
+        } else {
+            editor.putString(KEY_CURRENT_USER, email);
+        }
+        editor.apply();
+    }
+}
diff --git a/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/package-info.java b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/package-info.java
new file mode 100644
index 0000000..b848837
--- /dev/null
+++ b/demoapps/passwordlogin/java/org/openyolo/demoapp/passwordlogin/userdata/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Classes and behavior related to users and user authentication.
+ */
+package org.openyolo.demoapp.passwordlogin.userdata;
diff --git a/demoapps/passwordlogin/proguard-rules.txt b/demoapps/passwordlogin/proguard-rules.txt
new file mode 100644
index 0000000..577c47c
--- /dev/null
+++ b/demoapps/passwordlogin/proguard-rules.txt
@@ -0,0 +1,4 @@
+-dontwarn sun.misc.Unsafe
+-dontwarn com.google.common.collect.MinMaxPriorityQueue
+-dontwarn android.arch.util.paging.CountedDataSource
+-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/drawable/ic_done.xml b/demoapps/passwordlogin/res/drawable/ic_done.xml
new file mode 100644
index 0000000..4f18a25
--- /dev/null
+++ b/demoapps/passwordlogin/res/drawable/ic_done.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0">
+  <path
+      android:fillColor="#FFFFFFFF"
+      android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z" />
+</vector>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/drawable/openyolo_logo.xml b/demoapps/passwordlogin/res/drawable/openyolo_logo.xml
new file mode 100644
index 0000000..d634469
--- /dev/null
+++ b/demoapps/passwordlogin/res/drawable/openyolo_logo.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="128dp"
+    android:height="128dp"
+    android:viewportWidth="128"
+    android:viewportHeight="128">
+
+  <path
+      android:fillColor="#fff"
+      android:pathData="M126,64 A62,62,0,1,1,2,64 A62,62,0,0,1,126,64 Z" />
+  <path
+      android:fillColor="#2491eb"
+      android:pathData="M26.2,113.2 A61.9,61.9,0,0,1,51.6,3.2 L51.6,11.7 A53.8,53.8,0,0,0,22.7,98.4
+L26.1,89.1 A45.5,45.5,0,0,1,59.9,18.7 L59.9,2.1 L64,2 A62,62,0,0,1,101.8,113.2
+L99.6,107.2 L98.8,104.9 L96.2,97.5 L95.8,96.5 L93.1,88.8 L92.7,87.8
+A37,37,0,0,0,76.4,28.9 L76.4,20.2 A45.5,45.5,0,0,1,101.9,89.1 L105.3,98.4
+A53.7,53.7,0,0,0,68.2,10.4 L68.2,27 L64,26.8 A37.2,37.2,0,0,0,35.3,87.8
+L32.2,96.5 L31.4,98.7 L29.2,104.9 L28,108.2 L26.2,113.2" />
+  <path
+      android:fillColor="#36434f"
+      android:pathData="M94.7,117.9 A61.7,61.7,0,0,1,33.3,117.9 L36.1,109.9 L44.8,85.7
+A28.9,28.9,0,0,1,64,35 A29,29,0,0,1,83.2,85.6 L91.9,109.9 L92.9,112.9
+L94.7,117.8 Z M54.3,83.8 L52,90.3 L46.4,106 L43.6,113.8
+A53.6,53.6,0,0,0,84.4,113.8 L81.9,106.8 L76,90.2 L76,90 L73.8,84 L73.2,82.5
+A20.7,20.7,0,1,0,54.8,82.5 L54.3,83.8" />
+</vector>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/layout/login_layout.xml b/demoapps/passwordlogin/res/layout/login_layout.xml
new file mode 100644
index 0000000..be4f737
--- /dev/null
+++ b/demoapps/passwordlogin/res/layout/login_layout.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout>
+
+  <data>
+
+    <import type="android.text.InputType" />
+    <import type="android.view.View" />
+
+    <variable
+        name="viewmodel"
+        type="org.openyolo.demoapp.passwordlogin.LoginViewModel" />
+  </data>
+
+  <android.support.design.widget.CoordinatorLayout
+      xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:tools="http://schemas.android.com/tools"
+      android:id="@+id/contentFrame"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      tools:context=".LoginActivity">
+
+    <LinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:app="http://schemas.android.com/apk/res-auto"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:padding="16dp">
+
+      <ImageView
+          android:layout_width="128dp"
+          android:layout_height="128dp"
+          android:layout_gravity="center"
+          app:srcCompat="@drawable/openyolo_logo"
+          android:contentDescription="@string/openyolo_logo_contentDescription" />
+
+      <TextView
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_gravity="center"
+          android:layout_marginTop="8dp"
+          android:layout_marginBottom="16dp"
+          android:textAppearance="@style/TextAppearance.AppCompat.Title"
+          android:text="@string/login_header"/>
+
+      <LinearLayout
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:orientation="vertical"
+          android:visibility="@{viewmodel.loading ? View.VISIBLE : View.GONE}"
+          android:gravity="center">
+
+        <ProgressBar
+            style="@style/Base.Widget.AppCompat.ProgressBar"
+            android:layout_width="64dp"
+            android:layout_height="64dp"
+            android:indeterminate="true"/>
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@{viewmodel.loadingLabel}"
+            tools:text="Loading..."/>
+
+      </LinearLayout>
+
+      <LinearLayout
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:paddingBottom="16dp"
+          android:orientation="vertical"
+          android:visibility="@{viewmodel.loading ? View.GONE : View.VISIBLE}">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:text="@{viewmodel.authPrompt}"
+            android:layout_marginBottom="16dp"/>
+
+        <android.support.design.widget.TextInputLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:errorEnabled="true"
+            app:errorText="@{viewmodel.emailError}">
+
+          <android.support.design.widget.TextInputEditText
+              android:id="@+id/email"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:hint="@string/email_field_hint"
+              android:inputType="textEmailAddress"
+              android:text="@={viewmodel.email}"/>
+
+        </android.support.design.widget.TextInputLayout>
+
+        <android.support.design.widget.TextInputLayout
+            android:id="@+id/password"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:visibility="@{viewmodel.showPasswordField ? View.VISIBLE : View.GONE}"
+            app:passwordToggleEnabled="true"
+            app:errorEnabled="true"
+            app:errorText="@{viewmodel.passwordError}">
+
+          <android.support.design.widget.TextInputEditText
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:text="@={viewmodel.password}"
+              android:inputType="textPassword"
+              android:hint="@string/password_field_hint" />
+
+        </android.support.design.widget.TextInputLayout>
+
+        <android.support.design.widget.FloatingActionButton
+            android:layout_width="72dp"
+            android:layout_height="72dp"
+            android:layout_gravity="center"
+            android:layout_margin="8dp"
+            android:onClick="@{viewmodel::signInButtonClicked}"
+            app:srcCompat="@drawable/ic_done" />
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="8dp"
+            android:text="@string/error_prompt"
+            android:textAlignment="center"
+            android:visibility="@{viewmodel.errorOccurred ? View.VISIBLE : View.GONE}"/>
+
+      </LinearLayout>
+    </LinearLayout>
+  </android.support.design.widget.CoordinatorLayout>
+
+</layout>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/layout/main_layout.xml b/demoapps/passwordlogin/res/layout/main_layout.xml
new file mode 100644
index 0000000..76fbe01
--- /dev/null
+++ b/demoapps/passwordlogin/res/layout/main_layout.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout>
+
+  <data>
+    <import type="android.view.View" />
+    <variable
+        name="viewmodel"
+        type="org.openyolo.demoapp.passwordlogin.MainViewModel" />
+  </data>
+
+  <android.support.design.widget.CoordinatorLayout
+      xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:tools="http://schemas.android.com/tools"
+      android:id="@+id/contentFrame"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      tools:context=".LoginActivity">
+
+    <LinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:app="http://schemas.android.com/apk/res-auto"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:padding="16dp">
+
+      <ImageView
+          android:layout_width="128dp"
+          android:layout_height="128dp"
+          android:layout_gravity="center_horizontal"
+          app:srcCompat="@drawable/openyolo_logo"
+          android:contentDescription="@string/openyolo_logo_contentDescription"/>
+
+      <TextView
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_gravity="center_horizontal"
+          android:layout_marginTop="8dp"
+          android:textAppearance="@style/TextAppearance.AppCompat.Title"
+          android:text="@string/signed_in_prompt"/>
+
+      <LinearLayout
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:padding="16dp"
+          android:orientation="horizontal">
+
+        <ImageView
+            android:id="@+id/profile_picture"
+            android:layout_width="64dp"
+            android:layout_height="64dp"
+            android:src="@{viewmodel.displayPicture}"
+            android:contentDescription="@string/user_profile_picture"/>
+
+        <LinearLayout
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="8dp"
+            android:layout_marginLeft="8dp"
+            android:orientation="horizontal">
+
+          <TextView
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
+              android:text="@{viewmodel.displayName}"/>
+
+          <TextView
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+              android:text="@{viewmodel.email}"/>
+        </LinearLayout>
+
+      </LinearLayout>
+
+      <Button
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_gravity="center_horizontal"
+          android:layout_marginTop="16dp"
+          android:onClick="@{viewmodel::onSignOutClicked}"
+          android:text="@string/sign_out_label"
+          style="@style/Widget.AppCompat.Button.Colored" />
+
+    </LinearLayout>
+  </android.support.design.widget.CoordinatorLayout>
+</layout>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/mipmap-hdpi/ic_launcher.png b/demoapps/passwordlogin/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..eed49b7
Binary files /dev/null and b/demoapps/passwordlogin/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/demoapps/passwordlogin/res/mipmap-mdpi/ic_launcher.png b/demoapps/passwordlogin/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..fb13297
Binary files /dev/null and b/demoapps/passwordlogin/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/demoapps/passwordlogin/res/mipmap-xhdpi/ic_launcher.png b/demoapps/passwordlogin/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..dc6a316
Binary files /dev/null and b/demoapps/passwordlogin/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/demoapps/passwordlogin/res/mipmap-xxhdpi/ic_launcher.png b/demoapps/passwordlogin/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..717578d
Binary files /dev/null and b/demoapps/passwordlogin/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/demoapps/passwordlogin/res/mipmap-xxxhdpi/ic_launcher.png b/demoapps/passwordlogin/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b72edc1
Binary files /dev/null and b/demoapps/passwordlogin/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/demoapps/passwordlogin/res/values/colors.xml b/demoapps/passwordlogin/res/values/colors.xml
new file mode 100644
index 0000000..0c017cc
--- /dev/null
+++ b/demoapps/passwordlogin/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <color name="colorPrimary">#2491eb</color>
+  <color name="colorPrimaryDark">#36434f</color>
+  <color name="colorAccent">#4fc3f7</color>
+</resources>
\ No newline at end of file
diff --git a/demoapps/passwordlogin/res/values/strings.xml b/demoapps/passwordlogin/res/values/strings.xml
new file mode 100644
index 0000000..3ffb624
--- /dev/null
+++ b/demoapps/passwordlogin/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <string name="app_name_short">OpenYOLO</string>
+  <string name="email_field_hint">Email</string>
+  <string name="password_field_hint">Password</string>
+  <string name="login_header">OpenYOLO Demo - Password Login</string>
+  <string name="sign_out_label">Sign out</string>
+  <string name="openyolo_logo_contentDescription">OpenYOLO logo</string>
+  <string name="enter_email_prompt">Enter your email address:</string>
+  <string name="incorrect_stored_password">Incorrect stored password in credential provider. Please re-enter your password:</string>
+  <string name="existing_account_enter_password">Welcome back! Please enter your password:</string>
+  <string name="new_account_enter_password">Hey, you\'re new! Please choose a password for your account</string>
+  <string name="error_prompt">Oops, that didn\'t work. Maybe try again?</string>
+  <string name="signed_in_prompt">You are signed in as:</string>
+  <string name="error_invalid_email">Invalid email address</string>
+  <string name="error_password_too_short">Password is too short</string>
+  <string name="error_incorrect_password">Wrong password, please try again</string>
+  <string name="user_profile_picture">User profile picture</string>
+</resources>
diff --git a/demoapps/passwordlogin/res/values/styles.xml b/demoapps/passwordlogin/res/values/styles.xml
new file mode 100644
index 0000000..6079fba
--- /dev/null
+++ b/demoapps/passwordlogin/res/values/styles.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+    <item name="colorAccent">@color/colorAccent</item>
+    <item name="colorPrimary">@color/colorPrimary</item>
+    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+  </style>
+</resources>
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index bd31ac3..fa0376a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':bbq', ':protocol', ':api', ':spi', ':testapp', ':demoproviders:barbican', ':demoproviders:trapdoor'
+include ':bbq', ':protocol', ':api', ':spi', ':testapp', ':demoproviders:barbican', ':demoproviders:trapdoor', ':demoapps:passwordlogin'

commit 918964c5e713db1db685fd12e89ed36636690ab9
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Fri Aug 25 09:59:42 2017 -0700

    Tapping the back button on the ProviderPickerActivity will now return a user canceled result. (#77)

diff --git a/api/java/org/openyolo/api/internal/ActivityResult.java b/api/java/org/openyolo/api/internal/ActivityResult.java
new file mode 100644
index 0000000..ece9b0a
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/ActivityResult.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Parcelable representation of an activity result.
+ */
+public final class ActivityResult implements Parcelable {
+
+    /**
+     * Parcelable creator for {@link ActivityResult}.
+     */
+    public static final Parcelable.Creator<ActivityResult> CREATOR = new Creator();
+
+    private final int mResultCode;
+    private final Intent mData;
+
+    /**
+     * Returns a new instance of an {@link ActivityResult} from the given result code and intent
+     * data.
+     */
+    public static ActivityResult of(int resultCode, Intent data) {
+        return new ActivityResult(resultCode, data);
+    }
+
+    private ActivityResult(int resultCode, Intent data) {
+        mResultCode = resultCode;
+        mData = data;
+    }
+
+    private ActivityResult(Parcel in) {
+        mResultCode = in.readInt();
+        mData = in.readParcelable(Intent.class.getClassLoader());
+    }
+
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    public Intent getData() {
+        return mData;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeInt(mResultCode);
+        out.writeParcelable(mData, flags);
+    }
+
+    private static final class Creator implements Parcelable.Creator<ActivityResult> {
+        @Override
+        public ActivityResult createFromParcel(Parcel parcel) {
+            return new ActivityResult(parcel);
+        }
+
+        @Override
+        public ActivityResult[] newArray(int size) {
+            return new ActivityResult[0];
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/package-info.java b/api/java/org/openyolo/api/internal/package-info.java
new file mode 100644
index 0000000..4b69863
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Collection of internal data types and utility classes that are used by the OpenYOLO libraries.
+ * _NOTE_: The contents of this package are _not_ part of the public API, and may change at any
+ * time.
+ */
+package org.openyolo.api.internal;
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
index d2d5038..acd97c3 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -31,2 +31,3 @@ import android.support.annotation.DimenRes;
 import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
@@ -47,195 +48,255 @@ import java.util.List;
 
-import org.openyolo.api.CredentialClient;
 import org.openyolo.api.KnownProviders;
 import org.openyolo.api.R;
+import org.openyolo.api.internal.ActivityResult;
+import org.openyolo.protocol.CredentialDeleteResult;
+import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.CredentialSaveResult;
+import org.openyolo.protocol.HintRetrieveResult;
 
 /**
  * Activity which presents the list of providers that claim to have a credential available.
  * The user can select one of these options, which fires the associated intent for that provider,
  * or cancel the whole operation.
  */
 public class ProviderPickerActivity extends AppCompatActivity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES = "titleRes";
+    private static final String EXTRA_USER_CANCELED_RESULT = "userCanceledResult";
     private static final String LOG_TAG = "ProviderPicker";
 
-    private CredentialClient mClient;
+    private static final ActivityResult RETRIEVE_USER_CANCELED_RESULT =
+            ActivityResult.of(
+                    CredentialRetrieveResult.CODE_USER_CANCELED,
+                    CredentialRetrieveResult.USER_CANCELED.toResultDataIntent());
+
+    private static final ActivityResult SAVE_USER_CANCELED_RESULT =
+            ActivityResult.of(
+                    CredentialSaveResult.CODE_USER_CANCELED,
+                    CredentialSaveResult.USER_CANCELED.toResultDataIntent());
+
+    private static final ActivityResult HINT_USER_CANCELED_RESULT =
+            ActivityResult.of(
+                    HintRetrieveResult.CODE_USER_CANCELED,
+                    HintRetrieveResult.USER_CANCELED.toResultDataIntent());
+
+    private static final ActivityResult DELETE_USER_CANCELED_RESULT =
+            ActivityResult.of(
+                    CredentialDeleteResult.CODE_USER_CANCELED,
+                    CredentialDeleteResult.USER_CANCELED.toResultDataIntent());
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.picker_layout);
 
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         Resources res = getResources();
         @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = res.getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
 
         TextView titleView = (TextView) findViewById(R.id.picker_title);
         @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
         if (titleRes != 0) {
             //robotium has an issue recovering resources in the shadow classes.
             titleView.setText(titleRes);
         }
 
         ListView providerView = (ListView) findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
+    @Override
+    public void onBackPressed() {
+        finishWithUserCanceled();
+    }
+
+    private void finishWithUserCanceled() {
+        ActivityResult activityResult = getIntent().getParcelableExtra(EXTRA_USER_CANCELED_RESULT);
+
+        if (null != activityResult) {
+            setResult(activityResult.getResultCode(), activityResult.getData());
+        }
+
+        finish();
+    }
+
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
-            @StringRes int titleRes) {
+            @StringRes int titleRes,
+            @Nullable ActivityResult userCanceledResult) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES, titleRes);
+        intent.putExtra(EXTRA_USER_CANCELED_RESULT, userCanceledResult);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
-        return createIntent(context, retrieveIntents, R.string.retrieve_picker_prompt);
+
+        return createIntent(
+                context,
+                retrieveIntents,
+                R.string.retrieve_picker_prompt,
+                RETRIEVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
-        return createIntent(context, retrieveIntents, R.string.save_picker_prompt);
+
+        return createIntent(
+                context,
+                retrieveIntents,
+                R.string.save_picker_prompt,
+                SAVE_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
-        return createIntent(context, hintIntents, R.string.hint_picker_prompt);
+
+        return createIntent(
+                context,
+                hintIntents,
+                R.string.hint_picker_prompt,
+                HINT_USER_CANCELED_RESULT);
     }
 
     /**
      * Creates an intent for display a list of providers to which a credential deletion request
      * should be sent.
      */
     public static Intent createDeleteIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> deleteIntents) {
-        return createIntent(context, deleteIntents, R.string.delete_picker_prompt);
+
+        return createIntent(
+                context,
+                deleteIntents,
+                R.string.delete_picker_prompt,
+                DELETE_USER_CANCELED_RESULT);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
             TextView providerUnsafe =
                     (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
 
             // To support vector drawables on Pre-L devices we choose to set the drawable
             // programmatically. See https://github.com/openid/OpenYOLO-Android/issues/63 for more
             // details.
             VectorDrawableCompat vectorDrawableCompat =
                     VectorDrawableCompat.create(
                             getResources(),
                             R.drawable.warning_icon,
                             getTheme());
             providerUnsafe.setCompoundDrawablesWithIntrinsicBounds(
                     vectorDrawableCompat,
                     null,
                     null,
                     null);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
 
         @SuppressWarnings("deprecation")
         private int getColor(@ColorRes int colorRes) {
             if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                 return getResources().getColor(colorRes, null);
             } else {
                 return getResources().getColor(colorRes);
             }
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/internal/ActivityResultTest.java b/api/javatests/org/openyolo/api/internal/ActivityResultTest.java
new file mode 100644
index 0000000..95e28e3
--- /dev/null
+++ b/api/javatests/org/openyolo/api/internal/ActivityResultTest.java
@@ -0,0 +1,42 @@
+package org.openyolo.api.internal;
+
+import android.content.Intent;
+import android.os.Parcel;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.CredentialDeleteResult;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+/**
+ * Units tests for {@link ActivityResult}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ActivityResultTest {
+
+    @Test
+    public void parcelAndUnparcel_withValidInput_returnsEquivalent() throws Exception {
+        Parcel parcel = Parcel.obtain();
+
+        int resultCode = CredentialDeleteResult.CODE_BAD_REQUEST;
+        Intent intent = CredentialDeleteResult.BAD_REQUEST.toResultDataIntent();
+
+        // Act
+        ActivityResult givenActivityResult = ActivityResult.of(resultCode, intent);
+        givenActivityResult.writeToParcel(parcel, 0 /* flags */);
+
+        parcel.setDataPosition(0);
+        ActivityResult outputActivityResult = ActivityResult.CREATOR.createFromParcel(parcel);
+
+        // Assert
+        assertThat(outputActivityResult.getResultCode()).isEqualTo(resultCode);
+
+        CredentialDeleteResult credentialDeleteResult =
+                CredentialDeleteResult.fromResultIntentData(outputActivityResult.getData());
+        assertThat(credentialDeleteResult.getResultCode()).isEqualTo(resultCode);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java
index 7ce7ca3..af5df43 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java
@@ -42,129 +42,129 @@ import org.openyolo.protocol.Protobufs;
 public class DeleteCredentialActivity extends AppCompatActivity implements ConnectedCallback {
 
     private static final String LOG_TAG = "DeleteCrActivity";
     private CredentialStorageClient mStorageClient;
     private CredentialDeleteRequest mRequest;
     private Set<AuthenticationDomain> mCallerAuthDomains;
 
 
     @BindView(R.id.delete_prompt)
     TextView mDeletePromptView;
 
     @BindView(R.id.delete_yes_button)
     Button mAcceptDeleteButton;
 
     @BindView(R.id.delete_no_button)
     Button mRefuseDeleteButton;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mRequest = CredentialDeleteRequest.fromRequestIntent(getIntent());
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
             setResultAndFinish(CredentialDeleteResult.BAD_REQUEST);
             return;
         }
 
         mCallerAuthDomains = CallerUtil.extractCallerAuthDomains(this);
 
         if (mCallerAuthDomains.isEmpty()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
             setResultAndFinish(CredentialDeleteResult.BAD_REQUEST);
             return;
         }
 
         // TODO: expand the caller auth domains to all equivalent domains
 
         if (!mCallerAuthDomains.contains(mRequest.getCredential().getAuthenticationDomain())) {
             setResultAndFinish(CredentialDeleteResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
 
         final Credential credentialToDelete = mRequest.getCredential();
 
         if (!mStorageClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized");
             setResultAndFinish(CredentialDeleteResult.NO_MATCHING_CREDENTIAL);
             return;
         }
 
         try {
             Protobufs.Credential proto = credentialToDelete.toProtobuf();
             if (!mStorageClient.hasCredential(proto)) {
                 setResultAndFinish(CredentialDeleteResult.NO_MATCHING_CREDENTIAL);
                 return;
             }
         } catch (IOException ex) {
             setResultAndFinish(CredentialDeleteResult.UNKNOWN);
         }
 
         setContentView(R.layout.delete_layout);
         ButterKnife.bind(this);
 
         // monitor interactions outside of the dialog
         getWindow().setFlags(
                 LayoutParams.FLAG_NOT_TOUCH_MODAL,
                 LayoutParams.FLAG_NOT_TOUCH_MODAL);
         getWindow().setFlags(
                         LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                         LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
 
         String callingAppName = CallerUtil.getCallingAppName(this);
         String savePromptTemplate = getString(R.string.delete_prompt_template);
         mDeletePromptView.setText(String.format(
                 savePromptTemplate,
                 credentialToDelete.getIdentifier(),
                 callingAppName).trim());
         mAcceptDeleteButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View view) {
                 try {
                     mStorageClient.deleteCredential(credentialToDelete.toProtobuf());
                     setResultAndFinish(CredentialDeleteResult.DELETED);
                 } catch (IOException e) {
                     setResultAndFinish(CredentialDeleteResult.UNKNOWN);
                 }
             }
         });
 
         mRefuseDeleteButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View view) {
                 // TODO: record the fact that the user refused to delete this credential, so
                 // that subsequent requests can be auto-refused.
                 setResultAndFinish(CredentialDeleteResult.USER_REFUSED);
             }
         });
     }
 
     @Override
     public void onBackPressed() {
         setResultAndFinish(CredentialDeleteResult.USER_CANCELED);
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResultAndFinish(CredentialDeleteResult.USER_CANCELED);
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     @UiThread
     private void setResultAndFinish(CredentialDeleteResult result) {
-        setResult(result.getResultCode(), result.toResultIntentData());
+        setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index a2eecfd..f9e6609 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -33,258 +33,258 @@ import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  */
 public final class CredentialDeleteResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult UNKNOWN =
             new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
     private static final String UNABLE_TO_EXTRACT_RESULT =
             "Unable to extract or parse the credential deletion result";
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), IllegalArgumentException.class);
 
         return new CredentialDeleteResult.Builder(proto).build();
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
      * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
     public static CredentialDeleteResult fromResultIntentData(
             @Nullable Intent intent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_RESULT,
                         Protobufs.CredentialDeleteResult.parser(),
                         UNABLE_TO_EXTRACT_RESULT,
                         intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * credential deletion result, if available.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
-    public Intent toResultIntentData() {
+    public Intent toResultDataIntent() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
          * @throws MalformedDataException if the protocol buffer could not be parsed from the
          *     intent.
          */
         private Builder(Protobufs.CredentialDeleteResult proto) throws MalformedDataException {
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion result. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index 68dae7b..8ddd08a 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -31,227 +31,236 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential save request. Contains a result code,
  * indicating whether the request was successful or not, and an optional set of additional,
  * non-standard result properties.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credentials</a>
  */
 public final class CredentialSaveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential sent to the provider was saved.
      */
     public static final int CODE_SAVED =
             Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
 
     /**
      * Indicates the provider refused to save the credential, due to some policy restriction. For
      * example, a provider may refuse to update an existing credential if it is stored in a shared
      * keychain. The client SHOULD NOT request to save this credential again.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to delete the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates the user refused the request to save this credential. The client SHOULD NOT request
      * to save this credential again.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built save result for an unspecified outcome. Carries no additional properties.
      */
     public static final CredentialSaveResult UNSPECIFIED =
             new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built save result that indicates the credential was saved. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult SAVED =
             new CredentialSaveResult.Builder(CODE_SAVED).build();
 
     /**
      * Pre-built save result that indicates the request was malformed. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult BAD_REQUEST =
             new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
 
+    /**
+     * Indicates that the user dismissed the request to save the credential, by either pressing the
+     * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
+     * that is not an explicit refusal to save the credential. The client MAY request to save this
+     * credential again at a later time.
+     */
+    public static final CredentialSaveResult USER_CANCELED =
+            new CredentialSaveResult.Builder(CODE_USER_CANCELED).build();
+
     /**
      * Pre-built save result that indicates the request was refused by the user. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult USER_REFUSED =
             new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the provider. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult PROVIDER_REFUSED =
             new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     private final int mResultCode;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential save result from its protocol buffer equivalent.
      * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialSaveResult.Builder(proto).build();
     }
 
     /**
      * Creates a protocol buffer representation of the credential save result, for transmission
      * or storage.
      */
     public Protobufs.CredentialSaveResult toProtobuf() {
         Protobufs.CredentialSaveResult.Builder builder =
                 Protobufs.CredentialSaveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProperties);
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential save result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_SAVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     private CredentialSaveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProperties = builder.mAdditionalProps;
     }
 
     /**
      * The result code for the credential save operation.
      */
     @NonNull
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link CredentialSaveResult} instances.
      */
     public static final class Builder {
         private int mResultCode = CODE_UNKNOWN;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result given the mandatory status
          * code.
          * @throws MalformedDataException if the given protocol buffer was not valid.
          */
         private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 proto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Seeds a credential save result from its protocol buffer equivalent.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
             return this;
         }
 
         /**
          * Finalizes the creation of the credential save result.
          */
         public CredentialSaveResult build() {
             return new CredentialSaveResult(this);
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
index 1aedad6..949b72b 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
@@ -26,3 +26,3 @@ import com.google.protobuf.ByteString;
 import com.google.protobuf.InvalidProtocolBufferException;
-import java.io.IOException;
+
 import org.junit.Test;
@@ -34,152 +34,152 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteResult}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteResultTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteResult INVALID_PROTO =
             Protobufs.CredentialDeleteResult.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
     private static final byte[] INVALID_PROTO_BYTES =
             new byte[] { 1, 2, 3, 4, 5 };
 
     @Test
     public void build() {
         CredentialDeleteResult result = new CredentialDeleteResult.Builder(
                 CredentialDeleteResult.CODE_DELETED)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toProtobuf() {
         Protobufs.CredentialDeleteResult result = new CredentialDeleteResult.Builder(
                 CredentialDeleteResult.CODE_DELETED)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build()
                 .toProtobuf();
 
         assertThat(result.getResultCodeValue()).isEqualTo(
                 Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE);
         checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
     }
 
     @Test
     public void toResultIntentData() throws InvalidProtocolBufferException {
         Intent resultData = new CredentialDeleteResult.Builder(
                 CredentialDeleteResult.CODE_DELETED)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build()
-                .toResultIntentData();
+                .toResultDataIntent();
 
         assertThat(resultData.hasExtra(ProtocolConstants.EXTRA_DELETE_RESULT)).isTrue();
 
         byte[] resultBytes = resultData.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_RESULT);
         Protobufs.CredentialDeleteResult result =
                 Protobufs.CredentialDeleteResult.parseFrom(resultBytes);
 
         assertThat(result.getResultCodeValue()).isEqualTo(ResultCode.DELETED_VALUE);
         checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
     }
 
     @Test
     public void fromResultIntentData() throws Exception {
         byte[] resultBytes = Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCode(ResultCode.USER_REFUSED)
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build()
                 .toByteArray();
 
         Intent resultData = new Intent();
         resultData.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, resultBytes);
 
         CredentialDeleteResult result = CredentialDeleteResult.fromResultIntentData(resultData);
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_USER_REFUSED);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_nullIntent_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(null);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_missingExtra_throwsException() throws Exception {
         CredentialDeleteResult.fromResultIntentData(new Intent());
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, "notAByteArray");
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO_BYTES);
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromResultIntentData_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO.toByteArray());
 
         CredentialDeleteResult.fromResultIntentData(intent);
     }
 
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.CredentialDeleteResult proto = Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCode(ResultCode.BAD_REQUEST)
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test(expected=MalformedDataException.class)
     public void fromProtobuf_invalidProtoData_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
         byte[] protoBytes = Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCode(ResultCode.BAD_REQUEST)
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build()
                 .toByteArray();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobufBytes(protoBytes);
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 }

commit 9c3e2c548e033978b6cecf4d7cdd5d04790326a1
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Aug 23 10:26:13 2017 -0700

    Fixed bug where our use of vectors on Pre-L devices caused a fatal exception (#79)

diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
index 1ba9850..d2d5038 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -32,2 +32,3 @@ import android.support.annotation.NonNull;
 import android.support.annotation.StringRes;
+import android.support.graphics.drawable.VectorDrawableCompat;
 import android.support.v7.app.AppCompatActivity;
@@ -45,2 +46,3 @@ import java.util.Collections;
 import java.util.List;
+
 import org.openyolo.api.CredentialClient;
@@ -50,176 +52,190 @@ import org.openyolo.api.R;
 /**
  * Activity which presents the list of providers that claim to have a credential available.
  * The user can select one of these options, which fires the associated intent for that provider,
  * or cancel the whole operation.
  */
 public class ProviderPickerActivity extends AppCompatActivity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES = "titleRes";
     private static final String LOG_TAG = "ProviderPicker";
 
     private CredentialClient mClient;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.picker_layout);
 
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         Resources res = getResources();
         @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = res.getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
 
         TextView titleView = (TextView) findViewById(R.id.picker_title);
         @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
         if (titleRes != 0) {
             //robotium has an issue recovering resources in the shadow classes.
             titleView.setText(titleRes);
         }
 
         ListView providerView = (ListView) findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES, titleRes);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.retrieve_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.save_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
         return createIntent(context, hintIntents, R.string.hint_picker_prompt);
     }
 
     /**
      * Creates an intent for display a list of providers to which a credential deletion request
      * should be sent.
      */
     public static Intent createDeleteIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> deleteIntents) {
         return createIntent(context, deleteIntents, R.string.delete_picker_prompt);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
             TextView providerUnsafe =
                     (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
 
+            // To support vector drawables on Pre-L devices we choose to set the drawable
+            // programmatically. See https://github.com/openid/OpenYOLO-Android/issues/63 for more
+            // details.
+            VectorDrawableCompat vectorDrawableCompat =
+                    VectorDrawableCompat.create(
+                            getResources(),
+                            R.drawable.warning_icon,
+                            getTheme());
+            providerUnsafe.setCompoundDrawablesWithIntrinsicBounds(
+                    vectorDrawableCompat,
+                    null,
+                    null,
+                    null);
+
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
 
         @SuppressWarnings("deprecation")
         private int getColor(@ColorRes int colorRes) {
             if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                 return getResources().getColor(colorRes, null);
             } else {
                 return getResources().getColor(colorRes);
             }
         }
     }
 }
diff --git a/api/res/drawable/warning_icon_compat_wrapper.xml b/api/res/drawable/warning_icon_compat_wrapper.xml
deleted file mode 100644
index 7f4b3f1..0000000
--- a/api/res/drawable/warning_icon_compat_wrapper.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-this exists to provide a layer of indirection to the vector drawable, which
-ensures that support-vector-drawable will render the vector regardless of
-the context where it is used.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:drawable="@drawable/warning_icon" />
-</selector>
\ No newline at end of file
diff --git a/api/res/layout/provider_item.xml b/api/res/layout/provider_item.xml
index d333703..877ece1 100644
--- a/api/res/layout/provider_item.xml
+++ b/api/res/layout/provider_item.xml
@@ -1,46 +1,44 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="48dp"
     android:clickable="true"
     android:focusable="true"
     android:background="?attr/selectableItemBackground"
     android:orientation="horizontal"
     android:gravity="center_vertical">
 
     <ImageView
         android:id="@+id/provider_icon"
         android:layout_width="24dp"
         android:layout_height="24dp"
         android:contentDescription="@string/provider_icon_contentDescription" />
 
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:layout_marginLeft="32dp"
         android:layout_marginStart="32dp"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/provider_name"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
             tools:text="Provider Name"/>
 
         <TextView
             android:id="@+id/unsafe_provider_warning"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:drawableLeft="@drawable/warning_icon_compat_wrapper"
-            android:drawableStart="@drawable/warning_icon_compat_wrapper"
             android:drawablePadding="4dp"
             android:text="@string/possibly_unsafe"
             android:textAppearance="@style/TextAppearance.AppCompat.Caption"
             android:textColor="@color/amber_700_54pc"/>
     </LinearLayout>
 
 </LinearLayout>

commit f896a958f0ad4f408a523ec23170b018cac36010
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Wed Aug 23 10:24:00 2017 -0700

    Changed AuthenticationDomain to enforce applications have exactly one signature (#76)

diff --git a/api/java/org/openyolo/api/KnownProviders.java b/api/java/org/openyolo/api/KnownProviders.java
index 6ca018f..5b66c97 100644
--- a/api/java/org/openyolo/api/KnownProviders.java
+++ b/api/java/org/openyolo/api/KnownProviders.java
@@ -21,3 +21,2 @@ import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
@@ -27,173 +26,170 @@ import org.openyolo.protocol.AuthenticationDomain;
 /**
  * Manages a list of known providers, identified by their package name and a hash of their
  * signing certificate. This class will attempt to dynamically retrieve a list of known providers
  * from openyolo.org if possible, otherwise it will fall back to the list of known providers at
  * compile time.
  */
 public class KnownProviders {
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.dashlane.com">Dashlane</a>.
      */
     public static final AuthenticationDomain DASHLANE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
                     + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
                     + "@com.dashlane");
 
     /**
      * The known package name and certificate hash for Google's
      * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
      * Smart Lock for Passwords</a>.
      */
     public static final AuthenticationDomain GOOGLE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
                     + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
                     + "@com.google.android.gms");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://keepersecurity.com/">Keeper</a>.
      */
     public static final AuthenticationDomain KEEPER_PROVIDER =
             new AuthenticationDomain("android://"
                     + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
                     + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
                     + "@com.callpod.android_apps.keeper");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.lastpass.com/">LastPass</a>.
      */
     public static final AuthenticationDomain LASTPASS_PROVIDER =
             new AuthenticationDomain("android://"
                     + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
                     + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
                     + "@com.lastpass.lpandroid");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://1password.com/">1Password</a>.
      */
     public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
             new AuthenticationDomain("android://"
                     + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
                     + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
                     + "@com.agilebits.onepassword");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.roboform.com/">Roboform</a>.
      */
     public static final AuthenticationDomain ROBOFORM_PROVIDER =
             new AuthenticationDomain("android://"
                     + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
                     + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
                     + "@com.siber.roboform");
 
     /**
      * The list of known providers at the time this library was compiled.
      */
     public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
             Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
                     DASHLANE_PROVIDER,
                     GOOGLE_PROVIDER,
                     KEEPER_PROVIDER,
                     LASTPASS_PROVIDER,
                     ONEPASSWORD_PROVIDER,
                     ROBOFORM_PROVIDER
             )));
 
     private static final AtomicReference<KnownProviders> INSTANCE_REF =
             new AtomicReference<>();
 
     /**
      * Retrieves the singleton instance of the known provider list.
      */
     public static KnownProviders getInstance(Context context) {
         KnownProviders providers = new KnownProviders(context);
         if (!INSTANCE_REF.compareAndSet(null, providers)) {
             providers = INSTANCE_REF.get();
         }
 
         return providers;
     }
 
     /**
      * FOR TESTING ONLY - Overrides the KnownProvider instance. It is *strongly discouraged*
      * to use this method in anything other than unit tests, as it can compromise the security
      * of your app and the user's credentials.
      */
     @VisibleForTesting
     static void setApplicationBoundInstance(KnownProviders instance) {
         INSTANCE_REF.set(instance);
     }
 
     /**
      * FOR TESTING ONLY - Clears the current instance of KnownProvider.
      */
     @VisibleForTesting
     static void clearApplicationBoundInstance() {
         INSTANCE_REF.set(null);
     }
 
     private final Context mApplicationContext;
     private Set<AuthenticationDomain> mKnownProviders;
 
     private KnownProviders(Context context) {
         mApplicationContext = context.getApplicationContext();
 
         // TODO: implement dynamic retrieval of known providers from
         // https://www.openyolo.org/known-providers
         // and fall back to the static list only if this fails
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     public Set<AuthenticationDomain> getKnownProviders() {
         return new HashSet<>(mKnownProviders);
     }
 
     /**
      * Determines whether the application with the specified package name (if installed) is
      * on the known provider list.
      */
     public boolean isKnown(String packageName) {
-        List<AuthenticationDomain> packageAuthDomains =
-                AuthenticationDomain.listForPackage(mApplicationContext, packageName);
-
-        for (AuthenticationDomain packageAuthDomain : packageAuthDomains) {
-            if (mKnownProviders.contains(packageAuthDomain)) {
-                return true;
-            }
+        AuthenticationDomain authDomain =
+                AuthenticationDomain.fromPackageName(mApplicationContext, packageName);
+        if (null == authDomain) {
+            return false;
         }
 
-        return false;
+        return mKnownProviders.contains(authDomain);
     }
 
     /**
      * Reset the list of known providers to the default provider set. If possible, this will be
      * dynamically updated with a list retrieved from openyolo.org.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void resetKnownProvidersToDefault() {
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     /**
      * Adds a provider to the known provider list.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void addKnownProvider(AuthenticationDomain provider) {
         HashSet<AuthenticationDomain> knownProviders = new HashSet<>(mKnownProviders);
         knownProviders.add(provider);
         mKnownProviders = Collections.unmodifiableSet(knownProviders);
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
index e82d912..faf17f0 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
@@ -52,257 +52,260 @@ import org.openyolo.protocol.Credential;
 /**
  * Creates credentials from manual user input for storage.
  */
 public class CreateCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "CreateCredential";
 
     private static final int MIN_ID_LENGTH = 1;
     private static final int MIN_PASS_LENGTH = 1;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.headerToolbar)
     Toolbar mToolbar;
 
     @BindView(R.id.appBar)
     AppBarLayout mAppBar;
 
     @BindView(R.id.credential_authority)
     Spinner mCredentialAuthority;
 
     @BindView(R.id.credential_id)
     EditText mCredentialId;
 
     @BindView(R.id.credential_password)
     EditText mCredentialPassword;
 
     private MenuItem mDoneButton;
 
     private CredentialStorageClient mStorageClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.create_credential_layout);
         ButterKnife.bind(this);
         getSupportActionBar();
         setSupportActionBar(mToolbar);
         mToolbar.setNavigationIcon(R.drawable.back);
         mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 finish();
             }
         });
         mCredentialAuthority.setAdapter(new AppAdapter(getInstalledApps()));
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.menu_create, menu);
         mDoneButton = menu.findItem(R.id.action_done);
         onFieldsChanged();
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (super.onOptionsItemSelected(item)) {
             return true;
         }
 
         if (R.id.action_done == item.getItemId()) {
             App app = (App) mCredentialAuthority.getSelectedItem();
             String username = mCredentialId.getText().toString();
             String password = mCredentialPassword.getText().toString();
             new StoreCredentialTask(app.mPackageName, username, password).execute();
         }
 
         return false;
     }
 
     @OnItemSelected(R.id.credential_authority)
     @OnTextChanged({R.id.credential_id, R.id.credential_password})
     void onFieldsChanged() {
         boolean validCredential =
                 mCredentialAuthority.getSelectedItemPosition() != Spinner.INVALID_POSITION
                 && mCredentialId.length() >= MIN_ID_LENGTH
                 && mCredentialPassword.length() >= MIN_PASS_LENGTH;
 
         if (mDoneButton != null) {
             mDoneButton.setEnabled(validCredential);
         }
     }
 
     private List<App> getInstalledApps() {
         List<String> appPackageNames = InstalledAppsUtil.getInstalledAppsList(this);
         ArrayList<App> apps = new ArrayList<>();
         PackageManager pm = getPackageManager();
         for (String packageName : appPackageNames) {
             try {
                 ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                 String appName = pm.getApplicationLabel(info).toString();
                 Drawable appIcon = pm.getApplicationIcon(info);
                 apps.add(new App(packageName, appName, appIcon));
             } catch (PackageManager.NameNotFoundException e) {
                 // skip this app
             }
         }
 
         return apps;
     }
 
     @SuppressLint("StaticFieldLeak")
     private class StoreCredentialTask extends AsyncTask<Void, Void, Boolean> {
 
         final String mPackageName;
         final String mUsername;
         final String mPassword;
 
         StoreCredentialTask(
                 String packageName,
                 String username,
                 String password) {
             mPackageName = packageName;
             mUsername = username;
             mPassword = password;
         }
 
         @Override
         protected Boolean doInBackground(Void... params) {
-            AuthenticationDomain domain = AuthenticationDomain.listForPackage(
+            AuthenticationDomain domain = AuthenticationDomain.fromPackageName(
                     CreateCredentialActivity.this,
-                    mPackageName)
-                    .get(0);
+                    mPackageName);
+            if (null == domain) {
+                Log.e(LOG_TAG, "Failed to find auth-domain associated with package name.");
+                return null;
+            }
 
             Credential credential = new Credential.Builder(
                     mUsername,
                     AuthenticationMethods.EMAIL,
                     domain)
                     .setPassword(mPassword)
                     .build();
             try {
                 mStorageClient.upsertCredential(credential.toProtobuf());
                 return true;
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to upsert credential to database");
             }
             return null;
         }
 
         @Override
         protected void onPostExecute(Boolean success) {
             if (success) {
                 finish();
             } else {
                 Snackbar.make(
                         mRootView,
                         R.string.save_failed,
                         Snackbar.LENGTH_SHORT).show();
             }
         }
     }
 
     private class App implements Comparable<App> {
         @NonNull String mName;
         @NonNull String mPackageName;
         @Nullable Drawable mIcon;
 
         App(@NonNull String packageName, @NonNull String name, @Nullable Drawable icon) {
             mPackageName = packageName;
             mName = name;
             mIcon = icon;
         }
 
         @Override
         public int compareTo(@NonNull App app) {
             return mName.compareTo(app.mName);
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (!(obj instanceof App)) {
                 return false;
             }
 
             App other = (App) obj;
             return mPackageName.equals(other.mPackageName);
         }
 
         @Override
         public int hashCode() {
             return mPackageName.hashCode();
         }
     }
 
     private class AppAdapter extends BaseAdapter {
 
         private final List<App> mApps;
         private final LayoutInflater mInflater;
 
         AppAdapter(@NonNull List<App> apps) {
             mApps = apps;
             mInflater = LayoutInflater.from(CreateCredentialActivity.this);
         }
 
         @Override
         public int getCount() {
             return mApps.size();
         }
 
         @Override
         public Object getItem(int index) {
             return mApps.get(index);
         }
 
         @Override
         public long getItemId(int index) {
             return mApps.get(index).hashCode();
         }
 
         @Override
         public View getView(int index, View view, ViewGroup viewGroup) {
             App app = mApps.get(index);
             if (view == null) {
                 view = mInflater.inflate(R.layout.app_item, viewGroup, false);
             }
 
             ImageView iconView = (ImageView) view.findViewById(R.id.app_icon);
             if (app.mIcon != null) {
                 iconView.setImageDrawable(app.mIcon);
                 iconView.setVisibility(View.VISIBLE);
             } else {
                 iconView.setVisibility(View.INVISIBLE);
             }
 
             TextView nameView = (TextView) view.findViewById(R.id.app_name);
             nameView.setText(app.mName);
 
             return view;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java
index ab7199b..fc92952 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java
@@ -21,2 +21,4 @@ import android.content.pm.PackageManager;
 import android.support.annotation.NonNull;
+
+import java.util.Arrays;
 import java.util.Collections;
@@ -27,32 +29,38 @@ import org.openyolo.protocol.AuthenticationDomain;
 /**
  * Extracts information on the caller of an activity.
  */
 public final class CallerUtil {
 
     /**
      * Extracts the set of authentication domains for the caller of the provided activity.
      */
     @NonNull
     public static Set<AuthenticationDomain> extractCallerAuthDomains(@NonNull Activity activity) {
         ComponentName callingActivity = activity.getCallingActivity();
         if (callingActivity == null) {
             return Collections.emptySet();
         }
 
         String callingPackage = callingActivity.getPackageName();
-        return new HashSet<>(AuthenticationDomain.listForPackage(activity, callingPackage));
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.fromPackageName(activity, callingPackage);
+        if (null == authenticationDomain) {
+            return Collections.EMPTY_SET;
+        }
+
+        return new HashSet<>(Arrays.asList(authenticationDomain));
     }
 
     /**
      * Determines the human-readable name of the caller of the provided activity.
      */
     public static String getCallingAppName(@NonNull Activity activity) {
         try {
             PackageManager pm = activity.getPackageManager();
             ApplicationInfo info = pm.getApplicationInfo(activity.getCallingPackage(), 0);
             return pm.getApplicationLabel(info).toString();
         } catch (PackageManager.NameNotFoundException e) {
             return "???";
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
index da636ea..d347eea 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
@@ -45,180 +45,180 @@ import org.openyolo.protocol.ProtocolConstants;
 public class HintPickerActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "HintPickerActivity";
 
     private HintRetrieveRequest mRequest;
     private AuthenticationDomain mCallerAuthDomain;
     private CredentialStorageClient mClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (!getIntent().hasExtra(ProtocolConstants.EXTRA_HINT_REQUEST)) {
             Log.w(LOG_TAG, "No hint request object found in the intent");
             setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
             mRequest = HintRetrieveRequest.fromProtoBytes(
                     getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_HINT_REQUEST));
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
             setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         if (!extractCallerAuthDomain()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
             setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
 
         if (!mClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
             setResultAndFinish(HintRetrieveResult.UNKNOWN);
             return;
         }
 
         // some credential provider implementations may require an unlock to retrieve the
         // information required for hints, but for Barbican we instead choose to store basic
         // profile information usable for hints in plain text. With root access, this information
         // would be retrievable by malicious applications on the device, representing a privacy
         // risk. However, full credentials and associations between account identifiers
         // remain encrypted.
 
         List<AccountHint> hints;
         try {
             hints = mClient.getHints();
         } catch (IOException ex) {
             Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
             setResultAndFinish(HintRetrieveResult.UNKNOWN);
             return;
         }
 
         // filter the credentials to just those which are pertinent to the request. For those
         // selected, turn them into credentials. Order the hints by the amount of information
         // they contain (so more complete items are displayed first), and then alphabetically.
         ArrayList<Hint> filteredHints = new ArrayList<>();
         for (AccountHint hint : hints) {
             AuthenticationMethod hintAuthMethod = new AuthenticationMethod(hint.getAuthMethod());
             Set<AuthenticationMethod> authMethods = mRequest.getAuthenticationMethods();
             if (!authMethods.contains(hintAuthMethod)) {
                 continue;
             }
 
             Hint.Builder hintProtoBuilder = new Hint.Builder(
                     hint.getIdentifier(),
                     hintAuthMethod)
                     .setDisplayName(hint.getName())
                     .setDisplayPictureUri(hint.getPictureUri());
 
             // include a generated password if appropriate
             if (hintAuthMethod.equals(AuthenticationMethods.EMAIL)
                     || hintAuthMethod.equals(AuthenticationMethods.PHONE)
                     || hintAuthMethod.equals(AuthenticationMethods.USER_NAME)) {
                 hintProtoBuilder.setGeneratedPassword(
                         mRequest.getPasswordSpecification().generate());
             }
 
             filteredHints.add(hintProtoBuilder.build());
         }
 
         // if there are no hints, immediately end the request
         if (filteredHints.isEmpty()) {
             setResultAndFinish(HintRetrieveResult.NO_HINTS_AVAILABLE);
             return;
         }
 
         // otherwise, display the standard credential picker.
         renderPicker(filteredHints);
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void renderPicker(List<Hint> hints) {
         setContentView(R.layout.hint_picker_layout);
 
         RecyclerView hintsView = (RecyclerView) findViewById(R.id.available_hints);
 
         hintsView.setAdapter(new HintPickerAdapter(hints));
         hintsView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     private boolean extractCallerAuthDomain() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         String callingPackage = callingActivity.getPackageName();
-        List<AuthenticationDomain> authDomains =
-                AuthenticationDomain.listForPackage(this, callingPackage);
+        AuthenticationDomain authDomain =
+                AuthenticationDomain.fromPackageName(this, callingPackage);
 
-        if (authDomains.isEmpty()) {
+        if (null == authDomain) {
             return false;
         }
 
-        mCallerAuthDomain = authDomains.get(0);
+        mCallerAuthDomain = authDomain;
         return true;
     }
 
     @UiThread
     private void setResultAndFinish(HintRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private final class HintPickerAdapter extends RecyclerView.Adapter<AccountViewHolder> implements
             ClickHandler<Hint> {
 
         List<Hint> mHints;
 
         HintPickerAdapter(List<Hint> hints) {
             mHints = hints;
         }
 
         @Override
         public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new AccountViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(AccountViewHolder holder, int position) {
             holder.bind(mHints.get(position), this);
         }
 
         @Override
         public int getItemCount() {
             return mHints.size();
         }
 
         @Override
         public void onClick(Hint clicked) {
             HintRetrieveResult result = new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_HINT_SELECTED)
                     .setHint(clicked)
                     .build();
 
             setResultAndFinish(result);
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index 43608c1..7654bf0 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -23,2 +23,3 @@ import android.util.Log;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.List;
@@ -34,111 +35,117 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
 public class RetrieveCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "RetrieveCredential";
     private CredentialStorageClient mClient;
     private CredentialRetrieveRequest mRequest;
 
     /**
      * Creates the intent to handle releasing a credential to the calling app.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         // the format of this intent needs to be compatible with a "direct invocation" intent,
         // based on the spec (Section 4.3.1).
         Intent intent = new Intent(context, RetrieveCredentialActivity.class);
         intent.setAction(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
         intent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_REQUEST,
                 request.toProtocolBuffer().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
             mRequest = CredentialRetrieveRequest.fromRequestIntent(getIntent());
         } catch (MalformedDataException ex) {
             setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
         }
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
         if (!client.isUnlocked()) {
             Intent retrieveAfterUnlockIntent =
                     RetrieveCredentialActivity.createIntent(this, mRequest);
             retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
             Intent unlockIntent =
                     UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
             unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(unlockIntent);
             finish();
         } else {
             // TODO: we actually need the full set of requested domains from the original request,
             // not just those based on the package name.
 
-            List<AuthenticationDomain> authDomains =
-                    AuthenticationDomain.listForPackage(this, getCallingPackage());
+            AuthenticationDomain authDomain =
+                    AuthenticationDomain.fromPackageName(this, getCallingPackage());
+            if (null == authDomain) {
+                Log.w(LOG_TAG, "Failed to get AuthenticationDomain for calling app.");
+                finish();
+                return;
+            }
 
             List<Credential> credentials;
             try {
+                List<AuthenticationDomain> authDomains = Arrays.asList(authDomain);
                 credentials =
                         CredentialTransformUtils.fromProtoList(client.listCredentials(authDomains));
             } catch (IOException ex) {
                 Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
                 finish();
                 return;
             } catch (MalformedDataException ex) {
                 Log.w(LOG_TAG, "Unable to parse credentials from their protocol buffer form", ex);
                 finish();
                 return;
             }
 
             if (!mRequest.getRequireUserMediation() && credentials.size() == 1) {
                 Intent autoSignInIntent =
                         AutoSignInActivity.createIntent(this, credentials.get(0));
                 autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(autoSignInIntent);
             } else {
                 Intent pickerIntent =
                         CredentialPickerActivity.createIntent(this, credentials);
                 pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(pickerIntent);
             }
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
index cdbe6db..7860dc3 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -24,3 +24,4 @@ import android.util.Log;
 import java.io.IOException;
-import java.util.List;
+import java.util.Arrays;
+
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
@@ -33,116 +34,116 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * Verifies the rights to save a credential, before proceeding to
  * {@link SaveCredentialConfirmationActivity}.
  */
 public class SaveCredentialActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
 
     private CredentialSaveRequest mRequest;
     private String mCallingPackage;
-    private List<AuthenticationDomain> mAuthDomainsForApp;
+    private AuthenticationDomain mAuthDomainForApp;
     private CredentialStorageClient mStorageClient;
 
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         final byte[] encodedRequest =
                 getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_REQUEST);
 
         // Ensure the intent contains a save request
         if (null == encodedRequest) {
             Log.w(LOG_TAG, "No save request included in intent");
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         // Ensure the request can successfully be parsed from it's encoded form
         try {
             mRequest = CredentialSaveRequest.fromProtoBytes(encodedRequest);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "Failed to decode save request", ex);
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         if (!verifyCaller()) {
             Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
                     + mRequest.getCredential().getAuthenticationDomain());
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(final CredentialStorageClient client) {
                 mStorageClient = client;
                 runOnUiThread(new AfterStorageConnect());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         if (mStorageClient != null) {
             mStorageClient.disconnect(this);
         }
     }
 
     @UiThread
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private boolean verifyCaller() {
         final ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         mCallingPackage = callingActivity.getPackageName();
-        mAuthDomainsForApp = AuthenticationDomain.listForPackage(this, mCallingPackage);
+        mAuthDomainForApp = AuthenticationDomain.fromPackageName(this, mCallingPackage);
 
         final AuthenticationDomain authDomain = mRequest.getCredential().getAuthenticationDomain();
-        if (!mAuthDomainsForApp.contains(authDomain)) {
+        if (!authDomain.equals(mAuthDomainForApp)) {
             Log.w(LOG_TAG, "App " + mCallingPackage
                     + " is not provably associated to authentication domain "
                     + authDomain
                     + " for the credential to be saved.");
             return false;
         }
 
         return true;
     }
 
     private final class AfterStorageConnect implements Runnable {
         @Override
         public void run() {
             try {
                 // Ensure authentication domain is not on never save list
-                if (mStorageClient.isOnNeverSaveList(mAuthDomainsForApp)) {
+                if (mStorageClient.isOnNeverSaveList(Arrays.asList(mAuthDomainForApp))) {
                     finishWithResult(CredentialSaveResult.PROVIDER_REFUSED);
                     return;
                 }
 
                 // Start confirm activity
                 Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
                         SaveCredentialActivity.this,
                         mCallingPackage,
                         mRequest.getCredential());
                 confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(confirmIntent);
                 finish();
             } catch (IOException ex) {
                 finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         }
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
index 375a408..05c9e8d 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -24,3 +24,2 @@ import android.text.TextWatcher;
 import android.util.Log;
-import java.util.TreeSet;
 import me.philio.pinentry.PinEntryView;
@@ -32,72 +31,78 @@ import org.openyolo.protocol.CredentialRetrieveResult;
 /**
  * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
  */
 public class RetrieveActivity extends AppCompatActivity {
 
     private static final int PIN_SIZE = 6;
 
     private static final String LOG_TAG = "TrapdoorRetrieve";
 
     private AuthenticationDomain mDomain;
 
     /**
      * Creates an Intent to start this activity.
      */
     public static Intent createIntent(Context context) {
         return new Intent(context, RetrieveActivity.class);
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
             setResult(RESULT_CANCELED);
             finish();
             return;
         }
 
-        mDomain = new TreeSet<>(
-                AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
+        mDomain = AuthenticationDomain.fromPackageName(this, getCallingPackage());
+        if (null == mDomain) {
+            Log.w(LOG_TAG, "No AuthenticationDomain associated with the calling package.");
+            setResult(RESULT_CANCELED);
+            finish();
+            return;
+        }
+
         Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
 
         setContentView(R.layout.dialog_layout);
         ((PinEntryView)findViewById(R.id.pin_entry_field))
                 .addTextChangedListener(new PinChangedWatcher());
     }
 
     private class PinChangedWatcher implements TextWatcher {
         @Override
         public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
 
         @Override
         public void onTextChanged(CharSequence seq, int start, int before, int count) {}
 
         @Override
         public void afterTextChanged(Editable pin) {
             if (pin.length() != PIN_SIZE) {
                 return;
             }
             String userName = UserDataStore.getUserName(RetrieveActivity.this);
             String password = PasswordGenerator.generatePassword(
                     userName,
                     pin.toString(),
                     mDomain.toString());
 
             Credential credential = new Credential.Builder(
                     UserDataStore.getUserName(RetrieveActivity.this),
                     AuthenticationMethods.EMAIL,
                     mDomain)
                     .setPassword(password)
                     .build();
 
             CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
                     CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                     .setCredential(credential)
                     .build();
             setResult(result.getResultCode(), result.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
index a63b57f..2192260 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
@@ -29,4 +29,4 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.text.TextUtils;
 import android.util.Base64;
+import android.util.Log;
 import java.io.IOException;
@@ -34,240 +34,236 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
 
 
 /**
  * A URI-based representation of an authentication domain, which determines the scope within which
  * a credential is valid. An authentication domain may have multiple equivalent representations,
  * such as when apps and sites share the same authentication system. The responsibility for
  * determining whether two given authentication domains are equivalent lies with the credential
  * provider.
  *
  * <p>Two broad classes of authentication domain are defined in the OpenYOLO
  * specification : Android authentication domains, of form
  * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
  * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
  * with no path, query or fragment. They must therefore always be of form
  * {@code scheme://authority}.
  */
 @SuppressLint("PackageManagerGetSignatures")
 public final class AuthenticationDomain implements Comparable<AuthenticationDomain> {
 
+    private static final String TAG = "AuthenticationDomain";
+
     private static final String DIGEST_SHA_512 = "SHA-512";
     private static final String SCHEME_ANDROID = "android";
     private static final String SCHEME_HTTP = "http";
     private static final String SCHEME_HTTPS = "https";
 
     private final String mUriStr;
 
     /**
      * Initially null, created on-demand for each thread from mUriStr.
      */
     private final ThreadLocal<Uri> mParsedUri = new ThreadLocal<>();
 
     /**
      * Creates an authentication domain that represents the current package, as identified
      * by the provided context's {@link Context#getPackageName() getPackageName} method.
      */
     @NonNull
     public static AuthenticationDomain getSelfAuthDomain(@NonNull Context context) {
         validate(context, notNullValue(), IllegalArgumentException.class);
 
-        PackageManager pm = context.getPackageManager();
         String packageName = context.getPackageName();
-        PackageInfo packageInfo;
-        try {
-            packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
-        } catch (PackageManager.NameNotFoundException e) {
+        AuthenticationDomain authenticationDomain = fromPackageName(context, packageName);
+        if (null == authenticationDomain) {
             throw new IllegalStateException("Unable to find package info for " + packageName);
         }
 
-        return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
+        return authenticationDomain;
     }
 
     /**
-     * Creates the list of all authentication domains that represent the specified package.
-     * The list will contain a distinct entry for every signature related to the application.
+     * Returns the {@link AuthenticationDomain} for the application installed on the current device
+     * associated with the given package name otherwise {@code null}.
      */
-    @NonNull
-    public static List<AuthenticationDomain> listForPackage(
+    @Nullable
+    public static AuthenticationDomain fromPackageName(
             @NonNull Context context,
-            @Nullable String packageName) {
+            @NonNull String packageName) {
         validate(context, notNullValue(), IllegalArgumentException.class);
+        validate(packageName, notNullOrEmptyString(), IllegalArgumentException.class);
 
         PackageManager pm = context.getPackageManager();
         PackageInfo packageInfo;
-        if (TextUtils.isEmpty(packageName)) {
-            return Collections.emptyList();
-        }
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
-        } catch (PackageManager.NameNotFoundException e) {
-            return Collections.emptyList();
+        } catch (PackageManager.NameNotFoundException ex) {
+            return null;
         }
 
-        ArrayList<AuthenticationDomain> authDomains =
-                new ArrayList<>(packageInfo.signatures.length);
-        for (Signature signature : packageInfo.signatures) {
-            authDomains.add(createAndroidAuthDomain(packageName, signature));
+        if (1 != packageInfo.signatures.length) {
+            Log.w(TAG,
+                    String.format(
+                            "application (%s) did not have exactly one signature",
+                            packageName));
+            return null;
         }
 
-        return authDomains;
+        return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
     }
 
     /**
      * Creates an Android authentication domain (of form {@code android://SIGNATURE@PACKAGE}),
      * given the provided package name and signature.
      */
     @NonNull
-    public static AuthenticationDomain createAndroidAuthDomain(
+    static AuthenticationDomain createAndroidAuthDomain(
             @NonNull String packageName,
             @NonNull Signature signature) {
         validate(packageName, notNullOrEmptyString(), IllegalArgumentException.class);
         validate(signature, notNullValue(), IllegalArgumentException.class);
 
         return new AuthenticationDomain(
                 new Uri.Builder()
                         .scheme(SCHEME_ANDROID)
                         .encodedAuthority(generateSignatureHash(signature) + "@" + packageName)
                         .build()
                         .toString());
     }
 
     /**
      * Creates an authentication domain from its protocol buffer equivalent, in byte form.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     @NonNull
     public static AuthenticationDomain fromProtobufBytes(@NonNull byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.AuthenticationDomain.parseFrom(protobufBytes));
         } catch (IOException ex) {
             throw new MalformedDataException("Unable to parse the given protocol buffer", ex);
         }
     }
 
     /**
      * Creates an authentication domain from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     @NonNull
     public static AuthenticationDomain fromProtobuf(
             @NonNull Protobufs.AuthenticationDomain authDomain) throws MalformedDataException {
         validate(authDomain, notNullValue(), MalformedDataException.class);
 
         try {
             return new AuthenticationDomain(authDomain.getUri());
         } catch (IllegalArgumentException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     @NonNull
     static String generateSignatureHash(@NonNull Signature signature) {
         try {
             MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_512);
             byte[] hashBytes = digest.digest(signature.toByteArray());
             return Base64.encodeToString(hashBytes, Base64.URL_SAFE).replace("\n", "");
         } catch (NoSuchAlgorithmException e) {
             throw new IllegalStateException(
                     "Platform does not support" + DIGEST_SHA_512 + " hashing");
         }
     }
 
     /**
      * Creates an authentication domain from the provided String representation. If the string
      * provided is not a valid authentication domain, an {@link IllegalArgumentException}
      * will be thrown.
      */
     public AuthenticationDomain(@NonNull String authDomainString) {
         mUriStr = validate(
                 authDomainString,
                 isValidAuthenticationDomain(),
                 IllegalArgumentException.class);
     }
 
     /**
      * Determines whether the authentication domain refers to an Android application.
      */
     public boolean isAndroidAuthDomain() {
         return SCHEME_ANDROID.equals(getParsedUri().getScheme());
     }
 
     /**
      * Determines whether the authentication domain refers to a Web domain.
      */
     public boolean isWebAuthDomain() {
         Uri parsedUri = getParsedUri();
         return SCHEME_HTTP.equals(parsedUri.getScheme())
                 || SCHEME_HTTPS.equals(parsedUri.getScheme());
     }
 
     /**
      * Retrieves the Android package name from the authentication domain. If the authentication
      * domain does not represent an Android application, an {@link IllegalStateException} will
      * be thrown.
      */
     @NonNull
     public String getAndroidPackageName() {
         if (!isAndroidAuthDomain()) {
             throw new IllegalStateException("Authentication domain is not an Android domain");
         }
         return getParsedUri().getHost();
     }
 
     /**
      * Creates a protocol buffer representation of the authentication domain, for transmission
      * or storage.
      */
     public Protobufs.AuthenticationDomain toProtobuf() {
         return Protobufs.AuthenticationDomain.newBuilder()
                 .setUri(mUriStr)
                 .build();
     }
 
     /**
      * Retrieves the string form of the authentication domain.
      */
     @NonNull
     public String toString() {
         return mUriStr;
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (!(obj instanceof AuthenticationDomain)) {
             return false;
         }
 
         return compareTo((AuthenticationDomain) obj) == 0;
     }
 
     @Override
     public int hashCode() {
         return mUriStr.hashCode();
     }
 
     @Override
     public int compareTo(@NonNull AuthenticationDomain authenticationDomain) {
         return mUriStr.compareTo(authenticationDomain.mUriStr);
     }
 
     private Uri getParsedUri() {
         Uri parsedUri = mParsedUri.get();
         if (parsedUri == null) {
             parsedUri = Uri.parse(mUriStr);
             mParsedUri.set(parsedUri);
         }
 
         return parsedUri;
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
index 06d5da4..7c5a569 100644
--- a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
+++ b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
@@ -40,202 +40,202 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link AuthenticationDomain}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AuthenticationDomainTest {
 
     private static final String WEB_AUTH_DOMAIN_STR = "https://www.example.com";
 
     private static final String VALID_PACKAGE_NAME = "com.example.app";
 
     private static byte[] VALID_SIGNATURE_BYTES = new byte[]
             { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
     private static final String VALID_FINGERPRINT =
             "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                     + "7V4Lo8BdCxaA307H0HYkAw==";
 
     private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
             "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
 
     private static final PackageInfo VALID_PACKAGE_INFO = makeValidPackageInfo();
 
     private static PackageInfo makeValidPackageInfo() {
         PackageInfo packageInfo = new PackageInfo();
-        packageInfo.signatures = new Signature[2];
+        packageInfo.signatures = new Signature[1];
         packageInfo.signatures[0] = new Signature(VALID_SIGNATURE_BYTES);
-        packageInfo.signatures[1] = new Signature(new byte[16]);
 
         return packageInfo;
     }
 
     private static final class ValidAuthDomain {
         private static final String VALID_PACKAGE_NAME = "com.example.app";
         private static final String VALID_FINGERPRINT =
                 "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                         + "7V4Lo8BdCxaA307H0HYkAw==";
 
         private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
                 "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
         public static final AuthenticationDomain INSTANCE =
                 new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Mock
     PackageManager mockPackageManager;
     @Mock
     Context mockContext;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenReturn(VALID_PACKAGE_INFO);
         when(mockContext.getPackageName()).thenReturn(VALID_PACKAGE_NAME);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
     }
 
     @Test
     public void fromProtobufBytes_withValidInput_returnsEquivalent() throws Exception {
         byte[] encodedAuthDomain = ValidAuthDomain.INSTANCE.toProtobuf().toByteArray();
 
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.fromProtobufBytes(encodedAuthDomain);
 
         assertThat(authenticationDomain).isEqualTo(ValidAuthDomain.INSTANCE);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_withMalformedBytes_throwsMalformedDataException() throws Exception {
         AuthenticationDomain.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_withInvalidUri_throwsInvalidProtoBufferException() throws Exception {
         byte[] invalidProtoBytes =
                 Protobufs.AuthenticationDomain.newBuilder()
                         .setUri("Invalid uri")
                         .build()
                         .toByteArray();
 
         AuthenticationDomain.fromProtobufBytes(invalidProtoBytes);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_withInvalidUri_throwsInvalidProtoBufferException() throws Exception {
         Protobufs.AuthenticationDomain invalidProto =
             Protobufs.AuthenticationDomain.newBuilder()
                 .setUri("Invalid uri")
                 .build();
 
         AuthenticationDomain.fromProtobuf(invalidProto);
     }
 
     @Test
     public void getSelfAuthDomain_withValidInput_returnsValidDomain() throws Exception {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain).isNotNull();
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.toString())
                 .isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test
-    public void listForPackage_forValidPackage_containsValidAuthenticationDomain() {
-        assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME))
-                .contains(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
+    public void fromPackageName_forValidPackage_containsValidAuthenticationDomain() {
+        assertThat(AuthenticationDomain.fromPackageName(mockContext, VALID_PACKAGE_NAME))
+                .isEqualTo(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
     }
 
     @Test
-    public void listForPackage_forNullPackageName_returnsEmpty() throws Exception {
-        assertThat(AuthenticationDomain.listForPackage(mockContext, null /* package */)).isEmpty();
+    public void fromPackageName_packageDoesNotExist_returnsNull() throws Exception {
+        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
+                .thenThrow(NameNotFoundException.class);
+
+        assertThat(AuthenticationDomain.fromPackageName(mockContext, VALID_PACKAGE_NAME)).isNull();
     }
 
     @Test
-    public void listForPackage_packageDoesNotExist_returnsEmpty() throws Exception {
+    public void fromPackageName_hasMultipleSignatures_returnsNull() throws Exception {
+        PackageInfo packageInfo = new PackageInfo();
+        packageInfo.signatures = new Signature[2];
+
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
-                .thenAnswer(new Answer<PackageInfo>() {
-                    @Override
-                    public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
-                        throw new NameNotFoundException();
-                    }
-                });
-
-        assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME)).isEmpty();
+                .thenReturn(packageInfo);
+
+        assertThat(AuthenticationDomain.fromPackageName(mockContext, VALID_PACKAGE_NAME)).isNull();
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void CreateAndroidAuthDomain_withNullDomain_throwsIllegalArgumentException()
             throws Exception{
         AuthenticationDomain.createAndroidAuthDomain(null /* authDomain */, mock(Signature.class));
     }
 
     @Test
     public void validWebAuthDomain_hasExpectedBehaviour() {
         AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
 
         assertThat(authDomain.isAndroidAuthDomain()).isFalse();
         assertThat(authDomain.isWebAuthDomain()).isTrue();
 
         try {
             authDomain.getAndroidPackageName();
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void validAndroidAuthDomain_hasExpectedBehaviour(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.isWebAuthDomain()).isFalse();
 
         assertThat(authDomain.getAndroidPackageName()).isEqualTo(VALID_PACKAGE_NAME);
     }
 
     @Test
     public void getSelfAuthDomain_packageNotFoundException_throwsException() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
             .thenAnswer(new Answer<PackageInfo>() {
                 @Override
                 public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                     throw new NameNotFoundException();
                 }
             });
 
         try {
             AuthenticationDomain.getSelfAuthDomain(mockContext);
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void equals_withEquivalent_returnsTrue() throws Exception {
         AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mockContext);
         AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomainA).isEqualTo(authDomainA);
         assertThat(authDomainA).isEqualTo(authDomainB);
 
         assertThat(authDomainA.compareTo(authDomainB)).isEqualTo(0);
     }
 
     @Test
     public void equals_withDifferentType_returnsFalse() throws Exception {
         AuthenticationDomain domain = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
         assertThat(domain).isNotEqualTo(WEB_AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testHashCode_equivalent() throws Exception {
         AuthenticationDomain authDomainA = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
         AuthenticationDomain authDomainB = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
 
         assertThat(authDomainA.hashCode()).isEqualTo(authDomainB.hashCode());
     }
 
 }
diff --git a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
index 86a57d3..a0ae2e3 100644
--- a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
+++ b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
@@ -29,50 +29,49 @@ import org.openyolo.protocol.MalformedDataException;
 /**
  * Partial implementation of an OpenYOLO request receiver, that should be extended by providers.
  * This implementation handles some basic validation and decoding of the request before
  * handing the request to
  * {@link #processCredentialRequest(Context, BroadcastQuery, CredentialRetrieveRequest, Set)}.
  */
 public abstract class BaseCredentialQueryReceiver extends BaseBroadcastQueryReceiver {
 
     /**
      * Creates a receiver that will log errors to the specified log tag.
      */
     public BaseCredentialQueryReceiver(String logTag) {
         super(logTag);
     }
 
     @Override
     protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
 
         CredentialRetrieveRequest request;
         try {
             byte[] encodedProto = query.getQueryMessage().toByteArray();
             request = CredentialRetrieveRequest.fromProtobufBytes(encodedProto);
         } catch (MalformedDataException ex) {
             Log.w(mLogTag, "Credential request message failed field validation", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
-        // TODO: validate claimed authentication domains
-        Set<AuthenticationDomain> requestorDomains =
-                new HashSet<>(AuthenticationDomain.listForPackage(
-                    context,
-                    query.getRequestingApp()));
+        AuthenticationDomain requestorAuthDomain =
+                AuthenticationDomain.fromPackageName(context, query.getRequestingApp());
 
         // Ensure the authentication domain of the requesting app can be determined
-        if (requestorDomains.isEmpty()) {
+        if (null == requestorAuthDomain) {
             Log.w(mLogTag, "Unable to determine the authentication domain of the requesting app");
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
-        processCredentialRequest(context, query, request, requestorDomains);
+        HashSet<AuthenticationDomain> authenticationDomains = new HashSet<>();
+        authenticationDomains.add(requestorAuthDomain);
+        processCredentialRequest(context, query, request, authenticationDomains);
     }
 
     protected abstract void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains);
 }
diff --git a/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java b/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
index b0414f1..a685263 100644
--- a/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
+++ b/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
@@ -24,2 +24,3 @@ import android.util.Log;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
@@ -31,172 +32,178 @@ import org.openyolo.spi.assetlinks.data.AssetStatement;
 /**
  * <p>
  * This class loads the {@link AuthenticationDomain}s for the 'source'
  * (client) and 'target' asset statements and finds the ones that are bidirectional.  That is,
  * where the source and target apps grant the same relations to each other.
  * </p>
  *
  * <p>Example for looking-up bidirectional relationships:</p>
  *
  * <pre>
  * {@code
  *
  * private void loadRelatedAuthDomains(Context context, String requestedAppPackage) {
  *      // get the asset statements for the requesting/client app
  *      List<AssetStatement> sourceAssetStatements = getSourceAssetStatements
  *               (context, requestedAppPackage);
  *
  *      TargetAssetStatementLoader assetStatementLoader = new
  *               TargetAssetStatementLoader(context, sourceAssetStatements);
  *
  *      // get all 'related' target asset statements - those referenced in the client app's
  *      // asset statements
  *      List<AssetStatement> targetAssetStatements = assetStatementLoader
  *               .getRelatedAssetStatements();
  *
  *      AssetRelationshipHelper assetRelationshipHelper = new
  *               AssetRelationshipHelper(context, requestedAppPackage, sourceAssetStatements,
  *                targetAssetStatements);
  *
  *      List<AuthenticationDomain> bidirectionalAuthDomains =
  *               assetRelationshipHelper.getBidirectionalAuthDomains();
  * }
  *
  * private List<AssetStatement> getSourceAssetStatements(Context context, String packageName) {
  *      String clientAssetStatements = AssetStatementsUtil.getAssetStatements(context,
  *               packageName);
  *      return parseAssetStatementsJson(clientAssetStatements);
  * }
  *
  * private List<AssetStatement> parseAssetStatementsJson(String json) {
  *      return AssetStatementsFactory.INSTANCE.createAssetStatements(json);
  * }
  *}
  * </pre>
  */
 public class AssetRelationshipHelper {
     private static final String TAG = "AssetRelationshipHelper";
 
     private final Context mContext;
     private final String mClientPackageName;
     private final List<AssetStatement> mSourceAssetStatements;
     private final List<AssetStatement> mTargetAssetStatements;
 
     /**
      * Setup the helper and validate the input params.
      *
      * @param context Context
      * @param clientPackageName The client app's package name
      * @param sourceAssetStatements Asset statements from the 'source' (client) app
      * @param targetAssetStatements Asset statements from the various 'targets' referenced by the
      *     'source' (client) app
      */
     public AssetRelationshipHelper(@NonNull Context context, @NonNull String clientPackageName,
                 @NonNull List<AssetStatement> sourceAssetStatements, @NonNull List<AssetStatement>
                 targetAssetStatements) {
 
         require(context, notNullValue());
         require(!TextUtils.isEmpty(clientPackageName), "mClientPackageName must not be null or "
                     + "empty");
         require(sourceAssetStatements, notNullValue());
         require(targetAssetStatements, notNullValue());
 
         this.mContext = context.getApplicationContext();
         this.mClientPackageName = clientPackageName;
         this.mSourceAssetStatements = sourceAssetStatements;
         this.mTargetAssetStatements = targetAssetStatements;
     }
 
     /**
      * <p>
      * Load the asset statements for the client app.  Load the asset statements for each Android
      * 'target' in the client app's asset statements.  Return the of
-     * {@link org.openyolo.api.AuthenticationDomain}s that have bidirectional relationships with
-     * the client app.
+     * {@link org.openyolo.protocol.AuthenticationDomain}s that have bidirectional relationships
+     * with the client app.
      * </p>
      * <p>
      * Note, this currently only supports Android 'target' asset statements.
      * </p>
      *
      * @return Authentication domains that have a bidirectional relationship with the client
      *     Android app
      */
     public List<AuthenticationDomain> getBidirectionalAuthDomains() {
         if (mSourceAssetStatements.isEmpty() || mTargetAssetStatements.isEmpty()) {
             return Collections.emptyList();
         }
 
         final List<AuthenticationDomain> bidirectionalAuthDomains = new ArrayList<>();
 
         bidirectionalAuthDomains.addAll(getBidirectionalAuthDomains
                     (getTargetAndroidAssetStatements()));
 
         // TODO load authentication domains for web targets
 
         return bidirectionalAuthDomains;
     }
 
     private List<AuthenticationDomain> getBidirectionalAuthDomains(
                 final List<AndroidAssetStatement> androidAssetStmts) {
         final List<AuthenticationDomain> authDomains = new ArrayList<>();
         for (AndroidAssetStatement androidAssetStmt : androidAssetStmts) {
             authDomains.addAll(getBidirectionalAuthDomains(androidAssetStmt));
         }
         // TODO remove before released
         Log.d(TAG, "Android bidirectional auth domains: " + authDomains);
         return authDomains;
     }
 
     /**
      * Filter out any authentication domains from the target apps that aren't in the requestor
      * domains, leaving us with the authentication domains that have bidirectional
      * credential sharing relationships.
      *
      * @param targetAssetStatement Asset statement of the 'target' app
      */
     private List<AuthenticationDomain> getBidirectionalAuthDomains(final AndroidAssetStatement
                 targetAssetStatement) {
 
         // get the AuthenticationDomains for the source (client) app
         final List<AuthenticationDomain> sourceAuthDomains = createAuthDomains(
                     mClientPackageName);
 
         // get the AuthenticationDomains for app identified in the (target) android asset statement
         final List<AuthenticationDomain> targetAuthDomains = createAuthDomains(
                     targetAssetStatement);
 
         // filter out of the 'target' auth domains any AuthenticationDomains not in the
         // 'source' auth domains
         targetAuthDomains.retainAll(sourceAuthDomains);
 
         // TODO remove before released
         Log.d(TAG, "bidirectional auth domains for target pkg '" + mClientPackageName + "' and "
                     + "source pkg '" + targetAssetStatement.getTarget().getPackageName() + "': "
                     + targetAuthDomains);
 
         return targetAuthDomains;
     }
 
     /**
      * Returns a list of all the {@link org.openyolo.spi.assetlinks.data.AndroidAssetStatement}s in
      * {@link #mTargetAssetStatements}.
      */
     private List<AndroidAssetStatement> getTargetAndroidAssetStatements() {
         List<AndroidAssetStatement> androidAssetStatements = new ArrayList<>();
         for (AssetStatement assetStatement : mTargetAssetStatements) {
             if (assetStatement instanceof AndroidAssetStatement) {
                 androidAssetStatements.add((AndroidAssetStatement) assetStatement);
             }
         }
         return androidAssetStatements;
     }
 
     private List<AuthenticationDomain> createAuthDomains(
                 final AndroidAssetStatement androidAssetStatement) {
         return createAuthDomains(androidAssetStatement.getTarget().getPackageName());
     }
 
     private List<AuthenticationDomain> createAuthDomains(
                 final String packageName) {
-        return AuthenticationDomain.listForPackage(mContext, packageName);
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.fromPackageName(mContext, packageName);
+        if (null == authenticationDomain) {
+            return Collections.EMPTY_LIST;
+        }
+
+        return Arrays.asList(authenticationDomain);
     }
 }
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
index eb64e86..136024f 100644
--- a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -22,3 +22,2 @@ import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.isNull;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -32,6 +31,4 @@ import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.protobuf.ByteString;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
 import java.util.Set;
+
 import org.junit.Before;
@@ -45,2 +42,3 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.Protobufs;
+import org.openyolo.spi.Constants.ValidApplication;
 import org.robolectric.RobolectricTestRunner;
@@ -49,154 +47,144 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link BaseCredentialQueryReceiver}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE,
         shadows = {
                 ShadowQueryResponseSender.class,
                 ShadowAuthenticationDomain.class
         })
 public class BaseCredentialQueryReceiverTest {
 
     private BaseCredentialQueryReceiver credentialQueryReceiver;
 
     @Mock
     Context mockContext;
 
-    private static final String CALLING_PACKAGE_NAME = "org.openyolo.supercoolapp";
-
     private static final BroadcastQuery QUERY_WITH_NULL_MESSAGE =
             makeQueryFromRequest(null /* request */);
 
     private static final BroadcastQuery QUERY_WITH_INVALID_REQUEST =
             makeQueryFromRequest(makeInvalidCredentialRetrieveRequest());
 
     private static final BroadcastQuery QUERY_WITH_VALID_REQUEST =
             makeQueryFromRequest(makeValidCredentialRetrieveRequest());
 
-    private static final List<AuthenticationDomain> VALID_AUTHENTICATION_DOMAINS =
-            makeValidAuthenticationDomains();
-
-
     private static BroadcastQuery makeQueryFromRequest(
             @Nullable Protobufs.CredentialRetrieveRequest request) {
         BroadcastQuery.Builder builder = BroadcastQuery.newBuilder()
-                .setRequestingApp(CALLING_PACKAGE_NAME)
+                .setRequestingApp(ValidApplication.PACKAGE_NAME)
                 .setDataType("blah")
                 .setRequestId(101L)
                 .setResponseId(102L);
 
         if (request != null) {
             builder.setQueryMessage(ByteString.copyFrom(request.toByteArray()));
         }
 
         return builder.build();
     }
 
-    private static List<AuthenticationDomain> makeValidAuthenticationDomains() {
-        List<AuthenticationDomain> authenticationDomains = new ArrayList<>();
-        authenticationDomains.add(mock(AuthenticationDomain.class));
-
-        return authenticationDomains;
-    }
-
     private static Protobufs.CredentialRetrieveRequest makeInvalidCredentialRetrieveRequest() {
         // Invalid because it does not specify a non-empty set of authentication method
         return Protobufs.CredentialRetrieveRequest.newBuilder().build();
     }
 
     private static Protobufs.CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
             .addAuthMethods(new AuthenticationMethod("custom://one").toProtobuf())
             .addAuthMethods(new AuthenticationMethod("custom://two").toProtobuf())
             .build();
     }
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         ShadowQueryResponseSender.intializeForTest();
 
         credentialQueryReceiver = spy(
                 new BaseCredentialQueryReceiver("TestCredentialQueryReceiver") {
                     @Override
                     protected void processCredentialRequest(
                             @NonNull Context context,
                             @NonNull BroadcastQuery query,
                             @NonNull CredentialRetrieveRequest request,
                             @NonNull Set<AuthenticationDomain> requestorDomains) {
                         // Do nothing
                     }
                 });
 
-        ShadowAuthenticationDomain.setListForPackageResponse(VALID_AUTHENTICATION_DOMAINS);
+        // ShadowAuthenticationDomain.(VALID_AUTHENTICATION_DOMAINS);
+        ShadowAuthenticationDomain.reset();
     }
 
     @Test
     public void processQuery_withNullQuery_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_NULL_MESSAGE);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withInvalidRequest_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_INVALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withValidRequest_processesRequest() throws Exception {
+        ShadowAuthenticationDomain.setAuthDomainForPackage(
+                ValidApplication.PACKAGE_NAME,
+                ValidApplication.AUTHENTICATION_DOMAIN);
+
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasCalled();
         verifyQueryResponseIsNotSent();
     }
 
     @Test
     public void processQuery_withValidRequestAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
             throws Exception {
-        ShadowAuthenticationDomain.setListForPackageResponse(
-                Collections.<AuthenticationDomain>emptyList());
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     private void verifyQueryResponseIsNotSent() {
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(0))
                 .sendResponse((BroadcastQuery) any(), (byte[]) any());
     }
 
     private void verifyQueryResponseIsSentWith(@Nullable byte[] response) {
         if (null == response) {
             verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                     .sendResponse((BroadcastQuery) any(), (byte[]) isNull());
             return;
         }
 
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                 .sendResponse((BroadcastQuery) any(), eq(response));
     }
 
     private void verifyProcessCredentialRequestWasCalled() {
         verify(credentialQueryReceiver, times(1))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (CredentialRetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 
     private void verifyProcessCredentialRequestWasNotCalled() {
         verify(credentialQueryReceiver, times(0))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (CredentialRetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/Constants.java b/spi/javatests/java/org/openyolo/spi/Constants.java
new file mode 100644
index 0000000..47551b2
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/Constants.java
@@ -0,0 +1,18 @@
+package org.openyolo.spi;
+
+import org.openyolo.protocol.AuthenticationDomain;
+
+/** Collection of test constants. */
+public final class Constants {
+    private Constants() {}
+
+    public static final class ValidApplication {
+        private ValidApplication() {}
+
+        public static String PACKAGE_NAME = "com.super.cool.app";
+
+        private static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
+        public static AuthenticationDomain AUTHENTICATION_DOMAIN =
+                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java b/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
index 4136fdf..6c4052d 100644
--- a/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
+++ b/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
@@ -4,5 +4,6 @@ import android.content.Context;
 import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import java.util.Collections;
-import java.util.List;
+
+import java.util.HashMap;
+import java.util.Map;
+
 import org.openyolo.protocol.AuthenticationDomain;
@@ -10,22 +11,25 @@ import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 
 /**
- * Shadow for {@link AuthenticationDomain}
+ * Shadow for {@link AuthenticationDomain}.
  */
 @Implements(AuthenticationDomain.class)
 public class ShadowAuthenticationDomain {
 
-    private static List<AuthenticationDomain> authenticationDomains = Collections.EMPTY_LIST;
+    private static Map<String, AuthenticationDomain> sAuthDomainLookup = new HashMap<>();
+
+    public static void reset() {
+        sAuthDomainLookup.clear();
+    }
 
-    public static void setListForPackageResponse(
-            List<AuthenticationDomain> authenticationDomainsResponse) {
-        authenticationDomains = authenticationDomainsResponse;
+    public static void setAuthDomainForPackage(String packageName, AuthenticationDomain authDomain) {
+        sAuthDomainLookup.put(packageName, authDomain);
     }
 
     @Implementation
-    public static List<AuthenticationDomain> listForPackage(
+    public static AuthenticationDomain fromPackageName(
             @NonNull Context context,
-            @Nullable String packageName) {
-        return authenticationDomains;
+            @NonNull String packageName) {
+        return sAuthDomainLookup.get(packageName);
     }
 }

commit 594e5c1db6fec47dd8a464f82022ecdb3f4c1555
Author: David Samuelson <hello@dsamuelson.com>
Date:   Sun Aug 20 18:31:37 2017 -0700

    Catch and log IllegalArgumentExceptions for the save operation in the test app instead crashing.

diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index efc7647..510855b 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -20,2 +20,3 @@ import android.support.annotation.StringRes;
 import android.support.design.widget.Snackbar;
+import android.util.Log;
 import android.view.LayoutInflater;
@@ -32,89 +33,98 @@ import org.openyolo.protocol.CredentialSaveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
 public final class SaveTestPageFragment extends TestPageFragment {
 
+    private static final String TAG = "SaveTestPageFragment";
     private static final int RC_SAVE = 0;
 
     @BindView(R.id.save_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Save";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.save_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.save_button)
     void onSave() {
-        final Credential credential = mCredentialView.makeCredentialFromFields();
-        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(credential);
+        CredentialSaveRequest request;
+        try {
+            Credential credential = mCredentialView.makeCredentialFromFields();
+            request = CredentialSaveRequest.fromCredential(credential);
+        } catch (IllegalArgumentException ex) {
+            Log.e(TAG, "Invalid argument: " + ex);
+            showSnackbar(R.string.save_invalid_request);
+            return;
+        }
+
         final Intent saveIntent = mApi.getSaveIntent(request);
 
         if (saveIntent == null) {
             showSnackbar(R.string.no_available_save_providers);
             return;
         }
 
         startActivityForResult(saveIntent, RC_SAVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_SAVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialSaveResult result = mApi.getCredentialSaveResult(data);
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 resultMessageId = R.string.save_result_saved;
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.save_result_bad_request;
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 resultMessageId = R.string.save_result_provider_refused;
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.save_result_user_canceled;
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 resultMessageId = R.string.save_result_user_refused;
                 break;
             default:
-                resultMessageId = R.string.save_result_unkown;
+                resultMessageId = R.string.save_result_unknown;
         }
 
         showSnackbar(resultMessageId);
     }
 }
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index b097628..ef55078 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,103 +1,106 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
     <string name="phone_authentication_method_checkbox_text">openyolo://phone</string>
     <string name="username_authentication_method_checkbox_text">openyolo://username</string>
 
     <string name="require_user_mediation_checkbox_text">Require User Mediation</string>
     <string name="retrieve_other_section_title">Other</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
-    <string name="save_result_unkown">Unknown save result</string>
+
+    <string name="save_invalid_request">Invalid Save Request</string>
+
+    <string name="save_result_unknown">Unknown save result</string>
     <string name="save_result_saved">Credential Saved</string>
     <string name="save_result_bad_request">Malformed save request</string>
     <string name="save_result_provider_refused">Provider refused save request</string>
     <string name="save_result_user_canceled">User canceled save request</string>
     <string name="save_result_user_refused">User refused save request</string>
 
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
     <string name="no_available_delete_providers">"No available providers can delete this credential</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
     <string name="delete_result_unknown_response">Unknown delete response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
 
     <!-- Other Test -->
     <string name="disable_auto_sign_in_button_label">Disable Auto Sign In</string>
     <string name="disable_auto_sign_in_button_content_description">Disable Auto Sign In</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response Properties</string>
     <string name="request">Request Properties</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
   <string name="token_providers_header">Supported token providers</string>
     <string name="use_google_token_provider">Request Google ID tokens</string>
     <string name="token_provider_uri_field_hint">Token provider URI</string>
     <string name="client_id_field_hint">Client ID</string>
     <string name="nonce_field_hint">Nonce</string>
     <string name="clear_token_provider">Clear</string>
     <string name="no_token">No token returned</string>
     <string name="id_token_view_header">ID Token</string>
 
 </resources>

commit f310019ef98997f7892f88fb96d64d36c572aac3
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue Aug 22 13:32:02 2017 -0700

    Changed the last of the camel case proto definitions to use an (#74)
    
    underscore delimited format.
    
    Fixed https://github.com/openid/OpenYOLO-Android/issues/34

diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index 8fc23b6..a48d754 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -35,4 +35,4 @@ message CredentialRetrieveRequest {
 message CredentialRetrieveBbqResponse {
-    bytes retrieveIntent = 1;
-    map<string, bytes> additionalProps = 2;
+    bytes retrieve_intent = 1;
+    map<string, bytes> additional_props = 2;
 }

commit 533d5c0d1d8fce0d76ad0de7a579ca70fe758069
Author: David Samuelson <hello@dsamuelson.com>
Date:   Sun Aug 20 17:27:04 2017 -0700

    Added fix for https://github.com/openid/OpenYOLO-Android/issues/49

diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 19cffe9..c0b9d04 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -32,257 +32,258 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the user selected a hint, that has been returned as part of this response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws MalformedDataException {
         validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
             throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          * @throws MalformedDataException if the given protocol buffer was invalid.
          */
         private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setCredentialFromProto(proto.getCredential());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
                 throws MalformedDataException {
-            if (!Protobufs.Credential.getDefaultInstance().equals(credential)) {
-                mCredential = Credential.fromProtobuf(credential);
-            } else {
+            if (null == credential
+                    || Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = null;
+            } else {
+                mCredential = Credential.fromProtobuf(credential);
             }
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
index 493ecdf..cf4b39e 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -33,257 +33,257 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
  * of the request, and the response may contain a hint.
  */
 public final class HintRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN = ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the hint request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST = ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the user selected a hint, that has been returned as part of this response.
      */
     public static final int CODE_HINT_SELECTED = ResultCode.HINT_SELECTED_VALUE;
 
     /**
      * Indicates that no hints are available that meet the requirements of the hint request.
      */
     public static final int CODE_NO_HINTS_AVAILABLE = ResultCode.NO_HINTS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user  canceled the selection of a hint in a manner that indicates they
      * wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that The user canceled the selection of a hint in a manner that indicates they do
      * not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED = ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built hint result for an unspecified outcome. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult UNKNOWN =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_UNKNOWN).build();
 
     /**
      * Pre-built hint result for a bad request. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult BAD_REQUEST =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built hint result for when no hints are available. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult NO_HINTS_AVAILABLE =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_NO_HINTS_AVAILABLE).build();
 
     /**
      * Pre-built hint result for when the user requests manual authentication. Carries no hint
      * or additional properties.
      */
     public static final HintRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH)
                     .build();
 
     /**
      * Pre-built hint result for when the user canceled the selection of a hint in a manner that
      * indicates they do not wish to authenticate at this time. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult USER_CANCELED =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_USER_CANCELED).build();
 
     /**
      * Creates a hint result from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto)
             throws MalformedDataException {
         return new HintRetrieveResult.Builder(proto).build();
     }
 
     /**
      * Creates a hint result from its protocol buffer equivalent, in byte array form.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobufBytes(byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Hint mHint;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private HintRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mHint = builder.mHint;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint retrieve result, for transmission or
      * storage.
      */
     public Protobufs.HintRetrieveResult toProtobuf() {
         Protobufs.HintRetrieveResult.Builder builder =
                 Protobufs.HintRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mHint != null) {
             builder.setHint(mHint.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this hint retrieve result, that a provider should
      * return as its hint activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_HINT_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * The hint retrieve result code.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The hint returned as part of the hint result, if available.
      */
     @Nullable
     public Hint getHint() {
         return mHint;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * hint result, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link HintRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @Nullable
         private Hint mHint;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a hint retrieve result, based on the properties
          * contained in the provided protocol buffer.
          */
         private Builder(@NonNull Protobufs.HintRetrieveResult proto) throws MalformedDataException {
             validate(proto, notNullValue(), MalformedDataException.class);
 
             try {
                 setResultCode(proto.getResultCodeValue());
                 setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
                 setHintFromProto(proto.getHint());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a hint retrieve result, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the returned hint, if available.
          */
         public Builder setHint(@Nullable Hint hint) {
             mHint = hint;
             return this;
         }
 
         private Builder setHintFromProto(@Nullable Protobufs.Hint hint)
                 throws MalformedDataException {
-            if (null == hint) {
+            if (null == hint || Protobufs.Hint.getDefaultInstance().equals(hint)) {
                 mHint = null;
             } else {
                 mHint = Hint.fromProtobuf(hint);
             }
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. A null map is treated as an empty map. For a non-null map, all keys and values
          * must not be null, and the keys must not be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the hint retrieve result, from the specified properties.
          */
         public HintRetrieveResult build() {
             return new HintRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
index af7766e..ac294e2 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
@@ -32,93 +32,101 @@ import org.robolectric.annotation.Config;
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveResultTest {
 
     private static final String ALICE_ID = "alice@example.com";
     private static final Hint HINT =
             new Hint.Builder(
                     ALICE_ID,
                     AuthenticationMethods.EMAIL)
                     .build();
 
     @Test
     public void build() {
 
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isSameAs(HINT);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void buildSetHint_nullValue() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setHint(null)
                 .build();
 
         assertThat(result.getHint()).isNull();
     }
 
+    @Test
+    public void fromProtobuf_withDefaultInstanceOfHint_doesNotThrowException() throws Exception {
+        Protobufs.HintRetrieveResult hintRetrieveResult =
+                Protobufs.HintRetrieveResult.newBuilder().build();
+
+        HintRetrieveResult.fromProtobuf(hintRetrieveResult);
+    }
+
     @Test
     public void buildSetAdditionalProperties() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         assertThat(result.getAdditionalProperties()).hasSize(1);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toProtobuf() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         Protobufs.HintRetrieveResult proto = result.toProtobuf();
         assertThat(proto.getResultCodeValue()).isEqualTo(ResultCode.HINT_SELECTED_VALUE);
         assertThat(proto.hasHint());
         checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
     }
 
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.HintRetrieveResult proto = Protobufs.HintRetrieveResult.newBuilder()
                 .setResultCode(ResultCode.HINT_SELECTED)
                 .setHint(Protobufs.Hint.newBuilder()
                         .setId(ALICE_ID)
                         .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf()))
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         HintRetrieveResult result = HintRetrieveResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isNotNull();
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toResultIntentData() throws Exception {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         Intent intent = result.toResultDataIntent();
         assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
         byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
 
         HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
         assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(readResult.getHint()).isNotNull();
         checkAdditionalProps(readResult.getAdditionalProperties());
     }
 }

commit de74e99ff744421f7123e0e5f8359e97e25dd967
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue Aug 22 13:00:35 2017 -0700

    Added support for CredentialClient.disableAutoSignIn() (#70)
    
    - Added consistent line ending check
    - Bumped Gradle version

diff --git a/api/build.gradle b/api/build.gradle
index a4b0ea4..412078a 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -2,2 +2,3 @@ apply plugin: 'com.android.library'
 apply from:'../config/android-common.gradle'
+apply from:'../config/protobuf.gradle'
 
diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 08bfca3..5e67411 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -29,2 +29,3 @@ import static org.openyolo.protocol.ProtocolConstants.SAVE_CREDENTIAL_ACTION;
 import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -36,2 +37,3 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
 import android.util.Log;
@@ -46,3 +48,5 @@ import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
+
+import org.openyolo.api.persistence.DeviceState;
+import org.openyolo.api.persistence.internal.DeviceStateImpl;
 import org.openyolo.api.ui.ProviderPickerActivity;
@@ -64,443 +68,479 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
-    private static final AtomicReference<CredentialClient> INSTANCE_REF
-            = new AtomicReference<>();
-
     private final Context mApplicationContext;
-
     private final BroadcastQueryClient mQueryClient;
+    private final DeviceState mDeviceState;
 
     /**
-     * Retrieves the singleton credential client instance associated with the application.
+     * Returns a new credential client instance configured with the default options.
      */
-    public static CredentialClient getApplicationBoundInstance(Context context) {
-        Context applicationContext = context.getApplicationContext();
-        CredentialClient client = new CredentialClient(applicationContext);
-        if (!INSTANCE_REF.compareAndSet(null, client)) {
-            client = INSTANCE_REF.get();
-        }
+    public static CredentialClient getInstance(@NonNull Context context) {
+        CredentialClientOptions options =
+                new CredentialClientOptions.Builder(DeviceStateImpl.getInstance(context)).build();
 
-        return client;
+        return getInstance(context, options);
     }
 
-    CredentialClient(Context applicationContext) {
-        mApplicationContext = applicationContext;
-        mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
+    /**
+     * Returns a new credential client instance configured with the given
+     * {@link CredentialClientOptions}.
+     */
+    public static CredentialClient getInstance(
+            @NonNull Context context,
+            @NonNull CredentialClientOptions options) {
+        return new CredentialClient(context, BroadcastQueryClient.getInstance(context), options);
+    }
+
+    @VisibleForTesting
+    CredentialClient(
+            @NonNull Context context,
+            @NonNull BroadcastQueryClient broadcastQueryClient,
+            @NonNull CredentialClientOptions options) {
+        validate(context, notNullValue(), NullPointerException.class);
+        validate(broadcastQueryClient, notNullValue(), NullPointerException.class);
+        validate(options, notNullValue(), NullPointerException.class);
+
+        mApplicationContext = context.getApplicationContext();
+        mQueryClient = broadcastQueryClient;
+        mDeviceState = options.getDeviceState();
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
-            final CredentialRetrieveRequest request,
+            CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
+
+        if (mDeviceState.isAutoSignInDisabled()) {
+            request = new CredentialRetrieveRequest.Builder(request)
+                    .setRequireUserMediation(true)
+                    .build();
+        }
+
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
     @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             return null;
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
-            return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
+            CredentialRetrieveResult result =
+                    CredentialRetrieveResult.fromProtobufBytes(resultBytes);
+
+            // Once a successfully retrieve result has been handled, re-enable auto sign-in.
+            if (CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED == result.getResultCode()) {
+                mDeviceState.setIsAutoSignInDisabled(false);
+            }
+
+            return result;
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return createDefaultHintRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a credential save request from the intent data returned by a provider.
      */
     @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return createDefaultCredentialSaveResult();
         }
     }
 
+    /**
+     * Disables automatically signing a user until a successful response is given to
+     * {@link CredentialClient#getCredentialRetrieveResult(Intent)}.
+     */
+    public void disableAutoSignIn() {
+        mDeviceState.setIsAutoSignInDisabled(true);
+    }
+
     @NonNull
     private static CredentialSaveResult createDefaultCredentialSaveResult() {
         return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
                 .build();
     }
 
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @NonNull
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
-                KnownProviders.getApplicationBoundInstance(mApplicationContext);
+                KnownProviders.getInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/CredentialClientOptions.java b/api/java/org/openyolo/api/CredentialClientOptions.java
new file mode 100644
index 0000000..29b0d05
--- /dev/null
+++ b/api/java/org/openyolo/api/CredentialClientOptions.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Validation.validate;
+
+import android.support.annotation.NonNull;
+
+import org.openyolo.api.persistence.DeviceState;
+
+
+/**
+ * Context object that may be used to configure a {@link CredentialClient} instance.
+ */
+public class CredentialClientOptions {
+    private final DeviceState mDeviceState;
+
+    private CredentialClientOptions(Builder builder) {
+        mDeviceState = builder.mDeviceState;
+    }
+
+    @NonNull
+    DeviceState getDeviceState() {
+        return mDeviceState;
+    }
+
+    /**
+     * Builder for {@link CredentialClientOptions}.
+     */
+    public static final class Builder {
+        private DeviceState mDeviceState;
+
+        /**
+         * Default builder for {@link CredentialClientOptions}.
+         */
+        public Builder(@NonNull DeviceState deviceState) {
+            setDeviceState(deviceState);
+        }
+
+        /**
+         * Specifies the {@link DeviceState} implementation that will be used by the
+         * {@link CredentialClient}.
+         */
+        public Builder setDeviceState(@NonNull DeviceState deviceState) {
+            validate(deviceState, notNullValue(), NullPointerException.class);
+
+            this.mDeviceState = deviceState;
+            return this;
+        }
+
+        /**
+         * Returns a new {@link CredentialClientOptions} instance based on the configuration of this
+         * builder.
+         */
+        public CredentialClientOptions build() {
+            return new CredentialClientOptions(this);
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/KnownProviders.java b/api/java/org/openyolo/api/KnownProviders.java
index f2e47a4..6ca018f 100644
--- a/api/java/org/openyolo/api/KnownProviders.java
+++ b/api/java/org/openyolo/api/KnownProviders.java
@@ -27,173 +27,173 @@ import org.openyolo.protocol.AuthenticationDomain;
 /**
  * Manages a list of known providers, identified by their package name and a hash of their
  * signing certificate. This class will attempt to dynamically retrieve a list of known providers
  * from openyolo.org if possible, otherwise it will fall back to the list of known providers at
  * compile time.
  */
 public class KnownProviders {
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.dashlane.com">Dashlane</a>.
      */
     public static final AuthenticationDomain DASHLANE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
                     + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
                     + "@com.dashlane");
 
     /**
      * The known package name and certificate hash for Google's
      * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
      * Smart Lock for Passwords</a>.
      */
     public static final AuthenticationDomain GOOGLE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
                     + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
                     + "@com.google.android.gms");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://keepersecurity.com/">Keeper</a>.
      */
     public static final AuthenticationDomain KEEPER_PROVIDER =
             new AuthenticationDomain("android://"
                     + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
                     + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
                     + "@com.callpod.android_apps.keeper");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.lastpass.com/">LastPass</a>.
      */
     public static final AuthenticationDomain LASTPASS_PROVIDER =
             new AuthenticationDomain("android://"
                     + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
                     + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
                     + "@com.lastpass.lpandroid");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://1password.com/">1Password</a>.
      */
     public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
             new AuthenticationDomain("android://"
                     + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
                     + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
                     + "@com.agilebits.onepassword");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.roboform.com/">Roboform</a>.
      */
     public static final AuthenticationDomain ROBOFORM_PROVIDER =
             new AuthenticationDomain("android://"
                     + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
                     + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
                     + "@com.siber.roboform");
 
     /**
      * The list of known providers at the time this library was compiled.
      */
     public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
             Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
                     DASHLANE_PROVIDER,
                     GOOGLE_PROVIDER,
                     KEEPER_PROVIDER,
                     LASTPASS_PROVIDER,
                     ONEPASSWORD_PROVIDER,
                     ROBOFORM_PROVIDER
             )));
 
     private static final AtomicReference<KnownProviders> INSTANCE_REF =
             new AtomicReference<>();
 
     /**
      * Retrieves the singleton instance of the known provider list.
      */
-    public static KnownProviders getApplicationBoundInstance(Context context) {
+    public static KnownProviders getInstance(Context context) {
         KnownProviders providers = new KnownProviders(context);
         if (!INSTANCE_REF.compareAndSet(null, providers)) {
             providers = INSTANCE_REF.get();
         }
 
         return providers;
     }
 
     /**
      * FOR TESTING ONLY - Overrides the KnownProvider instance. It is *strongly discouraged*
      * to use this method in anything other than unit tests, as it can compromise the security
      * of your app and the user's credentials.
      */
     @VisibleForTesting
     static void setApplicationBoundInstance(KnownProviders instance) {
         INSTANCE_REF.set(instance);
     }
 
     /**
      * FOR TESTING ONLY - Clears the current instance of KnownProvider.
      */
     @VisibleForTesting
     static void clearApplicationBoundInstance() {
         INSTANCE_REF.set(null);
     }
 
     private final Context mApplicationContext;
     private Set<AuthenticationDomain> mKnownProviders;
 
     private KnownProviders(Context context) {
         mApplicationContext = context.getApplicationContext();
 
         // TODO: implement dynamic retrieval of known providers from
         // https://www.openyolo.org/known-providers
         // and fall back to the static list only if this fails
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     public Set<AuthenticationDomain> getKnownProviders() {
         return new HashSet<>(mKnownProviders);
     }
 
     /**
      * Determines whether the application with the specified package name (if installed) is
      * on the known provider list.
      */
     public boolean isKnown(String packageName) {
         List<AuthenticationDomain> packageAuthDomains =
                 AuthenticationDomain.listForPackage(mApplicationContext, packageName);
 
         for (AuthenticationDomain packageAuthDomain : packageAuthDomains) {
             if (mKnownProviders.contains(packageAuthDomain)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Reset the list of known providers to the default provider set. If possible, this will be
      * dynamically updated with a list retrieved from openyolo.org.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void resetKnownProvidersToDefault() {
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     /**
      * Adds a provider to the known provider list.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void addKnownProvider(AuthenticationDomain provider) {
         HashSet<AuthenticationDomain> knownProviders = new HashSet<>(mKnownProviders);
         knownProviders.add(provider);
         mKnownProviders = Collections.unmodifiableSet(knownProviders);
     }
 }
diff --git a/api/java/org/openyolo/api/persistence/DeviceState.java b/api/java/org/openyolo/api/persistence/DeviceState.java
new file mode 100644
index 0000000..e3bde63
--- /dev/null
+++ b/api/java/org/openyolo/api/persistence/DeviceState.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence;
+
+/** Collection of per application per device settings that should be persisted. */
+public interface DeviceState {
+
+    /**
+     * Returns {@code true} if the current application has disabled automatically signing in.
+     */
+    boolean isAutoSignInDisabled();
+
+    /**
+     * Setter for {@link #isAutoSignInDisabled()}.
+     */
+    void setIsAutoSignInDisabled(boolean isDisabled);
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/DeviceStateImpl.java b/api/java/org/openyolo/api/persistence/internal/DeviceStateImpl.java
new file mode 100644
index 0000000..07250f3
--- /dev/null
+++ b/api/java/org/openyolo/api/persistence/internal/DeviceStateImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+import android.content.Context;
+
+import org.openyolo.api.persistence.DeviceState;
+
+/**
+ * The default implementation of {@link DeviceState}.
+ */
+public final class DeviceStateImpl implements DeviceState {
+
+    private static final String SETTING_NAME_SPACE = "DeviceState";
+    private static final String KEY_IS_AUTO_SIGN_IN_DISABLED = "is_auto_sign_in_disabled";
+
+    private final SettingsFactory.BooleanSetting mIsAutoSignInDisabled;
+
+    /**
+     * Returns a new instance of {@link DeviceStateImpl}.
+     */
+    public static DeviceState getInstance(Context context) {
+        return new DeviceStateImpl(SettingsFactoryImpl.getInstance(context, SETTING_NAME_SPACE));
+    }
+
+    private DeviceStateImpl(SettingsFactory settingsFactory) {
+        mIsAutoSignInDisabled =
+                settingsFactory.makeBoolean(KEY_IS_AUTO_SIGN_IN_DISABLED, false /* defaultValue */);
+    }
+
+    @Override
+    public boolean isAutoSignInDisabled() {
+        return mIsAutoSignInDisabled.get();
+    }
+
+    @Override
+    public void setIsAutoSignInDisabled(boolean isDisabled) {
+        mIsAutoSignInDisabled.set(isDisabled);
+    }
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java b/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java
new file mode 100644
index 0000000..e2ca1c4
--- /dev/null
+++ b/api/java/org/openyolo/api/persistence/internal/SettingsFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+/**
+ * Factory for creating settings.
+ */
+interface SettingsFactory {
+
+    /**
+     * Returns a new {@link BooleanSetting} based on the given key and default value.
+     * @param key a unique identifier that acts as the primary key of the setting.
+     * @param defaultValue the default value of the setting.
+     */
+    BooleanSetting makeBoolean(String key, boolean defaultValue);
+
+    /**
+     * A boolean setting.
+     */
+    interface BooleanSetting {
+
+        /**
+         * Returns the current value if one has been set, otherwise the default value.
+         */
+        boolean get();
+
+        /**
+         * Sets the current value of the setting to the given value.
+         */
+        void set(boolean value);
+    }
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java b/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java
new file mode 100644
index 0000000..b89de05
--- /dev/null
+++ b/api/java/org/openyolo/api/persistence/internal/SettingsFactoryImpl.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * The default {@link SettingsFactory} implementation backed by {@link SharedPreferences}.
+ */
+final class SettingsFactoryImpl implements SettingsFactory {
+    private final SharedPreferences mSharedPreferences;
+
+    /**
+     * Returns a new instance of the {@link SettingsFactoryImpl} for the given settings namespace.
+     */
+    public static SettingsFactoryImpl getInstance(Context context, String namespace) {
+        return new SettingsFactoryImpl(context, namespace);
+    }
+
+    private SettingsFactoryImpl(Context context, String namespace) {
+        mSharedPreferences = context.getSharedPreferences(namespace, Context.MODE_PRIVATE);
+    }
+
+    /**
+     * Returns a new {@link SettingsFactory.BooleanSetting} based on
+     * the given key and default value.
+     */
+    public BooleanSetting makeBoolean(String key, boolean defaultValue) {
+        return BooleanSettingImpl.make(mSharedPreferences, key, defaultValue);
+    }
+
+    /**
+     * The default internal implementation of a {@link SettingsFactory.BooleanSetting}.
+     */
+    private static final class BooleanSettingImpl implements BooleanSetting {
+        private final String mKey;
+        private final boolean mDefaultValue;
+        private final SharedPreferences mSharedPreferences;
+
+        private static BooleanSetting make(
+                SharedPreferences sharedPreferences,
+                String key,
+                boolean defaultValue) {
+            return new BooleanSettingImpl(sharedPreferences, key, defaultValue);
+        }
+
+        private BooleanSettingImpl(
+                SharedPreferences sharedPreferences,
+                String key,
+                boolean defaultValue) {
+            mKey = key;
+            mDefaultValue = defaultValue;
+            mSharedPreferences = sharedPreferences;
+        }
+
+        @Override
+        public boolean get() {
+            return mSharedPreferences.getBoolean(mKey, mDefaultValue);
+        }
+
+        @Override
+        public void set(boolean value) {
+            SharedPreferences.Editor editor = mSharedPreferences.edit();
+            editor.putBoolean(mKey, value);
+            editor.apply();
+        }
+    }
+
+}
diff --git a/api/java/org/openyolo/api/persistence/internal/package-info.java b/api/java/org/openyolo/api/persistence/internal/package-info.java
new file mode 100644
index 0000000..b68c918
--- /dev/null
+++ b/api/java/org/openyolo/api/persistence/internal/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Collection of classes and interfaces related to persisting state used by the OpenYOLO libraries.
+ * _NOTE_: The contents of this package are _not_ part of the public API, and may change at any
+ * time.
+ */
+package org.openyolo.api.persistence.internal;
diff --git a/api/java/org/openyolo/api/persistence/package-info.java b/api/java/org/openyolo/api/persistence/package-info.java
new file mode 100644
index 0000000..d8c12fa
--- /dev/null
+++ b/api/java/org/openyolo/api/persistence/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Collection of interfaces related to persisting state.
+ */
+package org.openyolo.api.persistence;
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
index 5957aef..1ba9850 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -50,176 +50,176 @@ import org.openyolo.api.R;
 /**
  * Activity which presents the list of providers that claim to have a credential available.
  * The user can select one of these options, which fires the associated intent for that provider,
  * or cancel the whole operation.
  */
 public class ProviderPickerActivity extends AppCompatActivity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES = "titleRes";
     private static final String LOG_TAG = "ProviderPicker";
 
     private CredentialClient mClient;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.picker_layout);
 
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         Resources res = getResources();
         @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = res.getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
 
         TextView titleView = (TextView) findViewById(R.id.picker_title);
         @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
         if (titleRes != 0) {
             //robotium has an issue recovering resources in the shadow classes.
             titleView.setText(titleRes);
         }
 
         ListView providerView = (ListView) findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES, titleRes);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.retrieve_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.save_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
         return createIntent(context, hintIntents, R.string.hint_picker_prompt);
     }
 
     /**
      * Creates an intent for display a list of providers to which a credential deletion request
      * should be sent.
      */
     public static Intent createDeleteIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> deleteIntents) {
         return createIntent(context, deleteIntents, R.string.delete_picker_prompt);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
-            KnownProviders knownProviders = KnownProviders.getApplicationBoundInstance(
+            KnownProviders knownProviders = KnownProviders.getInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
             TextView providerUnsafe =
                     (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
 
         @SuppressWarnings("deprecation")
         private int getColor(@ColorRes int colorRes) {
             if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                 return getResources().getColor(colorRes, null);
             } else {
                 return getResources().getColor(colorRes);
             }
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 4d8ad7a..0042cc4 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -21,4 +21,9 @@ import static junit.framework.TestCase.assertNotNull;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
@@ -31,2 +36,6 @@ import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+
+import com.google.bbq.BroadcastQueryClient;
+import com.google.bbq.QueryCallback;
+
 import java.util.ArrayList;
@@ -37,6 +46,10 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.openyolo.api.persistence.DeviceState;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.CredentialSaveRequest;
@@ -45,2 +58,3 @@ import org.openyolo.protocol.HintRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.Protobufs;
 import org.openyolo.protocol.ProtocolConstants;
@@ -50,358 +64,429 @@ import org.robolectric.annotation.Config;
 /**
  * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
+    @Mock
+    private BroadcastQueryClient mockBroadcastQueryClient;
+
     @Mock
     private KnownProviders mockKnownProviders;
 
+    @Mock
+    private DeviceState mockDeviceState;
+
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
-        credentialClient = new CredentialClient(mockContext);
+        CredentialClientOptions options =
+                new CredentialClientOptions.Builder(mockDeviceState).build();
+        credentialClient = new CredentialClient(mockContext, mockBroadcastQueryClient, options);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
-    public void testGetApplicationBoundInstance() throws Exception {
-        CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
+    public void getInstance_returnsNonNull() throws Exception {
+        CredentialClient test = CredentialClient.getInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
         final Intent saveIntent = credentialClient.getSaveIntent(request);
 
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(null /* intent*/);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
         final Intent intent = new Intent();
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
         final Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
         final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void getCredentialSaveResult_validResult_returnsResult() {
         final CredentialSaveResult result =
                 credentialClient.getCredentialSaveResult(
                         CredentialSaveResult.SAVED.toResultDataIntent());
 
         assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
-    public void testGetCredentialRetrieveResult() throws Exception {
+    public void getCredentialRetrieveResult_withErrorResult_returnsErrorResult() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
+                new CredentialRetrieveResult.Builder(
+                        CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE)
+                        .build()
+                        .toProtobuf()
+                        .toByteArray());
+
+        CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
+
+        // Assert
+        assertThat(result).isNotNull();
+        assertThat(result.getResultCode()).isEqualTo(
+                CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE);
+        assertThat(result.getCredential()).isNull();
+        assertThat(result.getAdditionalProps()).isEmpty();
+
+        verifyNoMoreInteractions(mockDeviceState);
+    }
+
+    @Test
+    public void getCredentialRetrieveResult_withSuccessfulResult_returnsSuccessfulResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
+
+        // Assert
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
-
         assertThat(result.getAdditionalProps()).isEmpty();
+
+        verify(mockDeviceState).setIsAutoSignInDisabled(eq(false));
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
+    @Test
+    public void retrieve_autoSignInDisabled_requestRequiresUserMediation() {
+        CredentialRetrieveRequest request =
+                CredentialRetrieveRequest.forAuthenticationMethods(AuthenticationMethods.EMAIL);
+
+        when(mockDeviceState.isAutoSignInDisabled()).thenReturn(true);
+
+        // Act
+        credentialClient.retrieve(request, null /* callBack */);
+
+        // Assert
+        ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
+                ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
+        verify(mockBroadcastQueryClient)
+                .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
+        assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isTrue();
+    }
+
+    @Test
+    public void retrieve_autoSignInEnabled_requestDoesNotRequireUserMediation() {
+        CredentialRetrieveRequest request =
+                new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
+                        .setRequireUserMediation(false)
+                        .build();
+
+        when(mockDeviceState.isAutoSignInDisabled()).thenReturn(false);
+
+        // Act
+        credentialClient.retrieve(request, null /* callBack */);
+
+        // Assert
+        ArgumentCaptor<Protobufs.CredentialRetrieveRequest> requestArgumentCaptor =
+                ArgumentCaptor.forClass(Protobufs.CredentialRetrieveRequest.class);
+        verify(mockBroadcastQueryClient)
+                .queryFor(anyString(), requestArgumentCaptor.capture(), any(QueryCallback.class));
+        assertThat(requestArgumentCaptor.getValue().getRequireUserMediation()).isFalse();
+    }
+
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/api/javatests/org/openyolo/api/KnownProvidersTest.java b/api/javatests/org/openyolo/api/KnownProvidersTest.java
index 93d1709..d324ece 100644
--- a/api/javatests/org/openyolo/api/KnownProvidersTest.java
+++ b/api/javatests/org/openyolo/api/KnownProvidersTest.java
@@ -46,157 +46,157 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for KnownProviders.
  * Future-proofing the predefined values for the hardcoded providers.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class KnownProvidersTest {
 
     @Mock
     private Context mockContext;
     @Mock
     private PackageManager mockPackageManager;
 
     private KnownProviders underTest;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         PackageInfo mockPackageInfo = new PackageInfo();
         Signature[] signatures = new Signature[1];
         signatures[0] = mock(Signature.class);
         when(signatures[0].toByteArray()).thenReturn(new byte[10]);
         mockPackageInfo.signatures = signatures;
         when(mockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mockPackageInfo);
-        underTest = KnownProviders.getApplicationBoundInstance(mockContext);
+        underTest = KnownProviders.getInstance(mockContext);
     }
 
     /**
      * Future-proofing the default providers.
      * This test exist ONLY to future proof the sourcecode and make sure the above info doesn't
      * change by chance. The signatures here should never change, so in order to make sure of that
      * I added a second copy of them in this test.
      * @throws Exception
      */
     @Test
     public void testGetKnownProviders() throws Exception {
         Set<AuthenticationDomain> all = underTest.getKnownProviders();
         assertTrue(all.containsAll(DEFAULT_KNOWN_PROVIDERS));
         assertEquals(all.size(), DEFAULT_KNOWN_PROVIDERS.size());
     }
 
 
     public void testIsKnown_null() throws Exception {
         underTest.isKnown(null);
     }
 
     @Ignore // too dificult to unit test this, as it works with the byte[] of the actual signature
     @Test
     public void testIsKnown_positive() throws Exception {
         assertFalse(underTest.isKnown("com.dashlane"));
     }
 
     @Test
     public void testIsKnown_negative() throws Exception {
         assertFalse(underTest.isKnown("bogus.tld"));
     }
 
     @Test
     public void testResetKnownProvidersToDefault() throws Exception {
         int originalSize = underTest.getKnownProviders().size();
         AuthenticationDomain barbican = new AuthenticationDomain("https://barbican.com");
         underTest.addKnownProvider(barbican);
         int newsize = underTest.getKnownProviders().size();
         assertEquals(newsize, originalSize+1);
         underTest.resetKnownProvidersToDefault();
         Set<AuthenticationDomain> all = underTest.getKnownProviders();
         assertTrue(all.containsAll(DEFAULT_KNOWN_PROVIDERS));
         assertEquals(all.size(), DEFAULT_KNOWN_PROVIDERS.size());
     }
 
     @Test
     public void testAddKnownProvider() throws Exception {
         int originalSize = underTest.getKnownProviders().size();
         AuthenticationDomain barbican = new AuthenticationDomain("https://barbican.com");
         underTest.addKnownProvider(barbican);
         int newsize = underTest.getKnownProviders().size();
         assertEquals(newsize, originalSize+1);
     }
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.dashlane.com">Dashlane</a>.
      */
     public static final AuthenticationDomain DASHLANE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
                     + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
                     + "@com.dashlane");
 
     /**
      * The known package name and certificate hash for Google's
      * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
      * Smart Lock for Passwords</a>.
      */
     public static final AuthenticationDomain GOOGLE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
                     + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
                     + "@com.google.android.gms");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://keepersecurity.com/">Keeper</a>.
      */
     public static final AuthenticationDomain KEEPER_PROVIDER =
             new AuthenticationDomain("android://"
                     + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
                     + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
                     + "@com.callpod.android_apps.keeper");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.lastpass.com/">LastPass</a>.
      */
     public static final AuthenticationDomain LASTPASS_PROVIDER =
             new AuthenticationDomain("android://"
                     + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
                     + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
                     + "@com.lastpass.lpandroid");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://1password.com/">1Password</a>.
      */
     public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
             new AuthenticationDomain("android://"
                     + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
                     + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
                     + "@com.agilebits.onepassword");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.roboform.com/">Roboform</a>.
      */
     public static final AuthenticationDomain ROBOFORM_PROVIDER =
             new AuthenticationDomain("android://"
                     + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
                     + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
                     + "@com.siber.roboform");
 
     /**
      * The list of known providers at the time this library was compiled.
      */
     public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
             Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
                     DASHLANE_PROVIDER,
                     GOOGLE_PROVIDER,
                     KEEPER_PROVIDER,
                     LASTPASS_PROVIDER,
                     ONEPASSWORD_PROVIDER,
                     ROBOFORM_PROVIDER
             )));
 
 
 }
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java b/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java
new file mode 100644
index 0000000..b493ab0
--- /dev/null
+++ b/api/javatests/org/openyolo/api/persistence/internal/SettingsFactoryImplTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.persistence.internal;
+
+import android.content.Context;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.persistence.internal.SettingsFactory.BooleanSetting;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+/** Unit tests for {@link org.openyolo.api.persistence.internal.SettingsFactoryImpl} */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class SettingsFactoryImplTest {
+
+    private static final String NAMESPACE_A = "com.namespace.a";
+    private static final String NAMESPACE_B = "com.namespace.b";
+    private static final String BOOLEAN_KEY = "whatIsLife?";
+    private static final Context CONTEXT = RuntimeEnvironment.application;
+
+    private SettingsFactory mSettingsFactoryA;
+    private SettingsFactory mSettingsFactoryB;
+
+    @Before
+    public void setup() {
+        mSettingsFactoryA = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_A);
+        mSettingsFactoryB = SettingsFactoryImpl.getInstance(CONTEXT, NAMESPACE_B);
+    }
+
+    @Test
+    public void makeBooleanSetting_defaultValueFalse_returnsFalse() {
+        boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, false /* defaultValue */).get();
+        assertThat(value).isFalse();
+    }
+
+    @Test
+    public void makeBooleanSetting_defaultValueTrue_returnsTrue() {
+        boolean value = mSettingsFactoryA.makeBoolean(BOOLEAN_KEY, true /* defaultValue */).get();
+        assertThat(value).isTrue();
+    }
+
+    @Test
+    public void makeBooleansSettings_sameNamespacesSameKey_haveSameValues() {
+        final String key = "key";
+        final Boolean defaultValue = false;
+
+        BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue);
+        settingA.set(true);
+        BooleanSetting settingB = mSettingsFactoryA.makeBoolean(key, defaultValue);
+
+        assertThat(settingA.get()).isTrue();
+        assertThat(settingB.get()).isTrue();
+    }
+
+    @Test
+    public void makeBooleansSettings_differentNamespacesButSameKey_haveDifferentValues() {
+        final String key = "key";
+        final Boolean defaultValue = false;
+
+        BooleanSetting settingA = mSettingsFactoryA.makeBoolean(key, defaultValue);
+        settingA.set(true);
+        BooleanSetting settingB = mSettingsFactoryB.makeBoolean(key, defaultValue);
+
+        assertThat(settingA.get()).isTrue();
+        assertThat(settingB.get()).isFalse();
+    }
+}
diff --git a/bbq/java/com/google/bbq/BroadcastQueryClient.java b/bbq/java/com/google/bbq/BroadcastQueryClient.java
index 8944d96..17ccbb1 100644
--- a/bbq/java/com/google/bbq/BroadcastQueryClient.java
+++ b/bbq/java/com/google/bbq/BroadcastQueryClient.java
@@ -49,317 +49,317 @@ import java.util.concurrent.atomic.AtomicReference;
 /**
  * Dispatches broadcast queries to available data providers.
  */
-public final class BroadcastQueryClient {
+public class BroadcastQueryClient {
 
     /**
      * The default amount of time that this client will wait for responses from providers, before
      * ignoring them.
      */
     public static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2);
 
     private static final String LOG_TAG = "BroadcastQueryClient";
 
     private static final AtomicReference<BroadcastQueryClient> INSTANCE =
             new AtomicReference<>();
 
     @NonNull
     private final Context mContext;
 
     @NonNull
     private final SecureRandom mSecureRandom;
 
     @NonNull
     private final ConcurrentHashMap<Long, PendingQuery> mPendingQueries;
 
     @NonNull
     private final ScheduledExecutorService mExecutorService;
 
     @NonNull
     private final AtomicBoolean mDisposed;
 
     /**
      * Retrieves the global instance of the broadcast query client for the application
      * associated to the provided context.
      */
     @NonNull
-    public static BroadcastQueryClient getApplicationBoundInstance(Context context) {
+    public static BroadcastQueryClient getInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         BroadcastQueryClient client = new BroadcastQueryClient(applicationContext);
         if (!INSTANCE.compareAndSet(null, client)) {
             client.dispose();
             client = INSTANCE.get();
         }
 
         return client;
     }
 
     BroadcastQueryClient(@NonNull Context context) {
         mContext = context;
         mSecureRandom = new SecureRandom();
         mPendingQueries = new ConcurrentHashMap<>();
         mExecutorService = Executors.newSingleThreadScheduledExecutor();
         mDisposed = new AtomicBoolean(false);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified protocol buffer
      * message (if required). The response to this query will be provided to the specified callback.
      * A {@link #DEFAULT_TIMEOUT_MS default timeout} will be used.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable MessageLite queryMessage,
             @NonNull QueryCallback callback) {
         queryFor(dataType,
                 queryMessage,
                 DEFAULT_TIMEOUT_MS,
                 callback);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified protocol buffer
      * message (if required). The response to this query will be provided to the specified callback.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable MessageLite queryMessage,
             long timeoutInMs,
             @NonNull QueryCallback callback) {
         queryFor(dataType,
                 queryMessage != null ? queryMessage.toByteArray() : null,
                 timeoutInMs,
                 callback);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified message (if required).
      * The response to this query will be provided to the specified callback.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable byte[] queryMessage,
             long timeoutInMs,
             @NonNull QueryCallback callback) {
         require(!TextUtils.isEmpty(dataType), "dataType must not be null or empty");
         require(timeoutInMs > 0, "Timeout must be greater than zero");
         require(callback, notNullValue());
         require(!isDisposed(), "BroadcastQueryClient has been disposed");
 
         PendingQuery pq = new PendingQuery(
                 dataType,
                 queryMessage,
                 timeoutInMs,
                 callback);
 
         long queryId;
         do {
             queryId = mSecureRandom.nextLong();
         } while (mPendingQueries.putIfAbsent(queryId, pq) != null);
         pq.dispatch(queryId);
     }
 
     /**
      * Disposes all leakable resources associated with this client.
      */
     private void dispose() {
         if (!mDisposed.compareAndSet(false, true)) {
             return;
         }
 
         mExecutorService.shutdownNow();
         for (PendingQuery pq : mPendingQueries.values()) {
             mContext.unregisterReceiver(pq.mResponseReceiver);
         }
     }
 
     /**
      * Determines whether this client has been disposed, and therefore should no longer be used.
      */
     private boolean isDisposed() {
         return mDisposed.get();
     }
 
     private Intent createQueryIntent(
             PendingQuery pendingQuery,
             String responderPackage,
             long responseId) {
         Intent queryIntent = QueryUtil.createEmptyQueryIntent(pendingQuery.mDataType);
         queryIntent.setPackage(responderPackage);
         queryIntent.putExtra(QueryUtil.EXTRA_QUERY_MESSAGE,
                 BroadcastQuery.newBuilder()
                         .setClientVersion(ClientVersionUtil.getClientVersion())
                         .setRequestingApp(mContext.getPackageName())
                         .setDataType(pendingQuery.mDataType)
                         .setRequestId(pendingQuery.mQueryId)
                         .setResponseId(responseId)
                         .setQueryMessage(pendingQuery.mQueryMessage != null
                                 ? ByteString.copyFrom(pendingQuery.mQueryMessage)
                                 : null)
                         .build()
                         .toByteArray());
         return queryIntent;
     }
 
     private final class PendingQuery {
         final String mDataType;
         final byte[] mQueryMessage;
         final Map<Long, String> mRespondersById;
         final CopyOnWriteArraySet<Long> mPendingResponses;
         final ConcurrentHashMap<String, QueryResponse> mResponses;
         final QueryCallback mQueryCallback;
         final long mTimeoutInMs;
 
         long mQueryId;
         ScheduledFuture<Void> mTimeoutFuture;
         BroadcastReceiver mResponseReceiver;
 
         PendingQuery(
                 String dataType,
                 byte[] queryMessage,
                 long timeoutInMs,
                 QueryCallback queryCallback) {
             mDataType = dataType;
             mQueryMessage = queryMessage;
             mTimeoutInMs = timeoutInMs;
 
             mRespondersById = buildRespondersById();
             mPendingResponses = new CopyOnWriteArraySet<>();
             for (long responderId : mRespondersById.keySet()) {
                 mPendingResponses.add(responderId);
             }
             mResponses = new ConcurrentHashMap<>();
             mQueryCallback = queryCallback;
         }
 
         Map<Long, String> buildRespondersById() {
             Set<String> responders = QueryUtil.getRespondersForDataType(mContext, mDataType);
             HashMap<Long, String> tempRespondersById = new HashMap<>();
             for (String responderPackage : responders) {
                 long responderId;
                 do {
                     responderId = mSecureRandom.nextLong();
                 } while (tempRespondersById.containsKey(responderId));
 
                 tempRespondersById.put(responderId, responderPackage);
             }
             return tempRespondersById;
         }
 
         void dispatch(long queryId) {
             mQueryId = queryId;
 
             if (mRespondersById.isEmpty()) {
                 complete();
                 return;
             }
 
             mResponseReceiver = new ResponseHandler(this);
             mContext.registerReceiver(mResponseReceiver, getResponseFilter());
 
             for (Map.Entry<Long, String> responderEntry : mRespondersById.entrySet()) {
                 long responseId = responderEntry.getKey();
                 String responderPackage = responderEntry.getValue();
                 mContext.sendBroadcast(createQueryIntent(this, responderPackage, responseId));
             }
 
             mTimeoutFuture = mExecutorService.schedule(
                     new QueryTimeoutHandler(this),
                     mTimeoutInMs,
                     TimeUnit.MILLISECONDS);
         }
 
         void complete() {
             if (!mPendingQueries.remove(mQueryId, this)) {
                 // response already delivered
                 return;
             }
 
             if (mTimeoutFuture != null) {
                 mTimeoutFuture.cancel(false);
             }
 
             if (mResponseReceiver != null) {
                 mContext.unregisterReceiver(mResponseReceiver);
             }
 
             mQueryCallback.onResponse(mQueryId, new ArrayList<>(mResponses.values()));
         }
 
         IntentFilter getResponseFilter() {
             IntentFilter filter = new IntentFilter();
             filter.addAction(QueryUtil.createResponseAction(mDataType, mQueryId));
             filter.addCategory(QueryUtil.BBQ_CATEGORY);
             return filter;
         }
     }
 
     /**
      * Forcibly completes a pending query when a timeout is reached.
      */
     private final class QueryTimeoutHandler implements Callable<Void> {
 
         final PendingQuery mPendingQuery;
 
         QueryTimeoutHandler(PendingQuery pendingQuery) {
             mPendingQuery = pendingQuery;
         }
 
         @Override
         public Void call() throws Exception {
             mPendingQuery.complete();
             return null;
         }
     }
 
     /**
      * Captures broadcast responses for queries.
      */
     private final class ResponseHandler extends BroadcastReceiver {
 
         final PendingQuery mPendingQuery;
 
         ResponseHandler(PendingQuery pendingQuery) {
             mPendingQuery = pendingQuery;
         }
 
         @Override
         public void onReceive(Context context, Intent intent) {
             byte[] responseBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
             if (responseBytes == null) {
                 Log.w(LOG_TAG, "Received query response without a defined message");
                 return;
             }
 
             BroadcastQueryResponse response;
             try {
                 response = BroadcastQueryResponse.parseFrom(responseBytes);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Unable to parse query response message");
                 return;
             }
 
             String responder = mPendingQuery.mRespondersById.get(response.getResponseId());
             if (responder == null) {
                 Log.w(LOG_TAG, "Received response from unknown responder");
                 return;
             }
 
             if (!mPendingQuery.mPendingResponses.remove(response.getResponseId())) {
                 Log.w(LOG_TAG, "Duplicate response received; ignoring");
                 return;
             }
 
             if (response.getResponseMessage() != null) {
                 QueryResponse queryResponse = new QueryResponse(
                         responder,
                         response.getResponseId(),
                         response.getResponseMessage().toByteArray());
                 mPendingQuery.mResponses.put(responder, queryResponse);
             }
 
             if (mPendingQuery.mPendingResponses.isEmpty()) {
                 mPendingQuery.complete();
             }
         }
     }
 }
diff --git a/build.gradle b/build.gradle
index 10d112a..a561e62 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,15 +1,15 @@
 buildscript {
     repositories {
         jcenter()
         maven { url 'https://maven.google.com' }
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
+        classpath 'com.android.tools.build:gradle:3.0.0-beta2'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
         classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index f88cb96..63dc7ef 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -6,475 +6,477 @@ Checkstyle-Configuration: Android Style
 Description: https://source.android.com/source/code-style.html
 -->
 <module name="Checker">
   <property name="fileExtensions" value="java, properties, xml"/>
 
   <!-- Require UTF-8 encoding for all files -->
   <property name="charset" value="UTF-8"/>
 
   <!-- Default severity is error -->
   <property name="severity" value="warning"/>
 
   <!-- Warnings can be suppressed by adding them to this file -->
   <module name="SuppressionFilter">
     <property name="file" value="${checkstyle.suppressions}"/>
   </module>
 
   <module name="TreeWalker">
 
     <!--#################################################################-->
     <!--################ NAMING CHECKS ##################################-->
     <!--#################################################################-->
 
     <!-- Require package names to be all lower-case -->
     <module name="PackageName">
         <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
         <message key="name.invalidPattern"
                  value="Package name ''{0}'' must be lower-case."/>
     </module>
 
     <!-- Require standard type names -->
     <module name="TypeName">
         <message key="name.invalidPattern"
          value="Type name ''{0}'' must begin with a capital letter."/>
     </module>
 
     <!--
     Type parameters must either be a single upper-case character, or must begin
     with an upper-case character and end with "T" (e.g. DataT).
     -->
     <module name="ClassTypeParameterName">
       <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
       <message key="name.invalidPattern"
                value="Class type parameter ''{0}'' must either be a single upper-case character, or begin with an upper-case character and end with 'T'."/>
     </module>
 
     <!-- Non-public, non-static members must start with "m" -->
     <module name="MemberName">
       <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
       <property name="applyToPublic" value="false"/>
       <message key="name.invalidPattern"
                value="Member name ''{0}'' must be prefixed with m and be at least two characters long."/>
     </module>
 
     <!--
     Require method names to be at least two characters long, and start with a
     lower case letter.
     -->
     <module name="MethodName">
       <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
       <message key="name.invalidPattern"
                value="Method name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!--
     Type parameters must either be a single upper-case character, or must begin
     with an upper-case character and end with "T" (e.g. DataT).
     -->
     <module name="MethodTypeParameterName">
       <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
       <message key="name.invalidPattern"
                value="Method type parameter ''{0}'' must either be a single upper-case character or begin with an upper-case character and end with 'T'."/>
     </module>
 
     <!-- Require parameter names to be at least two characters long -->
     <module name="ParameterName">
         <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
         <message key="name.invalidPattern"
                  value="Parameter name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!--
     Require local variables to be at least two characters long,
     unless they are counters on a for loop.
     -->
     <module name="LocalVariableName">
         <property name="tokens" value="VARIABLE_DEF"/>
         <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
         <property name="allowOneCharVarInForLoop" value="true"/>
         <message key="name.invalidPattern"
                  value="Local variable name ''{0}'' must be at least two characters long."/>
     </module>
 
     <!-- Require that constants be capitalized. -->
     <module name="ConstantName"/>
 
     <module name="LocalFinalVariableName"/>
 
     <!--
     Require that static, non-public, non-final variable names be prefixed
     with "s".
     -->
     <module name="StaticVariableName">
       <property name="format" value="^s[A-Z][a-zA-Z0-9]*$"/>
       <message key="name.invalidPattern"
                value="Static variable name ''{0}'' must be prefixed with s and be at least two characters long."/>
     </module>
 
     <!-- Capitalized abbreviations are forbidden (e.g. URL, XML, HTTP) -->
     <module name="AbbreviationAsWordInName">
         <property name="ignoreFinal" value="false"/>
         <property name="allowedAbbreviationLength" value="1"/>
     </module>
 
     <!-- Forbid unnecessary escaping. -->
     <module name="IllegalTokenText">
       <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
       <property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
       <property name="message" value="Avoid using corresponding octal or Unicode escape."/>
     </module>
 
     <!-- Forbid unnecessary unicode escapes -->
     <module name="AvoidEscapedUnicodeCharacters">
         <property name="allowEscapesForControlCharacters" value="true"/>
         <property name="allowByTailComment" value="true"/>
         <property name="allowNonPrintableEscapes" value="true"/>
     </module>
 
     <!-- Require array notation on type (e.g. int[] x, not int x[]) -->
     <module name="ArrayTypeStyle"/>
 
     <!--###################################################-->
     <!--################ IMPORTS ##########################-->
     <!--###################################################-->
 
     <!-- Star imports are forbidden. -->
     <module name="AvoidStarImport"/>
 
     <!--
     Imports should be ordered such that static imports come before normal
     imports. Within these groups (separated by an empty line), imports should
     be lexicographially sorted with no further subcategorization required.
      -->
     <module name="CustomImportOrder">
         <property name="sortImportsInGroupAlphabetically" value="true"/>
         <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
     </module>
 
     <!-- Forbid imports from sun.* -->
     <module name="IllegalImport"/>
 
     <!-- Forbid redudant imports (e.g. import java.lang.String;) -->
     <module name="RedundantImport"/>
 
     <!-- Forbid unused imports -->
     <module name="UnusedImports"/>
 
     <!-- Forbid redundant modifiers -->
     <module name="RedundantModifier"/>
 
     <!--##############################################################-->
     <!--################ STRUCTURAL / WRAPPING CHECKS ################-->
     <!--##############################################################-->
 
     <!-- Require One top-level class per file -->
     <module name="OneTopLevelClass"/>
 
     <!-- Line-wrapping in import statements is forbidden. -->
     <module name="NoLineWrap"/>
 
     <!-- Empty catch blocks are forbidden. -->
     <module name="EmptyCatchBlock">
       <property name="exceptionVariableName" value="expected|ignore"/>
     </module>
 
     <!-- Require braces for all code blocks -->
     <module name="NeedBraces"/>
 
     <!-- Require One statement per line (e.g. no "a = b; c = d;") -->
     <module name="OneStatementPerLine"/>
 
     <!-- Multiple variable declarations on one line is forbidden. -->
     <module name="MultipleVariableDeclarations"/>
 
     <!-- Require switch statements to have default clause -->
     <module name="MissingSwitchDefault"/>
 
     <!--
     Case fall-through in switch statements is forbidden, except where an
     explicit "// fall-through" comment exists.
     -->
     <module name="FallThrough">
       <property name="reliefPattern" value="fall-through"/>
     </module>
 
     <!-- Require empty lines between definitions -->
     <module name="EmptyLineSeparator">
         <property name="allowNoEmptyLineBetweenFields" value="true"/>
     </module>
 
     <!-- Wrap only permitted before dot, e.g.
     fluentInterface.doX()
         .doY()
         .doZ();
     -->
     <module name="SeparatorWrap">
       <property name="tokens" value="DOT"/>
       <property name="option" value="nl"/>
     </module>
 
     <!-- Wrap only permitted after comma, e.g.
     doThings(withA,
         withB,
         withC);
     -->
     <module name="SeparatorWrap">
         <property name="tokens" value="COMMA"/>
         <property name="option" value="EOL"/>
     </module>
 
     <!-- require line breaks before common binary operators -->
     <module name="OperatorWrap">
         <property name="option" value="NL"/>
         <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
     </module>
 
     <!--
     Require that annotations on type, method and constructor definitions be on
     a separate line.
     -->
     <module name="AnnotationLocation">
       <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
     </module>
 
     <!--
     Variable declarations may have annotations on the same line.
     -->
     <module name="AnnotationLocation">
         <property name="tokens" value="VARIABLE_DEF"/>
         <property name="allowSamelineMultipleAnnotations" value="true"/>
     </module>
 
     <!-- Forbid empty statements -->
     <module name="EmptyStatement"/>
 
     <!--#################################################################-->
     <!--################ WHITESPACE / LINE LENGTH CHECKS ################-->
     <!--#################################################################-->
 
     <!-- Forbid whitespace after prefix unary operators and accessors -->
     <module name="NoWhitespaceAfter">
       <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
     </module>
 
     <!--
     Forbid whitespace before comma, semi-colon, and postfix unary operators
     -->
     <module name="NoWhitespaceBefore"/>
 
     <!-- Require whitespace around common tokens (=, if, etc.) -->
     <module name="WhitespaceAround">
       <property name="allowEmptyConstructors" value="true"/>
       <property name="allowEmptyMethods" value="true"/>
       <property name="allowEmptyTypes" value="true"/>
       <property name="allowEmptyLoops" value="true"/>
       <message key="ws.notFollowed"
        value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
        <message key="ws.notPreceded"
        value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
     </module>
 
     <!-- Require standard whitespace around type parameters -->
     <module name="GenericWhitespace">
       <message key="ws.followed"
                value="GenericWhitespace ''{0}'' is followed by whitespace."/>
        <message key="ws.preceded"
                 value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
        <message key="ws.illegalFollow"
                 value="GenericWhitespace ''{0}'' should followed by whitespace."/>
        <message key="ws.notPreceded"
                 value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
     </module>
 
     <!-- Require Android standard indentation. -->
     <module name="Indentation">
         <property name="basicOffset" value="4"/>
         <property name="braceAdjustment" value="0"/>
         <property name="caseIndent" value="4"/>
         <property name="throwsIndent" value="8"/>
         <property name="lineWrappingIndentation" value="8"/>
         <property name="arrayInitIndent" value="4"/>
     </module>
 
     <!--
     Require that comments be placed at the same level of indentation as
     surrounding code.
     -->
     <module name="CommentsIndentation"/>
 
     <!-- 100 char per line max, unless unavoidable -->
     <module name="LineLength">
       <property name="max" value="100"/>
       <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
     </module>
 
     <!--################################################-->
     <!--################ JAVADOC CHECKS ################-->
     <!--################################################-->
 
     <!--
     Require Javadoc for public methods:
     https://source.android.com/source/code-style.html#use-javadoc-standard-comments
     -->
     <module name="JavadocMethod">
       <property name="scope" value="public"/>
       <!-- exception: property methods (getX, setX, isX) -->
       <property name="allowMissingPropertyJavadoc" value="true"/>
       <!-- exception: method overrides, test methods -->
       <property name="allowedAnnotations" value="Override, Test, Before, After"/>
 
       <!--
       Every parameter need not be documented. This is to avoid the need for
       redundant descriptions between the main description and the parameter
       descriptions.
       -->
       <property name="allowMissingParamTags" value="true"/>
       <!--
       The return value need not be documented. This is to avoid the need for
       redundant descriptions between the main description and the return value
       descriptions.
       -->
       <property name="allowMissingReturnTag" value="true"/>
       <property name="allowThrowsTagsForSubclasses" value="true"/>
       <property name="suppressLoadErrors" value="true"/>
     </module>
 
     <!-- Javadoc required for public fields (part of API) -->
     <module name="JavadocVariable">
       <property name="scope" value="public"/>
     </module>
 
     <!-- Javadoc must be well-formed -->
     <module name="JavadocStyle"/>
 
     <!--
     Require descriptions for all included @param / @return / @throws /
     @deprecated tags in Javadoc comments.
     -->
     <module name="NonEmptyAtclauseDescription"/>
 
     <!--
     Require 4-character indentation of @param / @return / @throws / @deprecated
     descriptions which span more than one line.
     -->
     <module name="JavadocTagContinuationIndentation"/>
 
     <!--
     Forbid pointless Javadoc summary sentences.
     -->
     <module name="SummaryJavadocCheck">
       <property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
     </module>
 
     <!-- Require correct use of whitespace and <p> tags for Javadoc comments -->
     <module name="JavadocParagraph"/>
 
     <!-- Require correct order of Javadoc comment tags -->
     <module name="AtclauseOrder">
         <property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
         <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
     </module>
 
     <!-- Single line Javadoc comments with a tag are forbidden. -->
     <module name="SingleLineJavadoc">
       <property name="ignoreInlineTags" value="false"/>
     </module>
 
     <!--
     Require @deprecated Javadoc tag and @Deprecated annotation to be used
     together.
     -->
     <module name="MissingDeprecated"/>
 
     <!--#################################################################-->
     <!--################ MISC. LANGUAGE CHECKS ##########################-->
     <!--#################################################################-->
 
     <!-- File name must correspond to contained class -->
     <module name="OuterTypeFilename"/>
 
     <!--
     Long constants must be suffixed with L:
     "The suffix L is preferred, because the letter l (ell) is often hard to
     distinguish from the digit 1 (one)."
     http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.1
     -->
     <module name="UpperEll"/>
 
     <!--
     Require modifier order consistent with recommends in JLS:
     http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html
     -->
     <module name="ModifierOrder"/>
 
     <!-- Finalizers are forbidden. -->
     <module name="NoFinalizer"/>
 
     <!-- overloaded methods must be grouped together -->
     <module name="OverloadMethodsDeclarationOrder"/>
 
     <!-- Require variables to be declared close to where they are used -->
     <module name="VariableDeclarationUsageDistance"/>
 
     <!-- Require that equals() and hashCode() are overridden together -->
     <module name="EqualsHashCode"/>
 
     <!-- Forbid shadowing fields or variables -->
     <module name="HiddenField">
       <!-- exception: constructor parameters -->
       <property name="ignoreConstructorParameter" value="true"/>
       <!-- exception: setter method parameters -->
       <property name="ignoreSetter" value="true"/>
     </module>
 
     <!--
     Forbid assignments in expressions, with the exception of loop conditions
     -->
     <module name="InnerAssignment"/>
 
     <!-- Require @Override on overridden methods -->
     <module name="MissingOverride"/>
 
     <!-- Forbid arbitrarily nested blocks -->
     <module name="AvoidNestedBlocks"/>
 
     <!-- Forbid the use of arbitrary numeric literals -->
     <module name="MagicNumber"/>
 
     <!-- Require boolean expressions to be simplifed -->
     <module name="SimplifyBooleanExpression"/>
 
     <!-- Require boolean returns to be simplified -->
     <module name="SimplifyBooleanReturn"/>
 
     <!-- Forbid interfaces with no methods -->
     <module name="InterfaceIsType"/>
 
   </module>
 
   <!--################################################-->
   <!--################ Non-AST checks ################-->
   <!--################################################-->
 
   <!-- Ensure the copyright header appears in every java source file -->
   <module name="RegexpHeader">
     <property name="headerFile" value="${checkstyle.java.header}"/>
     <property name="fileExtensions" value="java"/>
   </module>
 
   <!-- Report every line containing a tab character" -->
   <module name="FileTabCharacter">
     <property name="eachLine" value="true"/>
   </module>
 
   <!-- Forbid trailing whitespace -->
   <module name="RegexpSingleline">
     <property name="format" value="\s+$"/>
     <property name="message" value="Line has trailing whitespace."/>
   </module>
 
   <!-- require Javadoc for all packages -->
   <module name="JavadocPackage"/>
 
   <!-- Require a new line at the end of all files -->
-  <module name="NewlineAtEndOfFile"/>
+  <module name="NewlineAtEndOfFile">
+    <property name="lineSeparator" value="lf"/>
+  </module>
 </module>
diff --git a/config/protobuf.gradle b/config/protobuf.gradle
index aba159a..651f1e1 100644
--- a/config/protobuf.gradle
+++ b/config/protobuf.gradle
@@ -42,42 +42,47 @@ def makeExecutable = { file ->
 /**
  * Compiles the protocol buffers in the "proto" folder of the project, into the "java_gen" folder.
  */
 task compileProtos {
     doLast {
         def protocFile = protoDepsConfig.fileCollection(protocDep).singleFile
         def javaliteFile = protoDepsConfig.fileCollection(javaliteDep).singleFile
 
         makeExecutable(protocFile)
         makeExecutable(javaliteFile)
 
         def protoFiles = fileTree(dir: "${projectDir}/proto").matching { include "**/*.proto"}.sort()
+        if (protoFiles.isEmpty()) {
+            logger.lifecycle("No protobuf files found. Skipping compilation.")
+            return
+        }
+
         logger.lifecycle("proto files: " + protoFiles)
 
         def outDir = file("${projectDir}/java_gen")
         if (!outDir.exists()) {
             outDir.mkdir()
         }
 
         def cmd = [ protocFile ]
         cmd += "--proto_path=${projectDir}/proto"
         cmd += "--plugin=protoc-gen-javalite=" + javaliteFile.absolutePath
         cmd += "--javalite_out=${projectDir}/java_gen"
         cmd.addAll(protoFiles)
 
         logger.lifecycle("protoc command: " + cmd.toString())
 
         def stdout = new StringBuffer()
         def stderr = new StringBuffer()
         Process compileProcess = cmd.execute()
         compileProcess.waitForProcessOutput(stdout, stderr)
 
         if (compileProcess.exitValue() != 0) {
             def error = "protobuf compilation failed: stdout: ${stdout}. stderr: ${stderr}"
             throw new GradleException(error)
         }
     }
 }
 
 /**
  * javalite compiled protos require this runtime dependency.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index fe5e2f4..43608c1 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -34,111 +34,111 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
 public class RetrieveCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "RetrieveCredential";
     private CredentialStorageClient mClient;
     private CredentialRetrieveRequest mRequest;
 
     /**
      * Creates the intent to handle releasing a credential to the calling app.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         // the format of this intent needs to be compatible with a "direct invocation" intent,
         // based on the spec (Section 4.3.1).
         Intent intent = new Intent(context, RetrieveCredentialActivity.class);
         intent.setAction(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
         intent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_REQUEST,
                 request.toProtocolBuffer().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
             mRequest = CredentialRetrieveRequest.fromRequestIntent(getIntent());
         } catch (MalformedDataException ex) {
             setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
         }
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
         if (!client.isUnlocked()) {
             Intent retrieveAfterUnlockIntent =
                     RetrieveCredentialActivity.createIntent(this, mRequest);
             retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
             Intent unlockIntent =
                     UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
             unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(unlockIntent);
             finish();
         } else {
             // TODO: we actually need the full set of requested domains from the original request,
             // not just those based on the package name.
 
             List<AuthenticationDomain> authDomains =
                     AuthenticationDomain.listForPackage(this, getCallingPackage());
 
             List<Credential> credentials;
             try {
                 credentials =
                         CredentialTransformUtils.fromProtoList(client.listCredentials(authDomains));
             } catch (IOException ex) {
                 Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
                 finish();
                 return;
             } catch (MalformedDataException ex) {
                 Log.w(LOG_TAG, "Unable to parse credentials from their protocol buffer form", ex);
                 finish();
                 return;
             }
 
-            if (credentials.size() == 1) {
+            if (!mRequest.getRequireUserMediation() && credentials.size() == 1) {
                 Intent autoSignInIntent =
                         AutoSignInActivity.createIntent(this, credentials.get(0));
                 autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(autoSignInIntent);
             } else {
                 Intent pickerIntent =
                         CredentialPickerActivity.createIntent(this, credentials);
                 pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(pickerIntent);
             }
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index 82bcb89..ac82359 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -32,2 +32,4 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+
 import java.io.IOException;
@@ -38,2 +40,3 @@ import java.util.Map;
 import java.util.Set;
+
 import org.openyolo.protocol.internal.AuthenticationMethodConverters;
@@ -46,319 +49,360 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class CredentialRetrieveRequest implements Parcelable {
 
+    @VisibleForTesting
+    static final Boolean DEFAULT_REQUIRE_USER_MEDIATION_VALUE = false;
+
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
             @NonNull Protobufs.CredentialRetrieveRequest proto) throws MalformedDataException {
         validate(proto, notNullValue(), MalformedDataException.class);
 
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
      * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
             throws MalformedDataException {
         validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
         } catch (IOException ex) {
             throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
      * @throws MalformedDataException if the intent does not contain a retrieve request, or the
      *     contained request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
             throws MalformedDataException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
             throw new MalformedDataException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
+    @NonNull
+    private final boolean mRequireUserMediation;
+
     private CredentialRetrieveRequest(Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalParams);
+        mRequireUserMediation = builder.mRequireUserMediation;
     }
 
     /**
      * The set of authentication methods that the requester supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The set of token providers that the requester supports. These are used by the
      * credential provider and the OpenYOLO client library to attempt to acquire a "proof of access"
      * ID token for any returned credential.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
-     * The map of additional, non-standard properties included with this request.
+     * Specifies if the provider MUST have the user interact before a successful response is
+     * returned.
+     */
+    @NonNull
+    public boolean getRequireUserMediation() {
+        return mRequireUserMediation;
+    }
+
+
+    /**
+     * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
+                .setRequireUserMediation(mRequireUserMediation)
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
+        private boolean mRequireUserMediation = DEFAULT_REQUIRE_USER_MEDIATION_VALUE;
+
+        /**
+         * Starts the process of creating a retrieve request using the data contained in the
+         * provided credential retrieve request.
+         */
+        public Builder(CredentialRetrieveRequest request) {
+            mAuthMethods = request.mAuthMethods;
+            mTokenProviders = request.mTokenProviders;
+            mAdditionalParams = request.mAdditionalProps;
+            mRequireUserMediation = request.mRequireUserMediation;
+        }
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          * @throws MalformedDataException if the given protocol buffer is not valid.
          */
         private Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto)
                 throws MalformedDataException {
             validate(requestProto, notNullValue(), MalformedDataException.class);
 
             try {
                 setAuthenticationMethods(CollectionConverter.toSet(
                         requestProto.getAuthMethodsList(),
                         AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
 
                 setTokenProviders(CollectionConverter.convertMapValues(
                         requestProto.getSupportedTokenProvidersMap(),
                         TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
 
                 setAdditionalProperties(
                         CollectionConverter.convertMapValues(
                                 requestProto.getAdditionalPropsMap(),
                                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+
+                setRequireUserMediation(requestProto.getRequireUserMediation());
             } catch (IllegalArgumentException ex) {
                 throw new MalformedDataException(ex);
             }
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
+        /**
+         * Specifies if the provider MUST require user interaction before returning a successful
+         * response.
+         */
+        public Builder setRequireUserMediation(boolean value) {
+            mRequireUserMediation = value;
+            return this;
+        }
+
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
             validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
 
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public CredentialRetrieveRequest build() {
             return new CredentialRetrieveRequest(this);
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return CredentialRetrieveRequest.fromProtobufBytes(protoBytes);
             } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 9577363..476af6d 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -32,105 +32,119 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
         TestConstants.checkTokenProviderMap(request.getTokenProviders());
         TestConstants.checkAdditionalProps(request.getAdditionalProperties());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProto_withNull_throwsMalformedDataException() throws Exception {
         CredentialRetrieveRequest.fromProtobuf(null);
     }
 
     @Test
     public void testWriteAndRead() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .setRequireUserMediation(true)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             TestConstants.checkTokenProviderMap(deserialized.getTokenProviders());
             TestConstants.checkAdditionalProps(deserialized.getAdditionalProperties());
+            assertThat(deserialized.getRequireUserMediation()).isTrue();
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
+
+    @Test
+    public void toProtocolBuffer_usingDefaultBuilder_returnsExpectedValues() {
+        CredentialRetrieveRequest request =
+                new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL).build();
+
+        Protobufs.CredentialRetrieveRequest protoRequest = request.toProtocolBuffer();
+
+        assertThat(protoRequest.getRequireUserMediation())
+                .isEqualTo(CredentialRetrieveRequest.DEFAULT_REQUIRE_USER_MEDIATION_VALUE);
+    }
+
     @Test
-    public void testToProtocolBuffer_includesClientVersion() {
+    public void toProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 }
\ No newline at end of file
diff --git a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
index 6420c01..0c6610b 100644
--- a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
@@ -31,97 +31,97 @@ import org.openyolo.protocol.CredentialDeleteResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential deletion flow.
  */
 public class DeleteTestPageFragment extends TestPageFragment  {
 
     private static final int RC_DELETE = 100;
 
     @BindView(R.id.credential_to_delete)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mApi = CredentialClient.getApplicationBoundInstance(getActivity());
+        mApi = CredentialClient.getInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.delete_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.delete_button)
     void onDelete() {
         Credential credential = mCredentialView.makeCredentialFromFields();
         if (credential == null) {
             showSnackbar(R.string.invalid_credential_data);
             return;
         }
 
         Intent deleteIntent = mApi.getDeleteIntent(credential);
         if (deleteIntent == null) {
             showSnackbar(R.string.no_available_delete_providers);
             return;
         }
 
         startActivityForResult(deleteIntent, RC_DELETE);
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_DELETE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialDeleteResult deleteResult = mApi.getDeleteResult(data);
 
         @StringRes
         int resultMessageId;
         switch (deleteResult.getResultCode()) {
             case CredentialDeleteResult.CODE_DELETED:
                 resultMessageId = R.string.delete_result_deleted;
                 break;
             case CredentialDeleteResult.CODE_NO_MATCHING_CREDENTIAL:
                 resultMessageId = R.string.delete_result_no_matching_credential;
                 break;
             case CredentialDeleteResult.CODE_PROVIDER_REFUSED:
                 resultMessageId = R.string.delete_result_provider_refused;
                 break;
             case CredentialDeleteResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.delete_result_user_canceled;
                 break;
             case CredentialDeleteResult.CODE_USER_REFUSED:
                 resultMessageId = R.string.delete_result_user_refused;
                 break;
             case CredentialDeleteResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.delete_result_bad_request;
                 break;
             default:
                 resultMessageId = R.string.delete_result_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @Override
     public String getPageTitle() {
         return "Delete";
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 179c1b0..b24158e 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -34,113 +34,113 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.token_providers_input)
     TokenProviderInputView mTokenProviderInputView;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     @BindView(R.id.id_token_view)
     IdTokenView mIdTokenView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mApi = CredentialClient.getApplicationBoundInstance(getContext());
+        mApi = CredentialClient.getInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         // CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         HintRetrieveResult result = mApi.getHintRetrieveResult(data);
         Hint hint = result.getHint();
         if (hint != null) {
             mCredentialView.setFieldsFromHint(hint);
             mIdTokenView.setIdToken(hint.getIdToken());
             return;
         }
 
         int errorStringResId;
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 errorStringResId = R.string.hint_bad_request;
                 break;
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 errorStringResId = R.string.hint_none_available;
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 errorStringResId = R.string.hint_user_canceled;
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 errorStringResId = R.string.hint_manual_auth;
                 break;
             default:
                 errorStringResId = R.string.hint_unknown_response;
         }
         showSnackbar(errorStringResId);
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
 
         HintRetrieveRequest request =
                 new HintRetrieveRequest.Builder(authenticationMethods)
                         .setTokenProviders(mTokenProviderInputView.getTokenProviders())
                         .build();
 
         Intent hintIntent = mApi.getHintRetrieveIntent(request);
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
index 2d74043..30cb046 100644
--- a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
+++ b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
@@ -28,53 +28,54 @@ import java.util.List;
 /**
  * The main OpenYolo test activity.
  */
 public final class OpenYoloTestActivity extends AppCompatActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.main_layout);
 
         setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
 
         final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
         DemoPagerAdapter demoPagerAdapter = new DemoPagerAdapter(getSupportFragmentManager());
         demoPagerAdapter.addPage(new RetrieveTestPageFragment());
         demoPagerAdapter.addPage(new SaveTestPageFragment());
         demoPagerAdapter.addPage(new HintTestPageFragment());
         demoPagerAdapter.addPage(new DeleteTestPageFragment());
+        demoPagerAdapter.addPage(new OtherTestPageFragment());
 
         viewPager.setAdapter(demoPagerAdapter);
         TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
         tabLayout.setupWithViewPager(viewPager);
     }
 
     private static class DemoPagerAdapter extends FragmentPagerAdapter {
 
         private final List<TestPageFragment> mPages = new ArrayList<>();
 
         DemoPagerAdapter(FragmentManager fragmentManager) {
             super(fragmentManager);
         }
 
         @Override
         public int getCount() {
             return mPages.size();
         }
 
         public void addPage(TestPageFragment pageFragment) {
             mPages.add(pageFragment);
         }
 
         @Override
         public Fragment getItem(int position) {
             return mPages.get(position);
         }
 
         @Override
         public CharSequence getPageTitle(int position) {
             return mPages.get(position).getPageTitle();
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java b/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
new file mode 100644
index 0000000..af1b9f5
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/OtherTestPageFragment.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import org.openyolo.api.CredentialClient;
+
+/**
+ * Test page for actions that do not cleanly fit into another category.
+ */
+public class OtherTestPageFragment extends TestPageFragment {
+
+    private CredentialClient mApi;
+
+    @Override
+    public String getPageTitle() {
+        return "Other";
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mApi = CredentialClient.getInstance(getContext());
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.other_test_layout, container, false);
+        ButterKnife.bind(this, view);
+
+        return view;
+    }
+
+    @OnClick(R.id.disable_auto_sign_in_button)
+    void onDisableAutoSignIn() {
+        mApi.disableAutoSignIn();
+    }
+}
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index 050cb8e..cac75c3 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -24,2 +24,4 @@ import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
+
 import butterknife.BindView;
@@ -38,140 +40,146 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.token_providers_input)
     TokenProviderInputView mTokenProviderInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
+    @BindView(R.id.require_user_mediation_check_box)
+    CheckBox mRequireUserMediationCheckBox;
+
     @BindView(R.id.id_token_view)
     IdTokenView mIdTokenView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mApi = CredentialClient.getApplicationBoundInstance(getContext());
+        mApi = CredentialClient.getInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         Credential credential = result.getCredential();
         if (credential != null) {
             mCredentialView.setFieldsFromCredential(credential);
             mIdTokenView.setIdToken(credential.getIdToken());
             return;
         }
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 resultMessageId = R.string.retrieve_no_credentials;
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.retrieve_bad_request;
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.retrieve_user_canceled;
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 resultMessageId = R.string.retrieve_manual_auth;
                 break;
             default:
                 resultMessageId = R.string.retrieve_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
-        CredentialRetrieveRequest request =
+        CredentialRetrieveRequest.Builder requestBuilder =
                 new CredentialRetrieveRequest.Builder(authenticationMethods)
-                        .setTokenProviders(mTokenProviderInputView.getTokenProviders())
-                        .build();
+                        .setTokenProviders(mTokenProviderInputView.getTokenProviders());
+
+        if (mRequireUserMediationCheckBox.isChecked()) {
+            requestBuilder.setRequireUserMediation(true);
+        }
 
-        mApi.retrieve(request, new HandleRetrieveResult());
+        mApi.retrieve(requestBuilder.build(), new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveBbqResponse> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveBbqResponse result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveBbqResponse result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.retrieve_no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index fd3508f..efc7647 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -32,89 +32,89 @@ import org.openyolo.protocol.CredentialSaveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
 public final class SaveTestPageFragment extends TestPageFragment {
 
     private static final int RC_SAVE = 0;
 
     @BindView(R.id.save_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Save";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mApi = CredentialClient.getApplicationBoundInstance(getActivity());
+        mApi = CredentialClient.getInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.save_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.save_button)
     void onSave() {
         final Credential credential = mCredentialView.makeCredentialFromFields();
         final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(credential);
         final Intent saveIntent = mApi.getSaveIntent(request);
 
         if (saveIntent == null) {
             showSnackbar(R.string.no_available_save_providers);
             return;
         }
 
         startActivityForResult(saveIntent, RC_SAVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_SAVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialSaveResult result = mApi.getCredentialSaveResult(data);
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialSaveResult.CODE_SAVED:
                 resultMessageId = R.string.save_result_saved;
                 break;
             case CredentialSaveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.save_result_bad_request;
                 break;
             case CredentialSaveResult.CODE_PROVIDER_REFUSED:
                 resultMessageId = R.string.save_result_provider_refused;
                 break;
             case CredentialSaveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.save_result_user_canceled;
                 break;
             case CredentialSaveResult.CODE_USER_REFUSED:
                 resultMessageId = R.string.save_result_user_refused;
                 break;
             default:
                 resultMessageId = R.string.save_result_unkown;
         }
 
         showSnackbar(resultMessageId);
     }
 }
diff --git a/testapp/res/layout/other_test_layout.xml b/testapp/res/layout/other_test_layout.xml
new file mode 100644
index 0000000..1569047
--- /dev/null
+++ b/testapp/res/layout/other_test_layout.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.NestedScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:layout_behavior="@string/appbar_scrolling_view_behavior"
+    style="@style/DemoContent">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <Button
+            android:id="@+id/disable_auto_sign_in_button"
+            style="@style/Widget.AppCompat.Button.Colored"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="16dp"
+            android:layout_marginLeft="8dp"
+            android:layout_marginRight="8dp"
+            android:layout_gravity="center_horizontal"
+            android:contentDescription="@string/disable_auto_sign_in_button_content_description"
+            android:text="@string/disable_auto_sign_in_button_label"
+            android:theme="@style/GreenButtonThemeOverlay"/>
+
+    </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/retrieve_test_layout.xml b/testapp/res/layout/retrieve_test_layout.xml
index 782cb9c..ea4448e 100644
--- a/testapp/res/layout/retrieve_test_layout.xml
+++ b/testapp/res/layout/retrieve_test_layout.xml
@@ -1,71 +1,84 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/request"
         android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/authentication_method_section_title"
         android:paddingTop="8dp"
         android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
 
     <org.openyolo.testapp.AuthenticationMethodsInputView
       android:id="@+id/authentication_methods_input"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" />
 
     <org.openyolo.testapp.TokenProviderInputView
       android:id="@+id/token_providers_input"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" />
 
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/retrieve_other_section_title"
+        android:paddingTop="8dp"
+        android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
+
+    <android.support.v7.widget.AppCompatCheckBox
+        android:id="@+id/require_user_mediation_check_box"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/require_user_mediation_checkbox_text"/>
+
     <Button
       android:id="@+id/retrieve_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/retrieve_button_content_description"
       android:text="@string/retrieve_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
 
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:paddingTop="16dp"
         android:text="@string/response"
         android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/retrieve_credential"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
     </org.openyolo.testapp.CredentialView>
 
     <org.openyolo.testapp.IdTokenView
         android:id="@+id/id_token_view"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" />
 
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 88b7019..b097628 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,95 +1,103 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
     <string name="phone_authentication_method_checkbox_text">openyolo://phone</string>
     <string name="username_authentication_method_checkbox_text">openyolo://username</string>
 
+    <string name="require_user_mediation_checkbox_text">Require User Mediation</string>
+    <string name="retrieve_other_section_title">Other</string>
+
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="save_result_unkown">Unknown save result</string>
     <string name="save_result_saved">Credential Saved</string>
     <string name="save_result_bad_request">Malformed save request</string>
     <string name="save_result_provider_refused">Provider refused save request</string>
     <string name="save_result_user_canceled">User canceled save request</string>
     <string name="save_result_user_refused">User refused save request</string>
 
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
     <string name="no_available_delete_providers">"No available providers can delete this credential</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
     <string name="delete_result_unknown_response">Unknown delete response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
+
+    <!-- Other Test -->
+    <string name="disable_auto_sign_in_button_label">Disable Auto Sign In</string>
+    <string name="disable_auto_sign_in_button_content_description">Disable Auto Sign In</string>
+
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response Properties</string>
     <string name="request">Request Properties</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
   <string name="token_providers_header">Supported token providers</string>
     <string name="use_google_token_provider">Request Google ID tokens</string>
     <string name="token_provider_uri_field_hint">Token provider URI</string>
     <string name="client_id_field_hint">Client ID</string>
     <string name="nonce_field_hint">Nonce</string>
     <string name="clear_token_provider">Clear</string>
     <string name="no_token">No token returned</string>
     <string name="id_token_view_header">ID Token</string>
 
 </resources>

commit 315c11f584ac59fbfeee828be5b834b88bdbed19
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue Aug 8 13:08:16 2017 -0700

    Tool and dependency version bump
    
    Updated android lint picked up new issues in resources, these are now fixed.
    
    Robolectric upgrade broke some low-value tests in api, these were removed and
    will be rewritten once a better approach is found.
    
    Upgrading to Glide 4.x required some minor code changes for the new
    generated APIs, which maintain source compatibility with the previously
    used glide version.

diff --git a/api/build.gradle b/api/build.gradle
index 00a4c5a..a4b0ea4 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -20,10 +20,12 @@ android {
 dependencies {
-    compile project(":bbq")
-    compile project(":protocol")
-    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
-    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
-    compile "org.hamcrest:hamcrest-core:1.3"
-    compile "org.valid4j:valid4j:0.5.0"
+    api project(":bbq")
+    api project(":protocol")
+    implementation "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:support-vector-drawable:${rootProject.ext.supportLibVersion}"
+    implementation "org.hamcrest:hamcrest-core:${rootProject.ext.hamcrestVersion}"
+    implementation "org.valid4j:valid4j:${rootProject.ext.valid4jVersion}"
     apply from:'../config/testdeps.gradle', to:it
+
+    testImplementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
 }
diff --git a/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java b/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
deleted file mode 100644
index 9550d28..0000000
--- a/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.api.ui;
-
-import static junit.framework.TestCase.assertNotNull;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-import java.util.ArrayList;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openyolo.api.R;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-
-/**
- * Battery of tests for the ProviderPickerActivity
- */
-@RunWith(YoloTestRunner.class)
-@Config(manifest = "AndroidManifest.xml",
-        sdk = Build.VERSION_CODES.LOLLIPOP,
-        packageName = "org.openyolo.api")
-public class ProviderPickerActivityTest {
-
-    @Mock
-    Context mockContext;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-    }
-
-    @Test
-    public void createRetrieveIntent() throws Exception {
-        ArrayList<Intent> retrieveIntents = new ArrayList<>();
-        Intent item = ProviderPickerActivity.createRetrieveIntent(mockContext, retrieveIntents);
-        assertNotNull(item);
-
-    }
-
-    @Test
-    public void createSaveIntent() throws Exception {
-        ArrayList<Intent> retrieveIntents = new ArrayList<>();
-        Intent item = ProviderPickerActivity.createSaveIntent(mockContext, retrieveIntents);
-        assertNotNull(item);
-    }
-
-    @Test
-    public void testActivity_main() throws Exception {
-        Activity activity = Robolectric.buildActivity(ProviderPickerActivity.class).create().get();
-        assertNotNull(activity);
-        TextView titleView = (TextView) activity.findViewById(R.id.picker_title);
-    }
-
-    @Test
-    public void testActivity_toViewport_save() throws Exception {
-        final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
-        final String OPENYOLO_CATEGORY = "org.openyolo";
-        final String EXTRA_PROVIDER_INTENTS = "providerIntents";
-
-            Intent saveIntent = new Intent(SAVE_CREDENTIAL_ACTION);
-            saveIntent.setClassName(
-                    "com.dashlane",
-                    "LoginActivity");
-            ArrayList<Intent> intents = new ArrayList<>();
-            saveIntent.addCategory(OPENYOLO_CATEGORY);
-            saveIntent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, intents);
-            //saveIntent.setData(credentialToSave.getAuthenticationMethod());
-
-
-        Activity activity = Robolectric.buildActivity(ProviderPickerActivity.class)
-                .withIntent(saveIntent)
-                .create()
-                .start()
-                .resume()
-                .visible()
-                .get();
-        assertNotNull(activity);
-        ListAdapter adapter = ((ListView) activity.findViewById(R.id.provider_list)).getAdapter();
-        assertNotNull(adapter);
-    }
-}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/ui/YoloTestRunner.java b/api/javatests/org/openyolo/api/ui/YoloTestRunner.java
deleted file mode 100644
index 5d59a18..0000000
--- a/api/javatests/org/openyolo/api/ui/YoloTestRunner.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.api.ui;
-
-import org.junit.runners.model.InitializationError;
-import org.openyolo.api.BuildConfig;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-import org.robolectric.manifest.AndroidManifest;
-import org.robolectric.res.Fs;
-
-public class YoloTestRunner extends RobolectricTestRunner {
-    public YoloTestRunner(Class<?> testClass) throws InitializationError {
-        super(testClass);
-        String buildVariant = (BuildConfig.FLAVOR.isEmpty()
-                ? "" : BuildConfig.FLAVOR+ "/") + BuildConfig.BUILD_TYPE;
-        String intermediatesPath = BuildConfig.class.getResource("")
-                .toString().replace("file:", "");
-        intermediatesPath = intermediatesPath
-                .substring(0, intermediatesPath.indexOf("/classes"));
-
-        System.setProperty("android.package",
-                BuildConfig.APPLICATION_ID);
-        System.setProperty("android.manifest",
-                intermediatesPath + "/manifests/aapt/"
-                        + buildVariant + "/AndroidManifest.xml");
-        System.setProperty("android.resources",
-                intermediatesPath + "/res/merged/" + buildVariant);
-        System.setProperty("android.assets",
-                intermediatesPath + "/assets/" + buildVariant);
-    }
-
-    @Override protected AndroidManifest getAppManifest(Config config) {
-
-        String manifestProperty = System.getProperty("android.manifest");
-        String resProperty = System.getProperty("android.resources");
-        String assetsProperty = System.getProperty("android.assets");
-        AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty),
-                Fs.fileFromPath(assetsProperty)){
-        };
-        manifest.setPackageName("org.openyolo.api");
-        return manifest;
-    }
-}
\ No newline at end of file
diff --git a/api/res/layout/provider_item.xml b/api/res/layout/provider_item.xml
index e454adf..d333703 100644
--- a/api/res/layout/provider_item.xml
+++ b/api/res/layout/provider_item.xml
@@ -1,45 +1,46 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="48dp"
     android:clickable="true"
+    android:focusable="true"
     android:background="?attr/selectableItemBackground"
     android:orientation="horizontal"
     android:gravity="center_vertical">
 
     <ImageView
         android:id="@+id/provider_icon"
         android:layout_width="24dp"
         android:layout_height="24dp"
         android:contentDescription="@string/provider_icon_contentDescription" />
 
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:layout_marginLeft="32dp"
         android:layout_marginStart="32dp"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/provider_name"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
             tools:text="Provider Name"/>
 
         <TextView
             android:id="@+id/unsafe_provider_warning"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:drawableLeft="@drawable/warning_icon_compat_wrapper"
             android:drawableStart="@drawable/warning_icon_compat_wrapper"
             android:drawablePadding="4dp"
             android:text="@string/possibly_unsafe"
             android:textAppearance="@style/TextAppearance.AppCompat.Caption"
             android:textColor="@color/amber_700_54pc"/>
     </LinearLayout>
 
 </LinearLayout>
diff --git a/bbq/build.gradle b/bbq/build.gradle
index ba31012..48dd384 100644
--- a/bbq/build.gradle
+++ b/bbq/build.gradle
@@ -21,6 +21,6 @@ android {
 dependencies {
-    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    compile "org.hamcrest:hamcrest-core:1.3"
-    compile "org.valid4j:valid4j:0.5.0"
+    implementation "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
+    implementation "org.hamcrest:hamcrest-core:${rootProject.ext.hamcrestVersion}"
+    implementation "org.valid4j:valid4j:${rootProject.ext.valid4jVersion}"
     apply from:'../config/testdeps.gradle', to:it
 }
diff --git a/build.gradle b/build.gradle
index b3ec84b..10d112a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,17 +1,15 @@
-apply from: 'config/localprops.gradle'
-
 buildscript {
     repositories {
         jcenter()
+        maven { url 'https://maven.google.com' }
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.3.1'
+        classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
-        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
         classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }
@@ -55,18 +53,21 @@ task showVersion {
 project.ext.minSdkVersion = 15
-project.ext.compileSdkVersion = 25
-project.ext.buildToolsVersion = '25.0.2'
-project.ext.supportLibVersion = '25.3.1'
+project.ext.compileSdkVersion = 26
+project.ext.buildToolsVersion = '26.0.1'
+project.ext.supportLibVersion = '26.0.1'
+project.ext.archVersion = '1.0.0-alpha5'
+project.ext.glideVersion = '4.0.0'
+project.ext.valid4jVersion = '0.5.0'
+project.ext.hamcrestVersion = '1.3'
+project.ext.guavaVersion = '23.0-android'
 
 subprojects {
     repositories {
         jcenter()
         mavenCentral()
 
-        maven {
-          url "${rootProject.androidSdkDir}/extras/android/m2repository"
-        }
+        maven { url 'https://maven.google.com' }
     }
 
     group = "org.openyolo"
     version = versionName
 }
@@ -74,3 +75,3 @@ subprojects {
 task wrapper(type: Wrapper) {
-    gradleVersion = '3.5'
+    gradleVersion = '4.1'
 }
diff --git a/config/android-common.gradle b/config/android-common.gradle
index 2daffcc..be65155 100644
--- a/config/android-common.gradle
+++ b/config/android-common.gradle
@@ -1,40 +1,40 @@
 android {
-    compileSdkVersion rootProject.compileSdkVersion
-    buildToolsVersion rootProject.buildToolsVersion
+    compileSdkVersion rootProject.ext.compileSdkVersion
+    buildToolsVersion rootProject.ext.buildToolsVersion
 
     defaultConfig {
-        minSdkVersion rootProject.minSdkVersion
-        targetSdkVersion rootProject.compileSdkVersion
-        versionCode rootProject.versionNum
-        versionName rootProject.versionName
+        minSdkVersion rootProject.ext.minSdkVersion
+        targetSdkVersion rootProject.ext.compileSdkVersion
+        versionCode rootProject.ext.versionNum
+        versionName rootProject.ext.versionName
     }
 
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_1_7
-        targetCompatibility = JavaVersion.VERSION_1_7
+        sourceCompatibility = JavaVersion.VERSION_1_8
+        targetCompatibility = JavaVersion.VERSION_1_8
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
         main.java.srcDirs = ['java']
         main.aidl.srcDirs = ['java']
         main.res.srcDir 'res'
         main.assets.srcDir 'assets'
         main.resources.srcDir 'java'
 
         test.setRoot('javatests');
         test.java.srcDir('javatests');
     }
 
     lintOptions {
         warningsAsErrors true
         disable 'InvalidPackage', 'TrulyRandom', 'GradleDependency'
     }
 
     packagingOptions {
         exclude 'META-INF/LICENSE.txt'
         exclude 'META-INF/NOTICE.txt'
     }
 }
 
 // produces a JAR containing sources
diff --git a/config/localprops.gradle b/config/localprops.gradle
deleted file mode 100644
index 92bdbd6..0000000
--- a/config/localprops.gradle
+++ /dev/null
@@ -1,52 +0,0 @@
-// infers the location of the Android SDK from the two most common environment
-// variables, ANDROID_SDK_HOME and ANDROID_HOME (in that order).
-def guessAndroidSdkLocation = {
-    def androidDir = null
-    if (System.env.ANDROID_SDK_HOME != null) {
-        logger.lifecycle("using android location from ANDROID_SDK_HOME")
-        return System.env.ANDROID_SDK_HOME
-    } else if (System.env.ANDROID_HOME != null) {
-        logger.info("using android location from ANDROID_HOME")
-        return System.env.ANDROID_HOME
-    }
-
-    return null
-}
-
-// creates a default local.properties file from inferred values and generated
-// resources
-def createLocalProperties = { localPropertiesFile ->
-    def androidDir = guessAndroidSdkLocation()
-    if (androidDir == null) {
-        logger.lifecycle([
-            "Unable to find android SDK location - please ",
-            "create a local.properties file with property sdk.dir set to ",
-            "the location of your android SDK. For example: \n",
-            "sdk.dir=/usr/local/me/android-sdk"].join())
-        throw new GradleException("Android SDK location could not be inferred")
-    }
-
-    def props = new Properties()
-    props.setProperty("sdk.dir", androidDir);
-
-    localPropertiesFile.withWriter('UTF-8') { props.store(it, null) }
-}
-
-
-def localPropertiesFile = file(new File(projectDir, "local.properties"))
-if (!localPropertiesFile.exists()) {
-    logger.lifecycle("local.properties file missing - attempting to " +
-            "create one")
-    createLocalProperties(localPropertiesFile)
-}
-
-def props = new Properties()
-localPropertiesFile.withInputStream {
-    props.load(it)
-}
-
-if (!props.stringPropertyNames().contains('sdk.dir')) {
-    throw new GradleException('sdk.dir not defined in local.properties')
-}
-
-ext.androidSdkDir = props.get("sdk.dir")
diff --git a/config/protobuf.gradle b/config/protobuf.gradle
index 57ae945..aba159a 100644
--- a/config/protobuf.gradle
+++ b/config/protobuf.gradle
@@ -22,7 +22,7 @@ Configuration protoDepsConfig = project.configurations.create("protobufDeps") {
 Dependency protocDep = project.dependencies.add(protoDepsConfig.name, [
         group: "com.google.protobuf",
         name: "protoc",
-        version: "3.2.0",
+        version: "3.3.0",
         classifier: project.osdetector.classifier,
         ext: 'exe'
 ])
@@ -81,10 +81,10 @@ task compileProtos {
 /**
  * javalite compiled protos require this runtime dependency.
  */
 dependencies {
-    compile 'com.google.protobuf:protobuf-lite:3.0.1'
+    implementation 'com.google.protobuf:protobuf-lite:3.0.1'
 }
 
 /**
  * Ensure that the generated code is included in the source set of the library / app
  */
diff --git a/config/testdeps.gradle b/config/testdeps.gradle
index 3bf17f0..bc903c5 100644
--- a/config/testdeps.gradle
+++ b/config/testdeps.gradle
@@ -1,4 +1,5 @@
-testCompile 'junit:junit:4.12'
-testCompile 'org.mockito:mockito-core:2.7.0'
-testCompile 'org.robolectric:robolectric:3.3.2'
-testCompile 'com.squareup.assertj:assertj-android:1.1.1'
\ No newline at end of file
+testImplementation 'junit:junit:4.12'
+testImplementation 'org.mockito:mockito-core:2.8.47'
+testImplementation 'org.robolectric:robolectric:3.4.2'
+testImplementation 'com.squareup.assertj:assertj-android:1.1.1'
+testImplementation 'org.assertj:assertj-core:3.8.0'
\ No newline at end of file
diff --git a/demoproviders/barbican/build.gradle b/demoproviders/barbican/build.gradle
index 5b56c32..3df0eb3 100644
--- a/demoproviders/barbican/build.gradle
+++ b/demoproviders/barbican/build.gradle
@@ -2,3 +2,2 @@ apply plugin: 'com.android.application'
 apply plugin: 'checkstyle'
-apply plugin: 'com.neenbedankt.android-apt'
 
@@ -22,18 +21,20 @@ android {
 dependencies {
-    compile project(':spi')
-    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
-    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
-    compile "com.android.support:design:${rootProject.supportLibVersion}"
-    compile "com.android.support:recyclerview-v7:${rootProject.supportLibVersion}"
-    compile 'com.madgag.spongycastle:core:1.54.0.0'
-    compile 'com.google.guava:guava:22.0-rc1-android'
+    implementation project(':spi')
+    implementation "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:support-vector-drawable:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
+    implementation 'com.madgag.spongycastle:core:1.54.0.0'
+    implementation "com.google.guava:guava:${rootProject.ext.guavaVersion}"
 
-    compile 'com.jakewharton:butterknife:8.5.1'
-    compile 'com.github.bumptech.glide:glide:3.7.0'
-    apt 'com.jakewharton:butterknife-compiler:8.5.1'
+    implementation 'com.jakewharton:butterknife:8.5.1'
+    implementation "com.github.bumptech.glide:glide:${rootProject.ext.glideVersion}"
+
+    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
+    annotationProcessor "com.github.bumptech.glide:compiler:${rootProject.glideVersion}"
 
     apply from: "${rootDir}/config/testdeps.gradle", to:it
-    testCompile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    testCompile 'com.google.guava:guava:22.0-rc1-android'
+    testImplementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    testImplementation 'com.google.guava:guava:22.0-rc1-android'
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
index d7b552f..e82d912 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
@@ -16,2 +16,3 @@ package org.openyolo.demoprovider.barbican;
 
+import android.annotation.SuppressLint;
 import android.content.pm.ApplicationInfo;
@@ -51,253 +52,257 @@ import org.openyolo.protocol.Credential;
 /**
  * Creates credentials from manual user input for storage.
  */
 public class CreateCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "CreateCredential";
 
     private static final int MIN_ID_LENGTH = 1;
     private static final int MIN_PASS_LENGTH = 1;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.headerToolbar)
     Toolbar mToolbar;
 
     @BindView(R.id.appBar)
     AppBarLayout mAppBar;
 
     @BindView(R.id.credential_authority)
     Spinner mCredentialAuthority;
 
     @BindView(R.id.credential_id)
     EditText mCredentialId;
 
     @BindView(R.id.credential_password)
     EditText mCredentialPassword;
 
     private MenuItem mDoneButton;
 
     private CredentialStorageClient mStorageClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.create_credential_layout);
         ButterKnife.bind(this);
         getSupportActionBar();
         setSupportActionBar(mToolbar);
         mToolbar.setNavigationIcon(R.drawable.back);
         mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 finish();
             }
         });
         mCredentialAuthority.setAdapter(new AppAdapter(getInstalledApps()));
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.menu_create, menu);
         mDoneButton = menu.findItem(R.id.action_done);
         onFieldsChanged();
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (super.onOptionsItemSelected(item)) {
             return true;
         }
 
         if (R.id.action_done == item.getItemId()) {
             App app = (App) mCredentialAuthority.getSelectedItem();
             String username = mCredentialId.getText().toString();
             String password = mCredentialPassword.getText().toString();
             new StoreCredentialTask(app.mPackageName, username, password).execute();
         }
 
         return false;
     }
 
     @OnItemSelected(R.id.credential_authority)
     @OnTextChanged({R.id.credential_id, R.id.credential_password})
     void onFieldsChanged() {
         boolean validCredential =
                 mCredentialAuthority.getSelectedItemPosition() != Spinner.INVALID_POSITION
                 && mCredentialId.length() >= MIN_ID_LENGTH
                 && mCredentialPassword.length() >= MIN_PASS_LENGTH;
 
         if (mDoneButton != null) {
             mDoneButton.setEnabled(validCredential);
         }
     }
 
     private List<App> getInstalledApps() {
         List<String> appPackageNames = InstalledAppsUtil.getInstalledAppsList(this);
         ArrayList<App> apps = new ArrayList<>();
         PackageManager pm = getPackageManager();
         for (String packageName : appPackageNames) {
             try {
                 ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                 String appName = pm.getApplicationLabel(info).toString();
                 Drawable appIcon = pm.getApplicationIcon(info);
                 apps.add(new App(packageName, appName, appIcon));
             } catch (PackageManager.NameNotFoundException e) {
                 // skip this app
             }
         }
 
         return apps;
     }
 
+    @SuppressLint("StaticFieldLeak")
     private class StoreCredentialTask extends AsyncTask<Void, Void, Boolean> {
 
         final String mPackageName;
         final String mUsername;
         final String mPassword;
 
-        StoreCredentialTask(String packageName, String username, String password) {
+        StoreCredentialTask(
+                String packageName,
+                String username,
+                String password) {
             mPackageName = packageName;
             mUsername = username;
             mPassword = password;
         }
 
         @Override
         protected Boolean doInBackground(Void... params) {
             AuthenticationDomain domain = AuthenticationDomain.listForPackage(
                     CreateCredentialActivity.this,
                     mPackageName)
                     .get(0);
 
             Credential credential = new Credential.Builder(
                     mUsername,
                     AuthenticationMethods.EMAIL,
                     domain)
                     .setPassword(mPassword)
                     .build();
             try {
                 mStorageClient.upsertCredential(credential.toProtobuf());
                 return true;
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to upsert credential to database");
             }
             return null;
         }
 
         @Override
         protected void onPostExecute(Boolean success) {
             if (success) {
                 finish();
             } else {
                 Snackbar.make(
                         mRootView,
                         R.string.save_failed,
                         Snackbar.LENGTH_SHORT).show();
             }
         }
     }
 
     private class App implements Comparable<App> {
         @NonNull String mName;
         @NonNull String mPackageName;
         @Nullable Drawable mIcon;
 
         App(@NonNull String packageName, @NonNull String name, @Nullable Drawable icon) {
             mPackageName = packageName;
             mName = name;
             mIcon = icon;
         }
 
         @Override
         public int compareTo(@NonNull App app) {
             return mName.compareTo(app.mName);
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (!(obj instanceof App)) {
                 return false;
             }
 
             App other = (App) obj;
             return mPackageName.equals(other.mPackageName);
         }
 
         @Override
         public int hashCode() {
             return mPackageName.hashCode();
         }
     }
 
     private class AppAdapter extends BaseAdapter {
 
         private final List<App> mApps;
         private final LayoutInflater mInflater;
 
         AppAdapter(@NonNull List<App> apps) {
             mApps = apps;
             mInflater = LayoutInflater.from(CreateCredentialActivity.this);
         }
 
         @Override
         public int getCount() {
             return mApps.size();
         }
 
         @Override
         public Object getItem(int index) {
             return mApps.get(index);
         }
 
         @Override
         public long getItemId(int index) {
             return mApps.get(index).hashCode();
         }
 
         @Override
         public View getView(int index, View view, ViewGroup viewGroup) {
             App app = mApps.get(index);
             if (view == null) {
                 view = mInflater.inflate(R.layout.app_item, viewGroup, false);
             }
 
             ImageView iconView = (ImageView) view.findViewById(R.id.app_icon);
             if (app.mIcon != null) {
                 iconView.setImageDrawable(app.mIcon);
                 iconView.setVisibility(View.VISIBLE);
             } else {
                 iconView.setVisibility(View.INVISIBLE);
             }
 
             TextView nameView = (TextView) view.findViewById(R.id.app_name);
             nameView.setText(app.mName);
 
             return view;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
index cfdfa89..4dd7049 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
@@ -16,2 +16,3 @@ package org.openyolo.demoprovider.barbican;
 
+import android.annotation.SuppressLint;
 import android.content.Intent;
@@ -37,112 +38,113 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * Displays the user's stored credentials.
  */
 public class CredentialListActivity
         extends AppCompatActivity
         implements ConnectedCallback {
 
     private static final String LOG_TAG = "CLActivity";
 
     private CredentialStorageClient mStorageClient;
 
     @BindView(R.id.headerToolbar)
     Toolbar mToolbar;
 
     @BindView(R.id.credential_list)
     RecyclerView mCredentialsView;
 
     private CredentialAdapter mCredentialAdapter;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.credential_list_layout);
         ButterKnife.bind(this);
         setSupportActionBar(mToolbar);
         mCredentialAdapter = new CredentialAdapter();
         mCredentialsView.setAdapter(mCredentialAdapter);
         mCredentialsView.setLayoutManager(
                 new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
         mCredentialAdapter.setCredentialStorageClient(client);
         if (checkUnlocked()) {
             new LoadCredentialsTask().execute();
         }
     }
 
     private boolean checkUnlocked() {
         if (!mStorageClient.isUnlocked()) {
             startActivity(new Intent(this, UnlockActivity.class));
             finish();
             return false;
         }
         return true;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.menu_main, menu);
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (super.onOptionsItemSelected(item)) {
             return true;
         }
 
         if (R.id.action_lock == item.getItemId()) {
             mStorageClient.lock();
             startActivity(new Intent(this, UnlockActivity.class));
             finish();
             return true;
         }
 
         if (R.id.action_wipe == item.getItemId()) {
             startActivity(new Intent(this, NeverSaveListActivity.class));
             return true;
         }
         return false;
     }
 
     @OnClick(R.id.create_credential)
     void onCreateCredential() {
         startActivity(new Intent(this, CreateCredentialActivity.class));
     }
 
+    @SuppressLint("StaticFieldLeak")
     private class LoadCredentialsTask extends AsyncTask<Void, Void, List<Credential>> {
 
         @Override
         protected List<Credential> doInBackground(Void... params) {
             try {
                 return mStorageClient.listAllCredentials();
             } catch (IOException ex) {
                 Log.e(LOG_TAG, "Failed to list credentials", ex);
                 return null;
             }
         }
 
         @Override
         protected void onPostExecute(List<Credential> credentials) {
             if (credentials != null) {
                 ((CredentialAdapter) mCredentialsView.getAdapter()).setCredentials(credentials);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/GlideModule.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/GlideModule.java
new file mode 100644
index 0000000..e4bfad6
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/GlideModule.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import com.bumptech.glide.module.AppGlideModule;
+
+/**
+ * Required definition for use of the Glide generated API.
+ * @see "http://bumptech.github.io/glide/doc/generatedapi.html"
+ */
+@com.bumptech.glide.annotation.GlideModule
+public class GlideModule extends AppGlideModule {}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java
index a16c04a..a40315d 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java
@@ -16,2 +16,3 @@ package org.openyolo.demoprovider.barbican;
 
+import android.annotation.SuppressLint;
 import android.content.Context;
@@ -31,127 +32,128 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 public class UnlockActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String EXTRA_AS_DIALOG = "asDialog";
     private static final String EXTRA_AFTER_UNLOCK = "afterUnlock";
     private static final String LOG_TAG = "UnlockActivity";
 
     private CredentialStorageClient mStorageClient;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.password_entry)
     View mPasswordEntryForm;
 
     @BindView(R.id.invalid_password)
     View mInvalidPasswordError;
 
     @BindView(R.id.password)
     EditText mPasswordField;
 
     @BindView(R.id.loading)
     View mLoadingView;
 
     /**
      * Creates an intent to display the unlock screen, triggering the provided intent after
      * unlock.
      */
     public static Intent createIntent(Context context, boolean asDialog, Intent afterUnlock) {
         Intent intent = new Intent(context, UnlockActivity.class);
         intent.putExtra(EXTRA_AS_DIALOG, asDialog);
         intent.putExtra(EXTRA_AFTER_UNLOCK, afterUnlock);
         return intent;
     }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (showAsDialog()) {
             setTheme(R.style.AppTheme_Dialog);
         } else {
             setTheme(R.style.AppTheme_NoActionBar);
         }
 
         setContentView(R.layout.unlock_layout);
         ButterKnife.bind(this);
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
 
         if (client.isUnlocked()) {
             startActivity(getAfterUnlock());
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @OnEditorAction(R.id.password)
     boolean onPasswordConfirmedViaIme() {
         new UnlockTask(mPasswordField.getText().toString()).execute();
         return true;
     }
 
     private boolean showAsDialog() {
         return getIntent().getBooleanExtra(EXTRA_AS_DIALOG, false);
     }
 
     private Intent getAfterUnlock() {
         if (getIntent().hasExtra(EXTRA_AFTER_UNLOCK)) {
             return getIntent().getParcelableExtra(EXTRA_AFTER_UNLOCK);
         } else {
             return new Intent(this, CredentialListActivity.class);
         }
     }
 
+    @SuppressLint("StaticFieldLeak")
     private class UnlockTask extends AsyncTask<Void, Void, Boolean> {
 
         private final String mPassword;
 
         UnlockTask(String password) {
             mPassword = password;
         }
 
         @Override
         protected void onPreExecute() {
             mPasswordEntryForm.setVisibility(View.GONE);
             mLoadingView.setVisibility(View.VISIBLE);
         }
 
         @Override
         protected Boolean doInBackground(Void... params) {
             try {
                 return mStorageClient.unlock(mPassword);
             } catch (IOException ex) {
                 Log.e(LOG_TAG, "Failed to unlock credential store", ex);
                 return false;
             }
         }
 
         @Override
         protected void onPostExecute(Boolean result) {
             if (result) {
                 startActivity(getAfterUnlock());
                 finish();
             } else {
                 mPasswordEntryForm.setVisibility(View.VISIBLE);
                 mInvalidPasswordError.setVisibility(View.VISIBLE);
                 mLoadingView.setVisibility(View.GONE);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java
index 9cbd307..9a785f8 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java
@@ -16,2 +16,3 @@ package org.openyolo.demoprovider.barbican;
 
+import android.annotation.SuppressLint;
 import android.content.Intent;
@@ -31,99 +32,100 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 public class WelcomeActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "WelcomeActivity";
     private static final int MIN_PASSWORD_SIZE = 6;
 
     private CredentialStorageClient mStorageClient;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.password)
     EditText mPasswordField;
 
     @BindView(R.id.loading)
     View mLoadingView;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.welcome_layout);
         ButterKnife.bind(this);
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @OnEditorAction(R.id.password)
     boolean onPasswordConfirmedViaIme() {
         if (!isPasswordValid(mPasswordField.getText().toString())) {
             return false;
         }
 
         initializeStorage();
         return true;
     }
 
     private boolean isPasswordValid(String password) {
         return password.length() >= MIN_PASSWORD_SIZE;
     }
 
     private void initializeStorage() {
         new InitializeStorageTask(mPasswordField.getText().toString()).execute();
     }
 
+    @SuppressLint("StaticFieldLeak")
     private class InitializeStorageTask extends AsyncTask<Void, Void, Boolean> {
 
         private String mPassword;
 
         InitializeStorageTask(String password) {
             mPassword = password;
         }
 
         @Override
         protected void onPreExecute() {
             mPasswordField.setVisibility(View.GONE);
             mLoadingView.setVisibility(View.VISIBLE);
         }
 
         protected Boolean doInBackground(Void... params) {
             try {
                 mStorageClient.create(mPassword);
                 return true;
             } catch (IOException ex) {
                 Log.e(LOG_TAG, "Failed to create credential storage", ex);
                 return false;
             }
         }
 
         @Override
         protected void onPostExecute(Boolean success) {
             if (success) {
                 startActivity(new Intent(WelcomeActivity.this, CredentialListActivity.class));
                 finish();
             } else {
                 mPasswordField.setVisibility(View.VISIBLE);
                 mLoadingView.setVisibility(View.GONE);
                 Snackbar.make(mRootView,
                         R.string.create_failure,
                         Snackbar.LENGTH_LONG).show();
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
index b8c94da..692d34b 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
@@ -23,3 +23,3 @@ import android.widget.ImageView;
 import android.widget.TextView;
-import com.bumptech.glide.Glide;
+import org.openyolo.demoprovider.barbican.GlideApp;
 import org.openyolo.demoprovider.barbican.R;
@@ -31,85 +31,85 @@ import org.openyolo.protocol.Hint;
 /**
  * RecyclerView holder for displaying account options to the user in a credential or hint picker.
  */
 public final class AccountViewHolder extends RecyclerView.ViewHolder {
 
     private ImageView mProfileIcon;
     private TextView mPrimaryLabel;
     private TextView mSecondaryLabel;
 
     AccountViewHolder(View itemView) {
         super(itemView);
 
         mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
         mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
         mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
     }
 
     void bind(final Credential credential, ClickHandler<Credential> clickHandler) {
         bind(
                 credential.getIdentifier(),
                 credential.getAuthenticationMethod(),
                 credential.getDisplayName(),
                 credential.getDisplayPicture(),
                 credential,
                 clickHandler);
     }
 
     void bind(final Hint hint, ClickHandler<Hint> clickHandler) {
         bind(
                 hint.getIdentifier(),
                 hint.getAuthenticationMethod(),
                 hint.getDisplayName(),
                 hint.getDisplayPictureUri(),
                 hint,
                 clickHandler);
     }
 
     <T> void bind(
             @NonNull String id,
             @NonNull AuthenticationMethod authMethod,
             @Nullable String displayName,
             @Nullable Uri profilePictureUri,
             @NonNull final T sourceObject,
             @NonNull final ClickHandler<T> clickHandler) {
 
         int iconId;
         if (AuthenticationMethods.EMAIL.equals(authMethod)) {
             iconId = R.drawable.email;
         } else if (AuthenticationMethods.PHONE.equals(authMethod)) {
             iconId = R.drawable.phone;
         } else {
             iconId = R.drawable.person;
         }
 
         if (profilePictureUri != null) {
-            Glide.with(mProfileIcon.getContext())
+            GlideApp.with(mProfileIcon.getContext())
                     .load(profilePictureUri)
                     .fitCenter()
                     .fallback(iconId)
                     .into(mProfileIcon);
         } else {
             mProfileIcon.setImageResource(iconId);
         }
 
         if (displayName != null) {
             mPrimaryLabel.setText(displayName);
             mSecondaryLabel.setText(id);
             mSecondaryLabel.setVisibility(View.VISIBLE);
         } else {
             mPrimaryLabel.setText(id);
             mSecondaryLabel.setVisibility(View.GONE);
         }
 
         itemView.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 clickHandler.onClick(sourceObject);
             }
         });
     }
 
     interface ClickHandler<T> {
         void onClick(T clicked);
     }
 }
diff --git a/demoproviders/barbican/res/drawable/create.xml b/demoproviders/barbican/res/drawable/create.xml
index 81dab71..c139013 100644
--- a/demoproviders/barbican/res/drawable/create.xml
+++ b/demoproviders/barbican/res/drawable/create.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24"
         android:viewportHeight="24">
     <path
         android:fillColor="#FFFFFF"
-        android:pathData="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39 .39 -1.02
-0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" />
+        android:pathData="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c0.39-0.39 0.39 -1.02
+0-1.41l-2.34-2.34c-0.39-0.39-1.02-0.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" />
 </vector>
diff --git a/demoproviders/barbican/res/drawable/lock.xml b/demoproviders/barbican/res/drawable/lock.xml
index af07ddc..b9cf806 100644
--- a/demoproviders/barbican/res/drawable/lock.xml
+++ b/demoproviders/barbican/res/drawable/lock.xml
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24"
         android:viewportHeight="24">
 
     <path
         android:fillColor="#FFFFFF"
-        android:pathData="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1 .9 2 2
-2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9
+        android:pathData="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 0.9-2 2v10c0 1.1 0.9 2 2
+2h12c1.1 0 2-0.9 2-2V10c0-1.1-0.9-2-2-2zm-6 9c-1.1 0-2-0.9-2-2s0.9-2 2-2 2 0.9 2 2-0.9
 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" />
 </vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/unlock.xml b/demoproviders/barbican/res/drawable/unlock.xml
index 7514b5f..b7ae7bc 100644
--- a/demoproviders/barbican/res/drawable/unlock.xml
+++ b/demoproviders/barbican/res/drawable/unlock.xml
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24"
         android:viewportHeight="24">
 
     <path
         android:fillColor="#FFFFFF"
-        android:pathData="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7
-3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2
-2v10c0 1.1 .9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z" />
+        android:pathData="M12 17c1.1 0 2-0.9 2-2s-0.9-2-2-2-2 0.9-2 2 0.9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7
+3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 0.9-2
+2v10c0 1.1 0.9 2 2 2h12c1.1 0 2-0.9 2-2V10c0-1.1-0.9-2-2-2zm0 12H6V10h12v10z" />
 </vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/credential_picker_item_view.xml b/demoproviders/barbican/res/layout/credential_picker_item_view.xml
index 9189222..c598601 100644
--- a/demoproviders/barbican/res/layout/credential_picker_item_view.xml
+++ b/demoproviders/barbican/res/layout/credential_picker_item_view.xml
@@ -1,46 +1,47 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="60dp"
     android:clickable="true"
+    android:focusable="true"
     android:background="?attr/selectableItemBackground"
     android:orientation="horizontal"
     android:gravity="center_vertical">
 
     <ImageView
         android:id="@+id/credential_icon"
         android:layout_width="32dp"
         android:layout_height="32dp"
         android:layout_marginLeft="16dp"
         android:layout_marginStart="16dp"
         android:contentDescription="@string/credential_icon" />
 
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginLeft="24dp"
         android:layout_marginStart="24dp"
         android:layout_marginRight="16dp"
         android:layout_marginEnd="16dp"
         android:layout_weight="1"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/credential_primary_label"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
 
         <TextView
             android:id="@+id/credential_secondary_label"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Body1"
             tools:text="test@tester.com" />
 
     </LinearLayout>
 
 </LinearLayout>
diff --git a/demoproviders/barbican/res/layout/credential_view.xml b/demoproviders/barbican/res/layout/credential_view.xml
index 8adab33..9c37599 100644
--- a/demoproviders/barbican/res/layout/credential_view.xml
+++ b/demoproviders/barbican/res/layout/credential_view.xml
@@ -1,48 +1,49 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="60dp"
     android:clickable="true"
+    android:focusable="true"
     android:background="?attr/selectableItemBackground"
     android:orientation="horizontal"
     android:gravity="center_vertical"
     tools:ignore="Overdraw">
 
     <ImageView
         android:id="@+id/credential_authority_icon"
         android:layout_width="24dp"
         android:layout_height="24dp"
         android:layout_marginLeft="16dp"
         android:layout_marginStart="16dp"
         android:contentDescription="@string/credential_authority_icon"
         android:visibility="invisible" />
 
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginLeft="32dp"
         android:layout_marginStart="32dp"
         android:layout_marginRight="16dp"
         android:layout_marginEnd="16dp"
         android:layout_weight="1"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/credential_authority"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
 
         <TextView
             android:id="@+id/credential_id"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Body1"
             tools:text="test@tester.com" />
 
     </LinearLayout>
 
 </LinearLayout>
diff --git a/demoproviders/barbican/res/layout/paired_api_item.xml b/demoproviders/barbican/res/layout/paired_api_item.xml
index 6ac27a9..4425e21 100644
--- a/demoproviders/barbican/res/layout/paired_api_item.xml
+++ b/demoproviders/barbican/res/layout/paired_api_item.xml
@@ -1,59 +1,60 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="60dp"
     android:background="?attr/selectableItemBackground"
     android:clickable="true"
+    android:focusable="true"
     android:gravity="center_vertical"
     android:orientation="horizontal"
     tools:ignore="Overdraw">
 
     <ImageView
         android:id="@+id/api_icon"
         android:layout_width="24dp"
         android:layout_height="24dp"
         android:layout_marginLeft="16dp"
         android:layout_marginStart="16dp"
         android:contentDescription="@string/credential_authority_icon"
         android:visibility="invisible"/>
 
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginEnd="16dp"
         android:layout_marginLeft="32dp"
         android:layout_marginRight="16dp"
         android:layout_marginStart="32dp"
         android:layout_weight="1"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/paired_api_title"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Body2"
             android:textColor="@android:color/black"/>
 
         <TextView
             android:id="@+id/paired_api_desc"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Body1"
             android:textColor="@android:color/black"
             tools:text="test@tester.com"/>
 
     </LinearLayout>
 
     <ImageButton
         android:id="@+id/btn_delete"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_vertical"
         android:src="@android:drawable/ic_delete"
         android:background="@android:drawable/screen_background_light_transparent"
         android:contentDescription="@string/remove_unpaired_api_dialog_title"/>
 
 </LinearLayout>
diff --git a/demoproviders/trapdoor/build.gradle b/demoproviders/trapdoor/build.gradle
index f28198b..69851c2 100644
--- a/demoproviders/trapdoor/build.gradle
+++ b/demoproviders/trapdoor/build.gradle
@@ -2,3 +2,2 @@ apply plugin: 'com.android.application'
 apply plugin: 'checkstyle'
-apply plugin: 'com.neenbedankt.android-apt'
 
@@ -21,18 +20,20 @@ android {
 dependencies {
-    compile project(':spi')
-    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
-    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
-    compile "com.android.support:design:${rootProject.supportLibVersion}"
-    compile 'com.madgag.spongycastle:core:1.54.0.0'
+    implementation project(':spi')
+    implementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    implementation "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    implementation "com.android.support:design:${rootProject.supportLibVersion}"
+    implementation 'com.madgag.spongycastle:core:1.54.0.0'
 
     // stylish pin entry field
-    compile 'me.philio:pinentryview:1.0.6'
+    implementation 'me.philio:pinentryview:1.0.6'
 
-    compile 'com.jakewharton:butterknife:8.5.1'
-    compile 'com.github.bumptech.glide:glide:3.7.0'
-    apt 'com.jakewharton:butterknife-compiler:8.5.1'
+    implementation 'com.jakewharton:butterknife:8.5.1'
+    implementation "com.github.bumptech.glide:glide:${rootProject.ext.glideVersion}"
+
+    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
+    annotationProcessor "com.github.bumptech.glide:compiler:${rootProject.glideVersion}"
 
     apply from: "${rootDir}/config/testdeps.gradle", to:it
-    testCompile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    testImplementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
 }
diff --git a/demoproviders/trapdoor/res/drawable-v23/splash.xml b/demoproviders/trapdoor/res/drawable-v23/splash.xml
deleted file mode 100644
index c1ed4ba..0000000
--- a/demoproviders/trapdoor/res/drawable-v23/splash.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item
-        android:drawable="@color/colorLight"
-        android:gravity="fill"/>
-
-    <item android:drawable="@drawable/app_icon"
-        android:gravity="center"
-        android:width="192dp"
-        android:height="192dp">
-    </item>
-
-</layer-list>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/drawable/splash.xml b/demoproviders/trapdoor/res/drawable/splash.xml
deleted file mode 100644
index 488b397..0000000
--- a/demoproviders/trapdoor/res/drawable/splash.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item android:drawable="@color/colorLight" />
-
-    <item>
-        <bitmap
-            android:gravity="center"
-            android:src="@mipmap/ic_launcher" />
-    </item>
-
-</layer-list>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/values/styles.xml b/demoproviders/trapdoor/res/values/styles.xml
index 4f06a59..ea48dba 100644
--- a/demoproviders/trapdoor/res/values/styles.xml
+++ b/demoproviders/trapdoor/res/values/styles.xml
@@ -1,48 +1,28 @@
 <resources>
     <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
         <item name="colorAccent">@color/colorAccent</item>
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
     </style>
 
     <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
         <item name="colorAccent">@color/colorAccent</item>
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
         <item name="android:background">@color/colorLight</item>
     </style>
 
-    <style name="AppTheme.NoUi" parent="Theme.AppCompat.NoActionBar">
-        <item name="android:colorBackgroundCacheHint">@null</item>
-        <item name="android:windowAnimationStyle">@null</item>
-        <item name="android:windowBackground">@android:color/transparent</item>
-        <item name="android:windowIsTranslucent">true</item>
-    </style>
-
     <style name="AppTheme.Dialog" parent="Theme.AppCompat.Dialog">
         <item name="android:windowActionBar">false</item>
         <item name="android:windowBackground">@android:color/transparent</item>
         <item name="android:windowMinWidthMajor">80%</item>
         <item name="android:windowMinWidthMinor">80%</item>
         <item name="android:background">@color/colorPrimary</item>
         <item name="windowNoTitle">true</item>
     </style>
 
-    <style name="AutoSignInTheme" parent="Theme.AppCompat">
-        <item name="android:backgroundDimEnabled">false</item>
-        <item name="android:windowBackground">@android:color/transparent</item>
-        <item name="android:windowIsFloating">true</item>
-        <item name="windowActionBar">false</item>
-        <item name="windowNoTitle">true</item>
-    </style>
-
-    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
-        <item name="android:windowBackground">@drawable/splash</item>
-        <item name="android:windowAnimationStyle">@null</item>
-    </style>
-
     <style name="PrimaryButtonStyle" parent="Widget.AppCompat.Button.Colored">
         <item name="colorButtonNormal">@color/colorAccent</item>
         <item name="android:textColor">@android:color/white</item>
     </style>
 </resources>
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 58549d5..7f4c491 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 4161a3e..7aee524 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,2 +1,2 @@
-#Tue Apr 11 14:41:57 PDT 2017
+#Tue Aug 08 12:20:01 PDT 2017
 distributionBase=GRADLE_USER_HOME
@@ -5,2 +5,2 @@ zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/gradlew b/gradlew
index 4453cce..cccdd3d 100755
--- a/gradlew
+++ b/gradlew
@@ -35,13 +35,13 @@ MAX_FD="maximum"
 
-warn ( ) {
+warn () {
     echo "$*"
 }
 
-die ( ) {
+die () {
     echo
     echo "$*"
     echo
     exit 1
 }
 
 # OS specific support (must be 'true' or 'false').
@@ -157,5 +157,5 @@ fi
 # Escape application args
-save ( ) {
+save () {
     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
     echo " "
 }
diff --git a/protocol/build.gradle b/protocol/build.gradle
index 63b950d..121a3b6 100644
--- a/protocol/build.gradle
+++ b/protocol/build.gradle
@@ -21,6 +21,7 @@ android {
 dependencies {
-    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    compile "org.hamcrest:hamcrest-core:1.3"
-    compile "org.valid4j:valid4j:0.5.0"
+    api 'com.google.protobuf:protobuf-lite:3.0.1'
+    implementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    implementation "org.hamcrest:hamcrest-core:${rootProject.ext.hamcrestVersion}"
+    implementation "org.valid4j:valid4j:${rootProject.ext.valid4jVersion}"
     apply from:'../config/testdeps.gradle', to:it
 }
diff --git a/spi/build.gradle b/spi/build.gradle
index b036508..fc1548e 100644
--- a/spi/build.gradle
+++ b/spi/build.gradle
@@ -19,8 +19,10 @@ android {
 dependencies {
-    compile project(':bbq')
-    compile project(':protocol')
+    api project(':bbq')
+    api project(':protocol')
 
-    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    implementation "org.hamcrest:hamcrest-core:${rootProject.ext.hamcrestVersion}"
+    implementation "org.valid4j:valid4j:${rootProject.ext.valid4jVersion}"
+    implementation "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     apply from:'../config/testdeps.gradle', to:it
 }
diff --git a/testapp/build.gradle b/testapp/build.gradle
index 5caa162..51c5085 100644
--- a/testapp/build.gradle
+++ b/testapp/build.gradle
@@ -2,3 +2,2 @@ apply plugin: 'com.android.application'
 apply plugin: 'checkstyle'
-apply plugin: 'com.neenbedankt.android-apt'
 
@@ -35,12 +34,16 @@ android {
 dependencies {
-    compile project(':api')
-    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
-    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
-    compile "com.android.support:design:${rootProject.supportLibVersion}"
-    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
-    compile 'com.google.guava:guava:20.0'
+    implementation project(':api')
+    implementation project(':protocol')
+    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:support-vector-drawable:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
+    implementation "com.android.support:support-vector-drawable:${rootProject.ext.supportLibVersion}"
+    implementation "com.github.bumptech.glide:glide:${rootProject.ext.glideVersion}"
+    implementation "com.google.guava:guava:${rootProject.ext.guavaVersion}"
+    implementation 'com.jakewharton:butterknife:8.5.1'
+    implementation "org.hamcrest:hamcrest-core:${rootProject.ext.hamcrestVersion}"
+    implementation "org.valid4j:valid4j:${rootProject.ext.valid4jVersion}"
 
-    compile 'com.jakewharton:butterknife:8.5.1'
-    compile 'com.github.bumptech.glide:glide:3.7.0'
-    apt 'com.jakewharton:butterknife-compiler:8.5.1'
+    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
+    annotationProcessor "com.github.bumptech.glide:compiler:${rootProject.glideVersion}"
 }
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 9a490f9..14fa734 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -31,3 +31,2 @@ import butterknife.OnClick;
 import butterknife.OnTextChanged;
-import com.bumptech.glide.Glide;
 import org.openyolo.protocol.AuthenticationDomain;
@@ -41,231 +40,231 @@ import org.valid4j.errors.RequireViolation;
 public final class CredentialView extends LinearLayout {
 
     private static final String TAG = "CredentialView";
 
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_email_provider_button)
     ImageButton mEmailProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
     /**
      * Simple constructor to use when creating a credential view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mEmailProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void setEmailAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
-        Glide.with(getContext())
+        GlideApp.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Populates the fragment's fields from a given OpenYOLO hint.
      */
     public void setFieldsFromHint(Hint hint) {
         copyIfNotNull(hint.getIdentifier(), mIdField);
         copyIfNotNull(hint.getGeneratedPassword(), mPasswordField);
         copyIfNotNull(hint.getDisplayName(), mDisplayNameField);
         copyIfNotNull(hint.getDisplayPictureUri(), mProfilePictureField);
         copyIfNotNull(hint.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authMethodStr = mAuthenticationMethodField.getText().toString();
         AuthenticationMethod authMethod;
         try {
             authMethod = new AuthenticationMethod(authMethodStr);
         } catch (RequireViolation ex) {
             Log.w(TAG, "User entered authentication method " + authMethodStr + " is invalid", ex);
             return null;
         }
 
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethod,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         credentialBuilder.setPassword(mPasswordField.getText().toString());
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/GlideModule.java b/testapp/java/org/openyolo/testapp/GlideModule.java
new file mode 100644
index 0000000..21f204f
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/GlideModule.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import com.bumptech.glide.module.AppGlideModule;
+
+/**
+ * Required definition for use of the Glide generated API.
+ * @see "http://bumptech.github.io/glide/doc/generatedapi.html"
+ */
+@com.bumptech.glide.annotation.GlideModule
+public class GlideModule extends AppGlideModule {}
diff --git a/testapp/res/drawable/account_box_24dp.xml b/testapp/res/drawable/account_box_24dp.xml
index 37af34b..82c5e23 100644
--- a/testapp/res/drawable/account_box_24dp.xml
+++ b/testapp/res/drawable/account_box_24dp.xml
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
   android:width="24dp"
   android:height="24dp"
   android:viewportWidth="24"
   android:viewportHeight="24">
 
   <path
     android:fillColor="#000000"
-    android:pathData="M3 5v14c0 1.1 .89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2
-2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3zm-9 8c0-2 4-3.1
-6-3.1s6 1.1 6 3.1v1H6v-1z" />
+    android:pathData="M3 5v14c0 1.1 0.89 2 2 2h14c1.1 0 2-0.9 2-2V5c0-1.1-0.9-2-2-2H5c-1.11 0-2
+0.9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6
+3.1v1H6v-1z" />
   <path
     android:pathData="M0 0h24v24H0z" />
 </vector>
\ No newline at end of file
diff --git a/testapp/res/drawable/facebook_24dp.xml b/testapp/res/drawable/facebook_24dp.xml
index 2414208..7965b83 100644
--- a/testapp/res/drawable/facebook_24dp.xml
+++ b/testapp/res/drawable/facebook_24dp.xml
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:width="24dp"
     android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
 
     <path
         android:fillColor="#3d539e"
-        android:pathData="M21.786 23c.67 0 1.214-.544 1.214-1.214V2.214C23 1.544 22.456 1 21.786
+        android:pathData="M21.786 23c0.67 0 1.214-0.544 1.214-1.214V2.214C23 1.544 22.456 1 21.786
 1H2.214C1.544 1 1 1.543 1 2.214v19.572C1 22.456 1.543 23 2.214 23h19.572" />
     <path
         android:fillColor="#fff"
-        android:pathData="M16.18 23v-8.52h2.86l.427-3.32H16.18V9.04c0-.96 .267 -1.616
-1.645-1.616h1.758v-2.97c-.304-.04-1.347-.131-2.562-.131-2.535 0-4.27 1.547-4.27
+        android:pathData="M16.18 23v-8.52h2.86l0.427-3.32H16.18V9.04c0-0.96 0.267 -1.616
+1.645-1.616h1.758v-2.97c-0.304-0.04-1.347-0.131-2.562-0.131-2.535 0-4.27 1.547-4.27
 4.389v2.448H9.884v3.32h2.867V23h3.429" />
 </vector>
\ No newline at end of file
diff --git a/testapp/res/drawable/google_24dp.xml b/testapp/res/drawable/google_24dp.xml
index 803d028..fb9890f 100644
--- a/testapp/res/drawable/google_24dp.xml
+++ b/testapp/res/drawable/google_24dp.xml
@@ -1,26 +1,26 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:width="24dp"
     android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
 
     <path
         android:fillColor="#4285F4"
-        android:pathData="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21
+        android:pathData="M22.56 12.25c0-0.78-0.07-1.53-0.2-2.25H12v4.26h5.92c-0.26 1.37-1.04 2.53-2.21
 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" />
     <path
         android:fillColor="#34A853"
-        android:pathData="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98 .66 -2.23 1.06-3.71 1.06-2.86
+        android:pathData="M12 23c2.97 0 5.46-0.98 7.28-2.66l-3.57-2.77c-0.98 0.66 -2.23 1.06-3.71 1.06-2.86
 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" />
     <path
         android:fillColor="#FBBC05"
-        android:pathData="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43 .35 -2.09V7.07H2.18C1.43 8.55 1
-10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22 .81 -.62z" />
+        android:pathData="M5.84 14.09c-0.22-0.66-0.35-1.36-0.35-2.09s0.13-1.43 0.35 -2.09V7.07H2.18C1.43 8.55 1
+10.22 1 12s0.43 3.45 1.18 4.93l2.85-2.22 0.81 -0.62z" />
     <path
         android:fillColor="#EA4335"
-        android:pathData="M12 5.38c1.62 0 3.06 .56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99
-3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" />
+        android:pathData="M12 5.38c1.62 0 3.06 0.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99
+3.47 2.18 7.07l3.66 2.84c0.87-2.6 3.3-4.53 6.16-4.53z" />
     <path
         android:pathData="M1 1h22v22H1z" />
 </vector>
\ No newline at end of file
diff --git a/testapp/res/values/styles.xml b/testapp/res/values/styles.xml
index adefe83..6a15bf2 100644
--- a/testapp/res/values/styles.xml
+++ b/testapp/res/values/styles.xml
@@ -1,31 +1,27 @@
 <resources>
     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
         <item name="colorAccent">@color/colorAccent</item>
     </style>
 
     <style name="AppTheme.NoActionBar">
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>
     </style>
 
     <style name="SideButton" parent="Widget.AppCompat.Button.Small">
         <item name="android:layout_width">wrap_content</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_gravity">center</item>
     </style>
 
     <style name="GreenButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
         <item name="colorAccent">@color/material_color_green_600</item>
     </style>
 
-    <style name="Headline" parent="TextAppearance.AppCompat.Headline">
-        <item name="android:layout_marginBottom">16dp</item>
-    </style>
-
     <style name="DemoContent">
         <item name="android:padding">16dp</item>
     </style>
 
 </resources>

commit 348e4db2f67862361c84b0411a6c7c82d45452b2
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Wed Jun 14 17:06:11 2017 -0700

    Nullity annotation fixes on CredentialClient

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 3ac1e8c..08bfca3 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -64,442 +64,443 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
     @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             return null;
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
-    @Nullable
+    @NonNull
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return createDefaultHintRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a credential save request from the intent data returned by a provider.
      */
+    @NonNull
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
         } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return createDefaultCredentialSaveResult();
         }
     }
 
     @NonNull
     private static CredentialSaveResult createDefaultCredentialSaveResult() {
         return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
                 .build();
     }
 
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
-    @Nullable
+    @NonNull
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }

commit a0859fdd8bb9ed96b0700cb3eff86e6ba6cdc1e2
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu May 25 13:38:02 2017 -0700

    Configurations for pushing artifacts to Bintray

diff --git a/api/build.gradle b/api/build.gradle
index 8586db6..00a4c5a 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -3,2 +3,6 @@ apply from:'../config/android-common.gradle'
 
+project.ext {
+    moduleDesc = 'OpenYOLO for Android Client API'
+}
+
 android {
@@ -29 +33,2 @@ apply from: '../config/coverage.gradle'
 apply from: '../config/javadoc.gradle'
+apply from: '../config/bintray.gradle'
diff --git a/bbq/build.gradle b/bbq/build.gradle
index 05bb0f9..ba31012 100644
--- a/bbq/build.gradle
+++ b/bbq/build.gradle
@@ -6,10 +6,14 @@ apply from:'../config/third-party.gradle'
 
+project.ext {
+    moduleDesc = 'Background Broadcast Query (BBQ) Protocol'
+}
+
 android {
     defaultConfig {
         project.archivesBaseName = 'bbq'
 
-        buildConfigField('String', 'bbqVersionMajor', rootProject.ext.versionMajor)
-        buildConfigField('String', 'bbqVersionMinor', rootProject.ext.versionMinor)
-        buildConfigField('String', 'bbqVersionPatch', rootProject.ext.versionPatch)
+        buildConfigField('String', 'bbqVersionMajor', '' + rootProject.ext.versionMajor)
+        buildConfigField('String', 'bbqVersionMinor', '' + rootProject.ext.versionMinor)
+        buildConfigField('String', 'bbqVersionPatch', '' + rootProject.ext.versionPatch)
     }
 }
@@ -26 +30,2 @@ apply from: '../config/coverage.gradle'
 apply from: '../config/javadoc.gradle'
+apply from: '../config/bintray.gradle'
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 94923fb..b3ec84b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,27 +19,27 @@ buildscript {
 try {
     def grgit = org.ajoberstar.grgit.Grgit.open(dir: '.')
     def lastCommit = grgit.head()
 
     project.ext.versionNum = grgit.log(includes:['HEAD']).size()
     project.ext.versionDate = lastCommit.getDate()
     project.ext.versionName = grgit.describe()
 
     def emptyValue = "\"\"";
     if (project.ext.versionName == null) {
         project.ext.versionName = "DEV"
         project.ext.versionMajor = emptyValue
         project.ext.versionMinor = emptyValue
         project.ext.versionPatch = emptyValue
     } else {
         def parts = project.ext.versionName.split("[\\.-]")
-        project.ext.versionMajor = (parts.length > 0) ? parts[0] : emptyValue;
-        project.ext.versionMinor = (parts.length > 1) ? parts[1] : emptyValue;
-        project.ext.versionPatch = (parts.length > 2) ? parts[2] : emptyValue;
+        project.ext.versionMajor = '\"' + ((parts.length > 0) ? parts[0] : emptyValue) + '\"';
+        project.ext.versionMinor = '\"' + ((parts.length > 1) ? parts[1] : emptyValue) + '\"';
+        project.ext.versionPatch = '\"' + ((parts.length > 2) ? parts[2] : emptyValue) + '\"';
     }
 } catch (Exception ex) {
     logger.lifecycle(
         "unable to infer version information from git - using defaults")
     project.ext.versionNum = 0
     project.ext.versionDate = new Date()
     project.ext.versionName = 'DEV'
 }
@@ -60,12 +60,13 @@ project.ext.supportLibVersion = '25.3.1'
 subprojects {
     repositories {
         jcenter()
+        mavenCentral()
 
         maven {
           url "${rootProject.androidSdkDir}/extras/android/m2repository"
         }
     }
 
     group = "org.openyolo"
     version = versionName
 }
diff --git a/config/android-common.gradle b/config/android-common.gradle
index 77c67c7..2daffcc 100644
--- a/config/android-common.gradle
+++ b/config/android-common.gradle
@@ -38 +38,7 @@ android {
 }
+
+// produces a JAR containing sources
+task sourcesJar(type: Jar, dependsOn:'generateReleaseSources') {
+    from android.sourceSets.main.java.srcDirs
+    classifier = 'sources'
+}
diff --git a/config/bintray.gradle b/config/bintray.gradle
new file mode 100644
index 0000000..7e3b316
--- /dev/null
+++ b/config/bintray.gradle
@@ -0,0 +1,64 @@
+apply plugin: 'com.jfrog.bintray'
+apply plugin: 'com.github.dcendents.android-maven'
+
+bintray {
+    user = System.getenv("BINTRAY_USER")
+    key = System.getenv("BINTRAY_KEY")
+    pkg {
+        repo = "net.openid"
+        name = project.archivesBaseName
+        desc = project.moduleDesc
+        userOrg = "openid"
+        licenses = ["Apache-2.0"]
+        websiteUrl = "https://openid.github.io/OpenYOLO-Android/"
+        issueTrackerUrl = "https://github.com/openid/OpenYOLO-Android/issues"
+        vcsUrl = "https://github.com/openid/OpenYOLO-Android.git"
+        githubRepo = 'openid/OpenYOLO-Android'
+
+        version {
+            name = rootProject.versionName
+            desc = "AppAuth for Android"
+            released = rootProject.versionDate
+            vcsTag = rootProject.versionName
+        }
+    }
+    configurations = ["archives"]
+}
+
+artifacts {
+    archives sourcesJar
+    archives javadocJar
+}
+
+install {
+    repositories.mavenInstaller {
+        pom {
+            project {
+                packaging 'aar'
+                name project.ext.moduleDesc
+                url 'https://github.com/openid/OpenYOLO-Android'
+                licenses {
+                    license {
+                        name "The Apache Software License, Version 2.0"
+                        url "http://www.apache.org/licenses/LICENSE-2.0.txt"
+                        distribution "repo"
+                    }
+                }
+
+                developers {
+                    developer {
+                        id "iainmcgin"
+                        name "Iain McGinniss"
+                        email "iainmcgin@google.com"
+                    }
+                }
+
+                scm {
+                    connection "https://github.com/openid/OpenYOLO-Android.git"
+                    developerConnection "https://github.com/openid/OpenYOLO-Android.git"
+                    url 'https://github.com/openid/OpenYOLO-Android'
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/config/javadoc.gradle b/config/javadoc.gradle
index 1136381..939a74f 100644
--- a/config/javadoc.gradle
+++ b/config/javadoc.gradle
@@ -1,18 +1,33 @@
-task androidJavadocs(type: Javadoc) {
+configurations {
+    mdDoclet
+}
+
+dependencies {
+    mdDoclet 'org.jdrupes.mdoclet:doclet:1.0.3'
+}
+
+task androidJavadoc(type: Javadoc) {
     source = android.sourceSets.main.java.srcDirs
-    title = "OpenYOLO"
-    classpath = files(project.android.getBootClasspath())
+    title = "AppAuth for Android"
+    classpath += files(project.android.getBootClasspath())
     options {
+        doclet "org.jdrupes.mdoclet.MDoclet"
+        docletpath(*configurations.mdDoclet.files.asType(List))
         links "http://docs.oracle.com/javase/7/docs/api/"
         linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
     }
     exclude '**/BuildConfig.java'
     exclude '**/R.java'
 }
 
+task javadocJar(type: Jar, dependsOn:androidJavadoc) {
+    classifier = 'javadoc'
+    from androidJavadoc.destinationDir
+}
+
 afterEvaluate {
     // fixes issue where javadoc can't find android symbols ref: http://stackoverflow.com/a/34572606
-    androidJavadocs.classpath += files(android.libraryVariants.collect { variant ->
+    androidJavadoc.classpath += files(android.libraryVariants.collect { variant ->
         variant.javaCompile.classpath.files
     })
 }
diff --git a/protocol/build.gradle b/protocol/build.gradle
index d5d53dd..63b950d 100644
--- a/protocol/build.gradle
+++ b/protocol/build.gradle
@@ -5,11 +5,15 @@ apply from:'../config/protobuf.gradle'
 
+project.ext {
+    moduleDesc = 'OpenYOLO for Android Protocol'
+}
+
 android {
     defaultConfig {
-        project.archivesBaseName = 'protocol'
+        project.archivesBaseName = 'openyolo-protocol'
         consumerProguardFiles 'proguard-rules.txt'
 
         buildConfigField('String', 'clientVersionMajor', rootProject.ext.versionMajor)
         buildConfigField('String', 'clientVersionMinor', rootProject.ext.versionMinor)
         buildConfigField('String', 'clientVersionPatch', rootProject.ext.versionPatch)
     }
 }
@@ -25,2 +29,3 @@ apply from: '../config/style.gradle'
 apply from: '../config/coverage.gradle'
-apply from: '../config/javadoc.gradle'
\ No newline at end of file
+apply from: '../config/javadoc.gradle'
+apply from: '../config/bintray.gradle'
diff --git a/spi/build.gradle b/spi/build.gradle
index 05948d6..b036508 100644
--- a/spi/build.gradle
+++ b/spi/build.gradle
@@ -3,2 +3,6 @@ apply from:'../config/android-common.gradle'
 
+project.ext {
+    moduleDesc = 'OpenYOLO for Android Service Provider Interface (SPI)'
+}
+
 android {
@@ -26 +30,2 @@ apply from: '../config/coverage.gradle'
 apply from: '../config/javadoc.gradle'
+apply from: '../config/bintray.gradle'

commit a0bf079c36fce96edf176980b2801cfc30ab908c
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue May 30 19:32:47 2017 -0700

    Solid background color for logo

diff --git a/openyolo_android_lockup.svg b/openyolo_android_lockup.svg
index 33e2263..80f792f 100644
--- a/openyolo_android_lockup.svg
+++ b/openyolo_android_lockup.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 128"><g fill-rule="evenodd"><path d="M30.3 113.2a61.9 61.9 0 0 1 25.3-110v8.5a53.8 53.8 0 0 0-28.8 86.7l3.3-9.3a45.5 45.5 0 0 1 33.8-70.4V2.1L68 2a62 62 0 0 1 37.8 111.2l-2.1-6-.8-2.3-2.7-7.4-.3-1-2.8-7.7-.4-1a37 37 0 0 0-16.3-58.9v-8.7A45.5 45.5 0 0 1 106 89.1l3.3 9.3a53.7 53.7 0 0 0-37.1-88V27l-4.2-.2a37.2 37.2 0 0 0-28.6 61l-3.2 8.7-.8 2.2-2.2 6.2-1.2 3.3-1.7 5" fill="#2491eb"/><path d="M98.7 117.9a61.7 61.7 0 0 1-61.4 0l2.9-8 8.7-24.2A28.9 28.9 0 0 1 68 35a29 29 0 0 1 19.2 50.6L96 110l1.1 3 1.7 4.9zM58.3 83.8L56 90.3 50.4 106l-2.8 7.8a53.6 53.6 0 0 0 40.9 0l-2.6-7-5.8-16.4-.1-.3-2.2-6-.5-1.5a20.7 20.7 0 1 0-18.5 0l-.5 1.3" fill="#36434f"/></g><g fill-rule="evenodd"><path d="M166.8 68.7a17.7 17.7 0 0 0 16.6-11.5 20 20 0 0 0 1.4-7.4v-.1c0-2.6-.5-5.1-1.4-7.4a18.3 18.3 0 0 0-9.5-10.1c-2.2-1-4.6-1.5-7.3-1.5A17.7 17.7 0 0 0 150 42.2a20.2 20.2 0 0 0 0 14.9 18.4 18.4 0 0 0 9.6 10c2.2 1 4.6 1.6 7.3 1.6zm109.2-42h4.8l29 36.9v-37h5.1v46.1h-4.1L281 35v37.8h-5v-46zm-40.2 0H269v4.6H241v15.9H266v4.7H241V68h28.4v4.7h-33.6v-46zm-23.5 25c2 0 3.7-.2 5.2-.6a12 12 0 0 0 4-2.1 9.1 9.1 0 0 0 3.5-7.4v-.1c0-3.3-1.1-5.8-3.4-7.5a14.6 14.6 0 0 0-9-2.5h-11.7v20.3h11.4zm-16.6-25H213c2.5 0 5 .3 7 1 2.2.7 4 1.6 5.5 2.9 1.5 1.2 2.7 2.7 3.5 4.5.8 1.8 1.2 3.9 1.2 6.2a14 14 0 0 1-1.5 6.6 14 14 0 0 1-3.9 4.7 17.1 17.1 0 0 1-5.7 2.9 25 25 0 0 1-7 1H201v16.2h-5.2v-46zm-29 46.8a23.4 23.4 0 0 1-17-7 24.7 24.7 0 0 1-6.4-16.6v-.2a24.5 24.5 0 0 1 6.4-16.7 23.1 23.1 0 0 1 17-7.1 23.4 23.4 0 0 1 17 7 24.7 24.7 0 0 1 4.7 25.8 23.3 23.3 0 0 1-12.2 12.9c-2.9 1.2-6 1.9-9.6 1.9" fill="#36434f"/><path d="M340 54.5l-17.8-27.8h11.9L345 45l11.1-18.4h11.6L350 54.4v18.3h-10.2V54.5zm141.6 9.7c2 0 3.8-.4 5.5-1.2 1.8-.7 3.2-1.7 4.4-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7 13.8 13.8 0 0 0-11.2 0c-1.7.7-3.1 1.7-4.3 3a14.6 14.6 0 0 0-3.9 10.2c0 2 .3 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7zM420 26.7H430v36.9h23v9.1h-33.1v-46zm-30.3 37.5c2 0 3.9-.4 5.6-1.2 1.7-.7 3.1-1.7 4.3-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7c-1.7-.8-3.5-1.2-5.6-1.2a12.9 12.9 0 0 0-10 4.2 14.6 14.6 0 0 0-3.8 10.2c0 2 .4 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7" fill="#2491eb"/></g><g style="line-height:125%;-inkscape-font-specification:Roboto" font-size="320" font-weight="400" letter-spacing="0" word-spacing="0" fill="#36434f" font-family="Roboto"><path d="M312.6 116.6V98.2h-3.3v-2.8h3.3v-2.7c0-2.3.6-4 1.7-5.2 1.2-1.2 2.8-1.8 5-1.8l1.2.1 1.5.3-.4 2.8a6.4 6.4 0 0 0-2-.2c-1 0-2 .4-2.5 1-.6.7-.8 1.7-.8 3v2.7h4.5v2.8h-4.5v18.4h-3.7M323.6 105.8c0-3.2.9-5.8 2.5-7.8 1.7-2 4-3 7-3s5.2 1 7 3c1.6 2 2.4 4.6 2.4 7.8v.5c0 3.2-.8 5.7-2.5 7.7-1.6 2-4 3-6.9 3-3 0-5.3-1-7-3-1.6-2-2.5-4.5-2.5-7.7v-.5m3.7.5c0 2.3.5 4.1 1.4 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.4-2.1 10 10 0 0 0 1.4-5.6v-.5c0-2.3-.5-4.1-1.5-5.6a4.9 4.9 0 0 0-4.3-2.2c-2 0-3.4.7-4.4 2.2a10 10 0 0 0-1.4 5.6v.5M357.4 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15h-3.6v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4"/><path d="M387.6 109h-12l-2.8 7.6H369l11-28.5h3.1l10.8 28.5h-3.7l-2.7-7.6m-11-3h9.9l-4.9-13.4-5 13.5M401 95.4l.2 3.2c.7-1.1 1.6-2 2.6-2.6 1.1-.6 2.3-1 3.7-1 2.3 0 4.1.7 5.3 2 1.3 1.3 1.9 3.4 1.9 6.2v13.4H411v-13.3c0-2-.3-3.3-1-4-.8-.9-2-1.2-3.5-1.2a5.6 5.6 0 0 0-5.2 3.1v15.4h-3.6V95.4h3.2M419.4 106.4c0-3.5.7-6.2 2.2-8.3a7 7 0 0 1 6-3c1.4 0 2.5.2 3.4.6 1 .5 1.8 1.2 2.5 2.1V86.1h3.7v30.5H434l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.6.8-2.6 0-4.6-1-6-2.8a11.8 11.8 0 0 1-2.2-7.4v-.4m3.6.4c0 2.2.5 4 1.4 5.2.8 1.3 2.2 2 4.1 2 1.3 0 2.3-.3 3-.8.9-.6 1.5-1.3 2-2.3V101c-.5-1-1.1-1.7-2-2.2-.7-.6-1.7-.8-3-.8-1.8 0-3.2.7-4.1 2.2a12 12 0 0 0-1.4 6v.5M453.1 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15H443v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4M455.6 105.8c0-3.2.8-5.8 2.5-7.8s4-3 7-3c2.9 0 5.2 1 6.9 3 1.6 2 2.5 4.6 2.5 7.8v.5c0 3.2-.8 5.7-2.5 7.7s-4 3-7 3-5.2-1-6.9-3c-1.7-2-2.5-4.5-2.5-7.7v-.5m3.6.5c0 2.3.5 4.1 1.5 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.3-2.1 10 10 0 0 0 1.5-5.6v-.5c0-2.3-.5-4.1-1.5-5.6A4.9 4.9 0 0 0 465 98c-2 0-3.4.7-4.3 2.2a10 10 0 0 0-1.5 5.6v.5M483.1 116.6h-3.6V95.4h3.6v21.2m0-26.6h-3.6V86h3.6V90M488.3 106.4c0-3.5.7-6.2 2-8.3a7 7 0 0 1 6.2-3c1.3 0 2.4.2 3.4.6 1 .5 1.7 1.2 2.4 2.1V86.1h3.7v30.5h-3.2l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.5.8-2.7 0-4.7-1-6.1-2.8a11.8 11.8 0 0 1-2.1-7.4v-.4m3.6.4c0 2.2.4 4 1.3 5.2.9 1.3 2.3 2 4.2 2 1.2 0 2.2-.3 3-.8.8-.6 1.4-1.3 2-2.3V101a5.3 5.3 0 0 0-5-3c-2 0-3.3.7-4.2 2.2a12 12 0 0 0-1.3 6v.5" fill="#2491eb"/></g></svg>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 128" style="background-color: white"><g fill-rule="evenodd"><path d="M30.3 113.2a61.9 61.9 0 0 1 25.3-110v8.5a53.8 53.8 0 0 0-28.8 86.7l3.3-9.3a45.5 45.5 0 0 1 33.8-70.4V2.1L68 2a62 62 0 0 1 37.8 111.2l-2.1-6-.8-2.3-2.7-7.4-.3-1-2.8-7.7-.4-1a37 37 0 0 0-16.3-58.9v-8.7A45.5 45.5 0 0 1 106 89.1l3.3 9.3a53.7 53.7 0 0 0-37.1-88V27l-4.2-.2a37.2 37.2 0 0 0-28.6 61l-3.2 8.7-.8 2.2-2.2 6.2-1.2 3.3-1.7 5" fill="#2491eb"/><path d="M98.7 117.9a61.7 61.7 0 0 1-61.4 0l2.9-8 8.7-24.2A28.9 28.9 0 0 1 68 35a29 29 0 0 1 19.2 50.6L96 110l1.1 3 1.7 4.9zM58.3 83.8L56 90.3 50.4 106l-2.8 7.8a53.6 53.6 0 0 0 40.9 0l-2.6-7-5.8-16.4-.1-.3-2.2-6-.5-1.5a20.7 20.7 0 1 0-18.5 0l-.5 1.3" fill="#36434f"/></g><g fill-rule="evenodd"><path d="M166.8 68.7a17.7 17.7 0 0 0 16.6-11.5 20 20 0 0 0 1.4-7.4v-.1c0-2.6-.5-5.1-1.4-7.4a18.3 18.3 0 0 0-9.5-10.1c-2.2-1-4.6-1.5-7.3-1.5A17.7 17.7 0 0 0 150 42.2a20.2 20.2 0 0 0 0 14.9 18.4 18.4 0 0 0 9.6 10c2.2 1 4.6 1.6 7.3 1.6zm109.2-42h4.8l29 36.9v-37h5.1v46.1h-4.1L281 35v37.8h-5v-46zm-40.2 0H269v4.6H241v15.9H266v4.7H241V68h28.4v4.7h-33.6v-46zm-23.5 25c2 0 3.7-.2 5.2-.6a12 12 0 0 0 4-2.1 9.1 9.1 0 0 0 3.5-7.4v-.1c0-3.3-1.1-5.8-3.4-7.5a14.6 14.6 0 0 0-9-2.5h-11.7v20.3h11.4zm-16.6-25H213c2.5 0 5 .3 7 1 2.2.7 4 1.6 5.5 2.9 1.5 1.2 2.7 2.7 3.5 4.5.8 1.8 1.2 3.9 1.2 6.2a14 14 0 0 1-1.5 6.6 14 14 0 0 1-3.9 4.7 17.1 17.1 0 0 1-5.7 2.9 25 25 0 0 1-7 1H201v16.2h-5.2v-46zm-29 46.8a23.4 23.4 0 0 1-17-7 24.7 24.7 0 0 1-6.4-16.6v-.2a24.5 24.5 0 0 1 6.4-16.7 23.1 23.1 0 0 1 17-7.1 23.4 23.4 0 0 1 17 7 24.7 24.7 0 0 1 4.7 25.8 23.3 23.3 0 0 1-12.2 12.9c-2.9 1.2-6 1.9-9.6 1.9" fill="#36434f"/><path d="M340 54.5l-17.8-27.8h11.9L345 45l11.1-18.4h11.6L350 54.4v18.3h-10.2V54.5zm141.6 9.7c2 0 3.8-.4 5.5-1.2 1.8-.7 3.2-1.7 4.4-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7 13.8 13.8 0 0 0-11.2 0c-1.7.7-3.1 1.7-4.3 3a14.6 14.6 0 0 0-3.9 10.2c0 2 .3 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7zM420 26.7H430v36.9h23v9.1h-33.1v-46zm-30.3 37.5c2 0 3.9-.4 5.6-1.2 1.7-.7 3.1-1.7 4.3-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7c-1.7-.8-3.5-1.2-5.6-1.2a12.9 12.9 0 0 0-10 4.2 14.6 14.6 0 0 0-3.8 10.2c0 2 .4 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7" fill="#2491eb"/></g><g style="line-height:125%;-inkscape-font-specification:Roboto" font-size="320" font-weight="400" letter-spacing="0" word-spacing="0" fill="#36434f" font-family="Roboto"><path d="M312.6 116.6V98.2h-3.3v-2.8h3.3v-2.7c0-2.3.6-4 1.7-5.2 1.2-1.2 2.8-1.8 5-1.8l1.2.1 1.5.3-.4 2.8a6.4 6.4 0 0 0-2-.2c-1 0-2 .4-2.5 1-.6.7-.8 1.7-.8 3v2.7h4.5v2.8h-4.5v18.4h-3.7M323.6 105.8c0-3.2.9-5.8 2.5-7.8 1.7-2 4-3 7-3s5.2 1 7 3c1.6 2 2.4 4.6 2.4 7.8v.5c0 3.2-.8 5.7-2.5 7.7-1.6 2-4 3-6.9 3-3 0-5.3-1-7-3-1.6-2-2.5-4.5-2.5-7.7v-.5m3.7.5c0 2.3.5 4.1 1.4 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.4-2.1 10 10 0 0 0 1.4-5.6v-.5c0-2.3-.5-4.1-1.5-5.6a4.9 4.9 0 0 0-4.3-2.2c-2 0-3.4.7-4.4 2.2a10 10 0 0 0-1.4 5.6v.5M357.4 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15h-3.6v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4"/><path d="M387.6 109h-12l-2.8 7.6H369l11-28.5h3.1l10.8 28.5h-3.7l-2.7-7.6m-11-3h9.9l-4.9-13.4-5 13.5M401 95.4l.2 3.2c.7-1.1 1.6-2 2.6-2.6 1.1-.6 2.3-1 3.7-1 2.3 0 4.1.7 5.3 2 1.3 1.3 1.9 3.4 1.9 6.2v13.4H411v-13.3c0-2-.3-3.3-1-4-.8-.9-2-1.2-3.5-1.2a5.6 5.6 0 0 0-5.2 3.1v15.4h-3.6V95.4h3.2M419.4 106.4c0-3.5.7-6.2 2.2-8.3a7 7 0 0 1 6-3c1.4 0 2.5.2 3.4.6 1 .5 1.8 1.2 2.5 2.1V86.1h3.7v30.5H434l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.6.8-2.6 0-4.6-1-6-2.8a11.8 11.8 0 0 1-2.2-7.4v-.4m3.6.4c0 2.2.5 4 1.4 5.2.8 1.3 2.2 2 4.1 2 1.3 0 2.3-.3 3-.8.9-.6 1.5-1.3 2-2.3V101c-.5-1-1.1-1.7-2-2.2-.7-.6-1.7-.8-3-.8-1.8 0-3.2.7-4.1 2.2a12 12 0 0 0-1.4 6v.5M453.1 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15H443v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4M455.6 105.8c0-3.2.8-5.8 2.5-7.8s4-3 7-3c2.9 0 5.2 1 6.9 3 1.6 2 2.5 4.6 2.5 7.8v.5c0 3.2-.8 5.7-2.5 7.7s-4 3-7 3-5.2-1-6.9-3c-1.7-2-2.5-4.5-2.5-7.7v-.5m3.6.5c0 2.3.5 4.1 1.5 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.3-2.1 10 10 0 0 0 1.5-5.6v-.5c0-2.3-.5-4.1-1.5-5.6A4.9 4.9 0 0 0 465 98c-2 0-3.4.7-4.3 2.2a10 10 0 0 0-1.5 5.6v.5M483.1 116.6h-3.6V95.4h3.6v21.2m0-26.6h-3.6V86h3.6V90M488.3 106.4c0-3.5.7-6.2 2-8.3a7 7 0 0 1 6.2-3c1.3 0 2.4.2 3.4.6 1 .5 1.7 1.2 2.4 2.1V86.1h3.7v30.5h-3.2l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.5.8-2.7 0-4.7-1-6.1-2.8a11.8 11.8 0 0 1-2.1-7.4v-.4m3.6.4c0 2.2.4 4 1.3 5.2.9 1.3 2.3 2 4.2 2 1.2 0 2.2-.3 3-.8.8-.6 1.4-1.3 2-2.3V101a5.3 5.3 0 0 0-5-3c-2 0-3.3.7-4.2 2.2a12 12 0 0 0-1.3 6v.5" fill="#2491eb"/></g></svg>

commit 7a018c0c35b4ea9dac2201bfb8cfea8162abb607
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue May 30 19:29:37 2017 -0700

    Replace logo width/height with viewBox, for resizing

diff --git a/openyolo_android_lockup.svg b/openyolo_android_lockup.svg
index 2f8daa1..33e2263 100644
--- a/openyolo_android_lockup.svg
+++ b/openyolo_android_lockup.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="512" height="128"><g fill-rule="evenodd"><path d="M30.3 113.2a61.9 61.9 0 0 1 25.3-110v8.5a53.8 53.8 0 0 0-28.8 86.7l3.3-9.3a45.5 45.5 0 0 1 33.8-70.4V2.1L68 2a62 62 0 0 1 37.8 111.2l-2.1-6-.8-2.3-2.7-7.4-.3-1-2.8-7.7-.4-1a37 37 0 0 0-16.3-58.9v-8.7A45.5 45.5 0 0 1 106 89.1l3.3 9.3a53.7 53.7 0 0 0-37.1-88V27l-4.2-.2a37.2 37.2 0 0 0-28.6 61l-3.2 8.7-.8 2.2-2.2 6.2-1.2 3.3-1.7 5" fill="#2491eb"/><path d="M98.7 117.9a61.7 61.7 0 0 1-61.4 0l2.9-8 8.7-24.2A28.9 28.9 0 0 1 68 35a29 29 0 0 1 19.2 50.6L96 110l1.1 3 1.7 4.9zM58.3 83.8L56 90.3 50.4 106l-2.8 7.8a53.6 53.6 0 0 0 40.9 0l-2.6-7-5.8-16.4-.1-.3-2.2-6-.5-1.5a20.7 20.7 0 1 0-18.5 0l-.5 1.3" fill="#36434f"/></g><g fill-rule="evenodd"><path d="M166.8 68.7a17.7 17.7 0 0 0 16.6-11.5 20 20 0 0 0 1.4-7.4v-.1c0-2.6-.5-5.1-1.4-7.4a18.3 18.3 0 0 0-9.5-10.1c-2.2-1-4.6-1.5-7.3-1.5A17.7 17.7 0 0 0 150 42.2a20.2 20.2 0 0 0 0 14.9 18.4 18.4 0 0 0 9.6 10c2.2 1 4.6 1.6 7.3 1.6zm109.2-42h4.8l29 36.9v-37h5.1v46.1h-4.1L281 35v37.8h-5v-46zm-40.2 0H269v4.6H241v15.9H266v4.7H241V68h28.4v4.7h-33.6v-46zm-23.5 25c2 0 3.7-.2 5.2-.6a12 12 0 0 0 4-2.1 9.1 9.1 0 0 0 3.5-7.4v-.1c0-3.3-1.1-5.8-3.4-7.5a14.6 14.6 0 0 0-9-2.5h-11.7v20.3h11.4zm-16.6-25H213c2.5 0 5 .3 7 1 2.2.7 4 1.6 5.5 2.9 1.5 1.2 2.7 2.7 3.5 4.5.8 1.8 1.2 3.9 1.2 6.2a14 14 0 0 1-1.5 6.6 14 14 0 0 1-3.9 4.7 17.1 17.1 0 0 1-5.7 2.9 25 25 0 0 1-7 1H201v16.2h-5.2v-46zm-29 46.8a23.4 23.4 0 0 1-17-7 24.7 24.7 0 0 1-6.4-16.6v-.2a24.5 24.5 0 0 1 6.4-16.7 23.1 23.1 0 0 1 17-7.1 23.4 23.4 0 0 1 17 7 24.7 24.7 0 0 1 4.7 25.8 23.3 23.3 0 0 1-12.2 12.9c-2.9 1.2-6 1.9-9.6 1.9" fill="#36434f"/><path d="M340 54.5l-17.8-27.8h11.9L345 45l11.1-18.4h11.6L350 54.4v18.3h-10.2V54.5zm141.6 9.7c2 0 3.8-.4 5.5-1.2 1.8-.7 3.2-1.7 4.4-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7 13.8 13.8 0 0 0-11.2 0c-1.7.7-3.1 1.7-4.3 3a14.6 14.6 0 0 0-3.9 10.2c0 2 .3 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7zM420 26.7H430v36.9h23v9.1h-33.1v-46zm-30.3 37.5c2 0 3.9-.4 5.6-1.2 1.7-.7 3.1-1.7 4.3-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7c-1.7-.8-3.5-1.2-5.6-1.2a12.9 12.9 0 0 0-10 4.2 14.6 14.6 0 0 0-3.8 10.2c0 2 .4 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7" fill="#2491eb"/></g><g style="line-height:125%;-inkscape-font-specification:Roboto" font-size="320" font-weight="400" letter-spacing="0" word-spacing="0" fill="#36434f" font-family="Roboto"><path d="M312.6 116.6V98.2h-3.3v-2.8h3.3v-2.7c0-2.3.6-4 1.7-5.2 1.2-1.2 2.8-1.8 5-1.8l1.2.1 1.5.3-.4 2.8a6.4 6.4 0 0 0-2-.2c-1 0-2 .4-2.5 1-.6.7-.8 1.7-.8 3v2.7h4.5v2.8h-4.5v18.4h-3.7M323.6 105.8c0-3.2.9-5.8 2.5-7.8 1.7-2 4-3 7-3s5.2 1 7 3c1.6 2 2.4 4.6 2.4 7.8v.5c0 3.2-.8 5.7-2.5 7.7-1.6 2-4 3-6.9 3-3 0-5.3-1-7-3-1.6-2-2.5-4.5-2.5-7.7v-.5m3.7.5c0 2.3.5 4.1 1.4 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.4-2.1 10 10 0 0 0 1.4-5.6v-.5c0-2.3-.5-4.1-1.5-5.6a4.9 4.9 0 0 0-4.3-2.2c-2 0-3.4.7-4.4 2.2a10 10 0 0 0-1.4 5.6v.5M357.4 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15h-3.6v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4"/><path d="M387.6 109h-12l-2.8 7.6H369l11-28.5h3.1l10.8 28.5h-3.7l-2.7-7.6m-11-3h9.9l-4.9-13.4-5 13.5M401 95.4l.2 3.2c.7-1.1 1.6-2 2.6-2.6 1.1-.6 2.3-1 3.7-1 2.3 0 4.1.7 5.3 2 1.3 1.3 1.9 3.4 1.9 6.2v13.4H411v-13.3c0-2-.3-3.3-1-4-.8-.9-2-1.2-3.5-1.2a5.6 5.6 0 0 0-5.2 3.1v15.4h-3.6V95.4h3.2M419.4 106.4c0-3.5.7-6.2 2.2-8.3a7 7 0 0 1 6-3c1.4 0 2.5.2 3.4.6 1 .5 1.8 1.2 2.5 2.1V86.1h3.7v30.5H434l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.6.8-2.6 0-4.6-1-6-2.8a11.8 11.8 0 0 1-2.2-7.4v-.4m3.6.4c0 2.2.5 4 1.4 5.2.8 1.3 2.2 2 4.1 2 1.3 0 2.3-.3 3-.8.9-.6 1.5-1.3 2-2.3V101c-.5-1-1.1-1.7-2-2.2-.7-.6-1.7-.8-3-.8-1.8 0-3.2.7-4.1 2.2a12 12 0 0 0-1.4 6v.5M453.1 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15H443v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4M455.6 105.8c0-3.2.8-5.8 2.5-7.8s4-3 7-3c2.9 0 5.2 1 6.9 3 1.6 2 2.5 4.6 2.5 7.8v.5c0 3.2-.8 5.7-2.5 7.7s-4 3-7 3-5.2-1-6.9-3c-1.7-2-2.5-4.5-2.5-7.7v-.5m3.6.5c0 2.3.5 4.1 1.5 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.3-2.1 10 10 0 0 0 1.5-5.6v-.5c0-2.3-.5-4.1-1.5-5.6A4.9 4.9 0 0 0 465 98c-2 0-3.4.7-4.3 2.2a10 10 0 0 0-1.5 5.6v.5M483.1 116.6h-3.6V95.4h3.6v21.2m0-26.6h-3.6V86h3.6V90M488.3 106.4c0-3.5.7-6.2 2-8.3a7 7 0 0 1 6.2-3c1.3 0 2.4.2 3.4.6 1 .5 1.7 1.2 2.4 2.1V86.1h3.7v30.5h-3.2l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.5.8-2.7 0-4.7-1-6.1-2.8a11.8 11.8 0 0 1-2.1-7.4v-.4m3.6.4c0 2.2.4 4 1.3 5.2.9 1.3 2.3 2 4.2 2 1.2 0 2.2-.3 3-.8.8-.6 1.4-1.3 2-2.3V101a5.3 5.3 0 0 0-5-3c-2 0-3.3.7-4.2 2.2a12 12 0 0 0-1.3 6v.5" fill="#2491eb"/></g></svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 128"><g fill-rule="evenodd"><path d="M30.3 113.2a61.9 61.9 0 0 1 25.3-110v8.5a53.8 53.8 0 0 0-28.8 86.7l3.3-9.3a45.5 45.5 0 0 1 33.8-70.4V2.1L68 2a62 62 0 0 1 37.8 111.2l-2.1-6-.8-2.3-2.7-7.4-.3-1-2.8-7.7-.4-1a37 37 0 0 0-16.3-58.9v-8.7A45.5 45.5 0 0 1 106 89.1l3.3 9.3a53.7 53.7 0 0 0-37.1-88V27l-4.2-.2a37.2 37.2 0 0 0-28.6 61l-3.2 8.7-.8 2.2-2.2 6.2-1.2 3.3-1.7 5" fill="#2491eb"/><path d="M98.7 117.9a61.7 61.7 0 0 1-61.4 0l2.9-8 8.7-24.2A28.9 28.9 0 0 1 68 35a29 29 0 0 1 19.2 50.6L96 110l1.1 3 1.7 4.9zM58.3 83.8L56 90.3 50.4 106l-2.8 7.8a53.6 53.6 0 0 0 40.9 0l-2.6-7-5.8-16.4-.1-.3-2.2-6-.5-1.5a20.7 20.7 0 1 0-18.5 0l-.5 1.3" fill="#36434f"/></g><g fill-rule="evenodd"><path d="M166.8 68.7a17.7 17.7 0 0 0 16.6-11.5 20 20 0 0 0 1.4-7.4v-.1c0-2.6-.5-5.1-1.4-7.4a18.3 18.3 0 0 0-9.5-10.1c-2.2-1-4.6-1.5-7.3-1.5A17.7 17.7 0 0 0 150 42.2a20.2 20.2 0 0 0 0 14.9 18.4 18.4 0 0 0 9.6 10c2.2 1 4.6 1.6 7.3 1.6zm109.2-42h4.8l29 36.9v-37h5.1v46.1h-4.1L281 35v37.8h-5v-46zm-40.2 0H269v4.6H241v15.9H266v4.7H241V68h28.4v4.7h-33.6v-46zm-23.5 25c2 0 3.7-.2 5.2-.6a12 12 0 0 0 4-2.1 9.1 9.1 0 0 0 3.5-7.4v-.1c0-3.3-1.1-5.8-3.4-7.5a14.6 14.6 0 0 0-9-2.5h-11.7v20.3h11.4zm-16.6-25H213c2.5 0 5 .3 7 1 2.2.7 4 1.6 5.5 2.9 1.5 1.2 2.7 2.7 3.5 4.5.8 1.8 1.2 3.9 1.2 6.2a14 14 0 0 1-1.5 6.6 14 14 0 0 1-3.9 4.7 17.1 17.1 0 0 1-5.7 2.9 25 25 0 0 1-7 1H201v16.2h-5.2v-46zm-29 46.8a23.4 23.4 0 0 1-17-7 24.7 24.7 0 0 1-6.4-16.6v-.2a24.5 24.5 0 0 1 6.4-16.7 23.1 23.1 0 0 1 17-7.1 23.4 23.4 0 0 1 17 7 24.7 24.7 0 0 1 4.7 25.8 23.3 23.3 0 0 1-12.2 12.9c-2.9 1.2-6 1.9-9.6 1.9" fill="#36434f"/><path d="M340 54.5l-17.8-27.8h11.9L345 45l11.1-18.4h11.6L350 54.4v18.3h-10.2V54.5zm141.6 9.7c2 0 3.8-.4 5.5-1.2 1.8-.7 3.2-1.7 4.4-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7 13.8 13.8 0 0 0-11.2 0c-1.7.7-3.1 1.7-4.3 3a14.6 14.6 0 0 0-3.9 10.2c0 2 .3 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7zM420 26.7H430v36.9h23v9.1h-33.1v-46zm-30.3 37.5c2 0 3.9-.4 5.6-1.2 1.7-.7 3.1-1.7 4.3-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7c-1.7-.8-3.5-1.2-5.6-1.2a12.9 12.9 0 0 0-10 4.2 14.6 14.6 0 0 0-3.8 10.2c0 2 .4 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7" fill="#2491eb"/></g><g style="line-height:125%;-inkscape-font-specification:Roboto" font-size="320" font-weight="400" letter-spacing="0" word-spacing="0" fill="#36434f" font-family="Roboto"><path d="M312.6 116.6V98.2h-3.3v-2.8h3.3v-2.7c0-2.3.6-4 1.7-5.2 1.2-1.2 2.8-1.8 5-1.8l1.2.1 1.5.3-.4 2.8a6.4 6.4 0 0 0-2-.2c-1 0-2 .4-2.5 1-.6.7-.8 1.7-.8 3v2.7h4.5v2.8h-4.5v18.4h-3.7M323.6 105.8c0-3.2.9-5.8 2.5-7.8 1.7-2 4-3 7-3s5.2 1 7 3c1.6 2 2.4 4.6 2.4 7.8v.5c0 3.2-.8 5.7-2.5 7.7-1.6 2-4 3-6.9 3-3 0-5.3-1-7-3-1.6-2-2.5-4.5-2.5-7.7v-.5m3.7.5c0 2.3.5 4.1 1.4 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.4-2.1 10 10 0 0 0 1.4-5.6v-.5c0-2.3-.5-4.1-1.5-5.6a4.9 4.9 0 0 0-4.3-2.2c-2 0-3.4.7-4.4 2.2a10 10 0 0 0-1.4 5.6v.5M357.4 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15h-3.6v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4"/><path d="M387.6 109h-12l-2.8 7.6H369l11-28.5h3.1l10.8 28.5h-3.7l-2.7-7.6m-11-3h9.9l-4.9-13.4-5 13.5M401 95.4l.2 3.2c.7-1.1 1.6-2 2.6-2.6 1.1-.6 2.3-1 3.7-1 2.3 0 4.1.7 5.3 2 1.3 1.3 1.9 3.4 1.9 6.2v13.4H411v-13.3c0-2-.3-3.3-1-4-.8-.9-2-1.2-3.5-1.2a5.6 5.6 0 0 0-5.2 3.1v15.4h-3.6V95.4h3.2M419.4 106.4c0-3.5.7-6.2 2.2-8.3a7 7 0 0 1 6-3c1.4 0 2.5.2 3.4.6 1 .5 1.8 1.2 2.5 2.1V86.1h3.7v30.5H434l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.6.8-2.6 0-4.6-1-6-2.8a11.8 11.8 0 0 1-2.2-7.4v-.4m3.6.4c0 2.2.5 4 1.4 5.2.8 1.3 2.2 2 4.1 2 1.3 0 2.3-.3 3-.8.9-.6 1.5-1.3 2-2.3V101c-.5-1-1.1-1.7-2-2.2-.7-.6-1.7-.8-3-.8-1.8 0-3.2.7-4.1 2.2a12 12 0 0 0-1.4 6v.5M453.1 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15H443v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4M455.6 105.8c0-3.2.8-5.8 2.5-7.8s4-3 7-3c2.9 0 5.2 1 6.9 3 1.6 2 2.5 4.6 2.5 7.8v.5c0 3.2-.8 5.7-2.5 7.7s-4 3-7 3-5.2-1-6.9-3c-1.7-2-2.5-4.5-2.5-7.7v-.5m3.6.5c0 2.3.5 4.1 1.5 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.3-2.1 10 10 0 0 0 1.5-5.6v-.5c0-2.3-.5-4.1-1.5-5.6A4.9 4.9 0 0 0 465 98c-2 0-3.4.7-4.3 2.2a10 10 0 0 0-1.5 5.6v.5M483.1 116.6h-3.6V95.4h3.6v21.2m0-26.6h-3.6V86h3.6V90M488.3 106.4c0-3.5.7-6.2 2-8.3a7 7 0 0 1 6.2-3c1.3 0 2.4.2 3.4.6 1 .5 1.7 1.2 2.4 2.1V86.1h3.7v30.5h-3.2l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.5.8-2.7 0-4.7-1-6.1-2.8a11.8 11.8 0 0 1-2.1-7.4v-.4m3.6.4c0 2.2.4 4 1.3 5.2.9 1.3 2.3 2 4.2 2 1.2 0 2.2-.3 3-.8.8-.6 1.4-1.3 2-2.3V101a5.3 5.3 0 0 0-5-3c-2 0-3.3.7-4.2 2.2a12 12 0 0 0-1.3 6v.5" fill="#2491eb"/></g></svg>

commit 7f3f278fccc3d121b5737d22d3ce5437ebd39a02
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue May 30 19:28:06 2017 -0700

    Add OpenYOLO for Android logo

diff --git a/README.md b/README.md
index 4a20026..5ad4a8e 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# OpenYOLO for Android
+![OpenYOLO for Android](https://rawgit.com/openid/OpenYOLO-Android/master/openyolo_android_lockup.svg)
 
 [![Build Status](https://www.bitrise.io/app/e7b1a2bcce9d787c.svg?token=kvggLFAJ-Tx48g6I671NSg)](https://www.bitrise.io/app/e7b1a2bcce9d787c)
 [![codecov](https://codecov.io/gh/openid/OpenYOLO-Android/branch/master/graph/badge.svg)](https://codecov.io/gh/openid/OpenYOLO-Android)
diff --git a/openyolo_android_lockup.svg b/openyolo_android_lockup.svg
new file mode 100644
index 0000000..2f8daa1
--- /dev/null
+++ b/openyolo_android_lockup.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="512" height="128"><g fill-rule="evenodd"><path d="M30.3 113.2a61.9 61.9 0 0 1 25.3-110v8.5a53.8 53.8 0 0 0-28.8 86.7l3.3-9.3a45.5 45.5 0 0 1 33.8-70.4V2.1L68 2a62 62 0 0 1 37.8 111.2l-2.1-6-.8-2.3-2.7-7.4-.3-1-2.8-7.7-.4-1a37 37 0 0 0-16.3-58.9v-8.7A45.5 45.5 0 0 1 106 89.1l3.3 9.3a53.7 53.7 0 0 0-37.1-88V27l-4.2-.2a37.2 37.2 0 0 0-28.6 61l-3.2 8.7-.8 2.2-2.2 6.2-1.2 3.3-1.7 5" fill="#2491eb"/><path d="M98.7 117.9a61.7 61.7 0 0 1-61.4 0l2.9-8 8.7-24.2A28.9 28.9 0 0 1 68 35a29 29 0 0 1 19.2 50.6L96 110l1.1 3 1.7 4.9zM58.3 83.8L56 90.3 50.4 106l-2.8 7.8a53.6 53.6 0 0 0 40.9 0l-2.6-7-5.8-16.4-.1-.3-2.2-6-.5-1.5a20.7 20.7 0 1 0-18.5 0l-.5 1.3" fill="#36434f"/></g><g fill-rule="evenodd"><path d="M166.8 68.7a17.7 17.7 0 0 0 16.6-11.5 20 20 0 0 0 1.4-7.4v-.1c0-2.6-.5-5.1-1.4-7.4a18.3 18.3 0 0 0-9.5-10.1c-2.2-1-4.6-1.5-7.3-1.5A17.7 17.7 0 0 0 150 42.2a20.2 20.2 0 0 0 0 14.9 18.4 18.4 0 0 0 9.6 10c2.2 1 4.6 1.6 7.3 1.6zm109.2-42h4.8l29 36.9v-37h5.1v46.1h-4.1L281 35v37.8h-5v-46zm-40.2 0H269v4.6H241v15.9H266v4.7H241V68h28.4v4.7h-33.6v-46zm-23.5 25c2 0 3.7-.2 5.2-.6a12 12 0 0 0 4-2.1 9.1 9.1 0 0 0 3.5-7.4v-.1c0-3.3-1.1-5.8-3.4-7.5a14.6 14.6 0 0 0-9-2.5h-11.7v20.3h11.4zm-16.6-25H213c2.5 0 5 .3 7 1 2.2.7 4 1.6 5.5 2.9 1.5 1.2 2.7 2.7 3.5 4.5.8 1.8 1.2 3.9 1.2 6.2a14 14 0 0 1-1.5 6.6 14 14 0 0 1-3.9 4.7 17.1 17.1 0 0 1-5.7 2.9 25 25 0 0 1-7 1H201v16.2h-5.2v-46zm-29 46.8a23.4 23.4 0 0 1-17-7 24.7 24.7 0 0 1-6.4-16.6v-.2a24.5 24.5 0 0 1 6.4-16.7 23.1 23.1 0 0 1 17-7.1 23.4 23.4 0 0 1 17 7 24.7 24.7 0 0 1 4.7 25.8 23.3 23.3 0 0 1-12.2 12.9c-2.9 1.2-6 1.9-9.6 1.9" fill="#36434f"/><path d="M340 54.5l-17.8-27.8h11.9L345 45l11.1-18.4h11.6L350 54.4v18.3h-10.2V54.5zm141.6 9.7c2 0 3.8-.4 5.5-1.2 1.8-.7 3.2-1.7 4.4-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7 13.8 13.8 0 0 0-11.2 0c-1.7.7-3.1 1.7-4.3 3a14.6 14.6 0 0 0-3.9 10.2c0 2 .3 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7zM420 26.7H430v36.9h23v9.1h-33.1v-46zm-30.3 37.5c2 0 3.9-.4 5.6-1.2 1.7-.7 3.1-1.7 4.3-3a14.6 14.6 0 0 0 3.9-10.2v-.1c0-2-.4-3.9-1-5.6a14 14 0 0 0-7.4-7.7c-1.7-.8-3.5-1.2-5.6-1.2a12.9 12.9 0 0 0-10 4.2 14.6 14.6 0 0 0-3.8 10.2c0 2 .4 4 1 5.7a13.9 13.9 0 0 0 13 8.9zm-.2 9.3a25.1 25.1 0 0 1-17.5-7 22.7 22.7 0 0 1-6.9-16.7v-.1a23.3 23.3 0 0 1 7-16.8c2.1-2.2 4.7-4 7.7-5.2 3-1.2 6.3-1.8 9.9-1.8a25.1 25.1 0 0 1 17.5 7 22.7 22.7 0 0 1 6.9 16.7 23.3 23.3 0 0 1-7 16.9 25.4 25.4 0 0 1-17.6 7" fill="#2491eb"/></g><g style="line-height:125%;-inkscape-font-specification:Roboto" font-size="320" font-weight="400" letter-spacing="0" word-spacing="0" fill="#36434f" font-family="Roboto"><path d="M312.6 116.6V98.2h-3.3v-2.8h3.3v-2.7c0-2.3.6-4 1.7-5.2 1.2-1.2 2.8-1.8 5-1.8l1.2.1 1.5.3-.4 2.8a6.4 6.4 0 0 0-2-.2c-1 0-2 .4-2.5 1-.6.7-.8 1.7-.8 3v2.7h4.5v2.8h-4.5v18.4h-3.7M323.6 105.8c0-3.2.9-5.8 2.5-7.8 1.7-2 4-3 7-3s5.2 1 7 3c1.6 2 2.4 4.6 2.4 7.8v.5c0 3.2-.8 5.7-2.5 7.7-1.6 2-4 3-6.9 3-3 0-5.3-1-7-3-1.6-2-2.5-4.5-2.5-7.7v-.5m3.7.5c0 2.3.5 4.1 1.4 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.4-2.1 10 10 0 0 0 1.4-5.6v-.5c0-2.3-.5-4.1-1.5-5.6a4.9 4.9 0 0 0-4.3-2.2c-2 0-3.4.7-4.4 2.2a10 10 0 0 0-1.4 5.6v.5M357.4 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15h-3.6v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4"/><path d="M387.6 109h-12l-2.8 7.6H369l11-28.5h3.1l10.8 28.5h-3.7l-2.7-7.6m-11-3h9.9l-4.9-13.4-5 13.5M401 95.4l.2 3.2c.7-1.1 1.6-2 2.6-2.6 1.1-.6 2.3-1 3.7-1 2.3 0 4.1.7 5.3 2 1.3 1.3 1.9 3.4 1.9 6.2v13.4H411v-13.3c0-2-.3-3.3-1-4-.8-.9-2-1.2-3.5-1.2a5.6 5.6 0 0 0-5.2 3.1v15.4h-3.6V95.4h3.2M419.4 106.4c0-3.5.7-6.2 2.2-8.3a7 7 0 0 1 6-3c1.4 0 2.5.2 3.4.6 1 .5 1.8 1.2 2.5 2.1V86.1h3.7v30.5H434l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.6.8-2.6 0-4.6-1-6-2.8a11.8 11.8 0 0 1-2.2-7.4v-.4m3.6.4c0 2.2.5 4 1.4 5.2.8 1.3 2.2 2 4.1 2 1.3 0 2.3-.3 3-.8.9-.6 1.5-1.3 2-2.3V101c-.5-1-1.1-1.7-2-2.2-.7-.6-1.7-.8-3-.8-1.8 0-3.2.7-4.1 2.2a12 12 0 0 0-1.4 6v.5M453.1 98.7l-2.1-.1c-1.1 0-2 .2-2.7.7-.8.6-1.3 1.3-1.7 2.2v15H443v-21h3.2l.4 3c.6-1 1.3-2 2.2-2.5a5.4 5.4 0 0 1 4-.9l.8.2-.5 3.4M455.6 105.8c0-3.2.8-5.8 2.5-7.8s4-3 7-3c2.9 0 5.2 1 6.9 3 1.6 2 2.5 4.6 2.5 7.8v.5c0 3.2-.8 5.7-2.5 7.7s-4 3-7 3-5.2-1-6.9-3c-1.7-2-2.5-4.5-2.5-7.7v-.5m3.6.5c0 2.3.5 4.1 1.5 5.6 1 1.4 2.4 2.1 4.4 2.1a5 5 0 0 0 4.3-2.1 10 10 0 0 0 1.5-5.6v-.5c0-2.3-.5-4.1-1.5-5.6A4.9 4.9 0 0 0 465 98c-2 0-3.4.7-4.3 2.2a10 10 0 0 0-1.5 5.6v.5M483.1 116.6h-3.6V95.4h3.6v21.2m0-26.6h-3.6V86h3.6V90M488.3 106.4c0-3.5.7-6.2 2-8.3a7 7 0 0 1 6.2-3c1.3 0 2.4.2 3.4.6 1 .5 1.7 1.2 2.4 2.1V86.1h3.7v30.5h-3.2l-.3-2.7a7 7 0 0 1-2.5 2.3c-1 .5-2.2.8-3.5.8-2.7 0-4.7-1-6.1-2.8a11.8 11.8 0 0 1-2.1-7.4v-.4m3.6.4c0 2.2.4 4 1.3 5.2.9 1.3 2.3 2 4.2 2 1.2 0 2.2-.3 3-.8.8-.6 1.4-1.3 2-2.3V101a5.3 5.3 0 0 0-5-3c-2 0-3.3.7-4.2 2.2a12 12 0 0 0-1.3 6v.5" fill="#2491eb"/></g></svg>
\ No newline at end of file

commit 7702f529dba5b82fdc601112dbf65fdb6e03492c
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue May 23 17:58:40 2017 -0700

    fromProtoX() methods now throw checked exceptions (#60)
    
    fromProtobuf() methods now throw checked exception

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index a55e78c..3ac1e8c 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -64,442 +64,442 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
         List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
     @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             return null;
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
-        } catch (IOException ex) {
+        } catch (MalformedDataException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @Nullable
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
-        } catch (IOException ex) {
-            Log.e(LOG_TAG, "hint result is malformed, returning default response");
+        } catch (MalformedDataException ex) {
+            Log.e(LOG_TAG, "hint result is malformed, returning default response", ex);
             return createDefaultHintRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a credential save request from the intent data returned by a provider.
      */
     public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No save result found in result data, returning default response");
             return createDefaultCredentialSaveResult();
         }
 
         try {
             return CredentialSaveResult.fromProtobufBytes(resultBytes);
-        } catch (IOException ex) {
-            Log.e(LOG_TAG, "save result is malformed, returning default response");
+        } catch (MalformedDataException ex) {
+            Log.e(LOG_TAG, "save result is malformed, returning default response", ex);
             return createDefaultCredentialSaveResult();
         }
     }
 
     @NonNull
     private static CredentialSaveResult createDefaultCredentialSaveResult() {
         return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
                 .build();
     }
 
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @Nullable
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
index 6572139..ff3dfd8 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
@@ -32,2 +32,3 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.Protobufs.Credential;
@@ -35,111 +36,114 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * RecyclerView adapter for displaying stored credentials.
  */
-class CredentialAdapter
-        extends RecyclerView.Adapter<CredentialAdapter.ViewHolder> {
+class CredentialAdapter extends RecyclerView.Adapter<CredentialAdapter.ViewHolder> {
 
     private List<Credential> mCredentials;
     private CredentialStorageClient mClient;
 
     CredentialAdapter() {
         mCredentials = Collections.emptyList();
     }
 
     void setCredentials(List<Credential> credentials) {
         mCredentials = credentials;
         notifyDataSetChanged();
     }
 
     @Override
     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
         View credentialView = LayoutInflater.from(parent.getContext())
                 .inflate(R.layout.credential_view, parent, false);
 
         return new ViewHolder(credentialView);
     }
 
     @Override
     public void onBindViewHolder(ViewHolder holder, int position) {
         holder.bind(mCredentials.get(position));
     }
 
     @Override
     public int getItemCount() {
         return mCredentials.size();
     }
 
     void setCredentialStorageClient(CredentialStorageClient credentialStorageClient) {
         mClient = credentialStorageClient;
     }
 
     final class ViewHolder extends RecyclerView.ViewHolder {
 
         private TextView mAuthorityView;
         private ImageView mAuthorityIconView;
         private TextView mIdView;
 
         ViewHolder(View itemView) {
             super(itemView);
 
             mAuthorityView = (TextView) itemView.findViewById(R.id.credential_authority);
             mAuthorityIconView = (ImageView) itemView.findViewById(R.id.credential_authority_icon);
             mIdView = (TextView) itemView.findViewById(R.id.credential_id);
         }
 
         void bind(final Credential credential) {
             String appLabel = credential.getAuthDomain().toString();
             Drawable appIcon = null;
 
-            AuthenticationDomain domain =
-                    AuthenticationDomain.fromProtobuf(credential.getAuthDomain());
-            if (domain.isAndroidAuthDomain()) {
-                String packageName = domain.getAndroidPackageName();
-                PackageManager pm = itemView.getContext().getPackageManager();
-                try {
-                    ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
-                    appLabel = pm.getApplicationLabel(info).toString();
-                    appIcon = pm.getApplicationIcon(info);
-                } catch (PackageManager.NameNotFoundException e) {
-                    // will just show the raw info
+            try {
+                AuthenticationDomain domain =
+                        AuthenticationDomain.fromProtobuf(credential.getAuthDomain());
+                if (domain.isAndroidAuthDomain()) {
+                    String packageName = domain.getAndroidPackageName();
+                    PackageManager pm = itemView.getContext().getPackageManager();
+                    try {
+                        ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
+                        appLabel = pm.getApplicationLabel(info).toString();
+                        appIcon = pm.getApplicationIcon(info);
+                    } catch (PackageManager.NameNotFoundException e) {
+                        // will just show the raw info
+                    }
                 }
+            } catch (MalformedDataException ex) {
+                // will just show the raw info
             }
 
             mAuthorityView.setText(appLabel);
             mIdView.setText(credential.getId());
 
             if (appIcon != null) {
                 mAuthorityIconView.setImageDrawable(appIcon);
                 mAuthorityIconView.setVisibility(View.VISIBLE);
             } else {
                 mAuthorityIconView.setVisibility(View.INVISIBLE);
             }
 
             itemView.setOnLongClickListener(new View.OnLongClickListener() {
                 @Override
                 public boolean onLongClick(View view) {
                     AlertDialog dialog = new AlertDialog.Builder(itemView.getContext())
                             .setTitle(R.string.ask_delete_credential)
                             .setPositiveButton(R.string.openyolo_simple_yes,
                                     new DialogInterface.OnClickListener() {
                                         @Override
                                         public void onClick(DialogInterface dialogInterface,
                                                             int which) {
                                             try {
                                                 mClient.deleteCredential(credential);
                                                 mCredentials.remove(credential);
                                                 notifyDataSetChanged();
                                             } catch (IOException e) {
                                                 e.printStackTrace();
                                             }
                                         }
                                     })
                             .setNegativeButton(R.string.openyolo_simple_no, null)
                             .create();
 
                     dialog.show();
                     return true;
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
index 32f45ba..a88b769 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
@@ -26,117 +26,117 @@ import org.openyolo.protocol.Protobufs;
 /**
  * Derives quality scores for credentials and hints that can help to order lists of them based on
  * how useful they are to an application.
  */
 public class CredentialQualityScore {
 
     /**
      * A comparator which orders credentials in descending order of quality score, i.e. those with
      * the highest quality score first.
      */
     public static final Comparator<Credential> QUALITY_SORT = new CredentialQualityComparator();
 
     /**
      * A comparator which orders credential protocol buffers in descending order of quality score,
      * i.e. those with the highest quality score first.
      */
     public static final Comparator<Protobufs.Credential> PROTO_QUALITY_SORT =
             new CredentialProtoQualityComparator();
 
     /**
      * Generates the score for the user data in an account hint.
      */
     public static int getScore(AccountHint hint) {
         return getQualityScore(
                 hint.getIdentifier(),
                 new AuthenticationMethod(hint.getAuthMethod()),
                 hint.getName(),
                 hint.getPictureUri());
     }
 
     /**
      * Generates the score for the user data in a credential protocol buffer.
      */
     public static int getScore(Protobufs.Credential credential) {
         return getQualityScore(
                 credential.getId(),
-                AuthenticationMethod.fromProtobuf(credential.getAuthMethod()),
+                new AuthenticationMethod(credential.getAuthMethod().getUri()),
                 credential.getDisplayName(),
                 credential.getDisplayPictureUri());
     }
 
     /**
      * Generates the score for the user data in a credential.
      */
     public static int getScore(Credential credential) {
         return getQualityScore(
                 credential.getIdentifier(),
                 credential.getAuthenticationMethod(),
                 credential.getDisplayName(),
                 credential.getDisplayPicture() != null
                         ? credential.getDisplayPicture().toString()
                         : null);
     }
 
     private static int getQualityScore(
             @Nullable String id,
             @Nullable AuthenticationMethod authMethod,
             @Nullable String name,
             @Nullable String pictureUri) {
 
         int score = 1;
 
         // email identifiers are recognisable and useful for ID token acquisition
         if (AuthenticationMethods.EMAIL.equals(authMethod)) {
             score <<= 1;
         }
 
         // prefer credentials that have a human readable name
         if (!TextUtils.isEmpty(name)) {
             score <<= 1;
         }
 
         // prefer credentials that have a profile picture
         if (pictureUri != null) {
             score <<= 1;
         }
 
         return score;
     }
 
     private static final class CredentialQualityComparator implements Comparator<Credential> {
 
         @Override
         public int compare(Credential c1, Credential c2) {
             int c1Score = getScore(c1);
             int c2Score = getScore(c2);
 
             // higher scores (more information) come first
             if (c1Score > c2Score) {
                 return -1;
             } else if (c1Score == c2Score) {
                 return 0;
             }
 
             return 1;
         }
     }
 
     private static final class CredentialProtoQualityComparator
             implements Comparator<Protobufs.Credential> {
 
         @Override
         public int compare(Protobufs.Credential c1, Protobufs.Credential c2) {
             int c1Score = getScore(c1);
             int c2Score = getScore(c2);
 
             // higher scores (more information) come first
             if (c1Score > c2Score) {
                 return -1;
             } else if (c1Score == c2Score) {
                 return 0;
             }
 
             return 1;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
index e513d16..7caceb8 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
@@ -27,3 +27,2 @@ import butterknife.BindView;
 import butterknife.ButterKnife;
-import java.io.IOException;
 import org.openyolo.demoprovider.barbican.R;
@@ -31,2 +30,3 @@ import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.Protobufs;
@@ -34,97 +34,97 @@ import org.openyolo.protocol.Protobufs;
 /**
  * Displays a brief, "snackbar"-like notification to the user indicating that a credential
  * is being returned to a requesting app.
  */
 public class AutoSignInActivity extends AppCompatActivity {
 
     private static final long DISPLAY_TIME_MS = 2000;
 
     private static final String EXTRA_CREDENTIAL = "credential";
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.credential_primary)
     TextView mCredentialPrimary;
 
     @BindView(R.id.credential_secondary)
     TextView mCredentialSecondary;
 
     /**
      * Creates an intent to display this activity with the specified credential.
      */
     public static Intent createIntent(Context context, Credential credential) {
         return createIntent(context, credential.toProtobuf());
     }
 
     /**
      * Creates an intent to display this activity with the specified credential, in protobuf form.
      */
     public static Intent createIntent(Context context, Protobufs.Credential credential) {
         Intent intent = new Intent(context, AutoSignInActivity.class);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.auto_sign_in_layout);
         positionWindow();
         ButterKnife.bind(this);
 
         Credential credential = getCredential();
         if (credential.getDisplayName() != null) {
             mCredentialPrimary.setText(credential.getDisplayName());
             mCredentialSecondary.setText(credential.getIdentifier());
         } else {
             mCredentialPrimary.setText(credential.getIdentifier());
             mCredentialSecondary.setVisibility(View.GONE);
         }
 
         mRootView.postDelayed(new ReturnCredentialTask(), DISPLAY_TIME_MS);
     }
 
     /**
      * Ensures the activity's window fills the full "visible" section of the screen, excluding
      * the status bar. This is a workaround for a size bug when using
      * {@code windowMinWidthMajor / windowMinWidthMinor} that can leave the windows a few pixels
      * off the correct size.
      */
     private void positionWindow() {
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = getResources().getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
     }
 
     private Credential getCredential() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
             return Credential.fromProtoBytes(credentialBytes);
-        } catch (IOException e) {
-            throw new IllegalStateException("Unable to decode credential");
+        } catch (MalformedDataException ex) {
+            throw new IllegalStateException("Unable to decode credential", ex);
         }
     }
 
     private class ReturnCredentialTask implements Runnable {
         @Override
         public void run() {
             CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
                     CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                     .setCredential(getCredential())
                     .build();
             setResult(result.getResultCode(), result.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index c81f051..7d1b44e 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -38,113 +38,110 @@ import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.internal.CollectionConverter;
-import org.openyolo.protocol.internal.CredentialConverter;
 
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(
             Context context,
             List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
         ByteString data = ProtoListUtil.writeMessageList(
-                CollectionConverter.toList(
-                        credentials,
-                        CredentialConverter.CREDENTIAL_TO_PROTO));
+                CredentialTransformUtils.toProtoList(credentials));
 
         intent.putExtra(EXTRA_CREDENTIALS, data.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResultAndFinish(CredentialRetrieveResult.USER_CANCELED);
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Protobufs.Credential> credentialProtos = ProtoListUtil
                     .readMessageList(credentialBytes, Protobufs.Credential.parser());
 
-            return CollectionConverter.toList(
-                    credentialProtos,
-                    CredentialConverter.PROTO_TO_CREDENTIAL);
+            return CredentialTransformUtils.fromProtoList(credentialProtos);
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
+        } catch (MalformedDataException ex) {
+            throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter
             extends RecyclerView.Adapter<AccountViewHolder>
             implements ClickHandler<Credential> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new AccountViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(AccountViewHolder holder, int position) {
             holder.bind(mCredentials.get(position), this);
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
 
         @Override
         public void onClick(Credential clicked) {
             CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
                     CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                     .setCredential(clicked)
                     .build();
             setResultAndFinish(result);
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialTransformUtils.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialTransformUtils.java
new file mode 100644
index 0000000..bc7de0b
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialTransformUtils.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.MalformedDataException;
+import org.openyolo.protocol.Protobufs;
+
+/**
+ * Collection of utility methods related to {@link org.openyolo.protocol.Protobufs.Credential}.
+ */
+public final class CredentialTransformUtils {
+
+    /**
+     * Given a list of {@link Protobufs.Credential} returns an equivalent list of
+     * {@link Credential}.
+     * @throws MalformedDataException if a given {@link Protobufs.Credential} can not be
+     *     successfully transformed into it's object representation.
+     */
+    public static List<Credential> fromProtoList(List<Protobufs.Credential> protoCredentials)
+            throws MalformedDataException {
+        List<Credential> credentials = new ArrayList<>(protoCredentials.size());
+        for (Protobufs.Credential protoCredential : protoCredentials) {
+            credentials.add(Credential.fromProtobuf(protoCredential));
+        }
+
+        return credentials;
+    }
+
+    /**
+     * Given a list {@link Credential} returns an equivalent list of {@link Protobufs.Credential}.
+     */
+    public static List<Protobufs.Credential> toProtoList(List<Credential> credentials) {
+        List<Protobufs.Credential> protoCredentials = new ArrayList<>(credentials.size());
+        for (Credential credential : credentials) {
+            protoCredentials.add(credential.toProtobuf());
+        }
+
+        return protoCredentials;
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
index d8648a1..da636ea 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
@@ -41,2 +41,3 @@ import org.openyolo.protocol.HintRetrieveRequest;
 import org.openyolo.protocol.HintRetrieveResult;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.ProtocolConstants;
@@ -44,180 +45,180 @@ import org.openyolo.protocol.ProtocolConstants;
 public class HintPickerActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "HintPickerActivity";
 
     private HintRetrieveRequest mRequest;
     private AuthenticationDomain mCallerAuthDomain;
     private CredentialStorageClient mClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (!getIntent().hasExtra(ProtocolConstants.EXTRA_HINT_REQUEST)) {
             Log.w(LOG_TAG, "No hint request object found in the intent");
             setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
             mRequest = HintRetrieveRequest.fromProtoBytes(
                     getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_HINT_REQUEST));
-        } catch (IOException ex) {
+        } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
             setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         if (!extractCallerAuthDomain()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
             setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
 
         if (!mClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
             setResultAndFinish(HintRetrieveResult.UNKNOWN);
             return;
         }
 
         // some credential provider implementations may require an unlock to retrieve the
         // information required for hints, but for Barbican we instead choose to store basic
         // profile information usable for hints in plain text. With root access, this information
         // would be retrievable by malicious applications on the device, representing a privacy
         // risk. However, full credentials and associations between account identifiers
         // remain encrypted.
 
         List<AccountHint> hints;
         try {
             hints = mClient.getHints();
         } catch (IOException ex) {
             Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
             setResultAndFinish(HintRetrieveResult.UNKNOWN);
             return;
         }
 
         // filter the credentials to just those which are pertinent to the request. For those
         // selected, turn them into credentials. Order the hints by the amount of information
         // they contain (so more complete items are displayed first), and then alphabetically.
         ArrayList<Hint> filteredHints = new ArrayList<>();
         for (AccountHint hint : hints) {
             AuthenticationMethod hintAuthMethod = new AuthenticationMethod(hint.getAuthMethod());
             Set<AuthenticationMethod> authMethods = mRequest.getAuthenticationMethods();
             if (!authMethods.contains(hintAuthMethod)) {
                 continue;
             }
 
             Hint.Builder hintProtoBuilder = new Hint.Builder(
                     hint.getIdentifier(),
                     hintAuthMethod)
                     .setDisplayName(hint.getName())
                     .setDisplayPictureUri(hint.getPictureUri());
 
             // include a generated password if appropriate
             if (hintAuthMethod.equals(AuthenticationMethods.EMAIL)
                     || hintAuthMethod.equals(AuthenticationMethods.PHONE)
                     || hintAuthMethod.equals(AuthenticationMethods.USER_NAME)) {
                 hintProtoBuilder.setGeneratedPassword(
                         mRequest.getPasswordSpecification().generate());
             }
 
             filteredHints.add(hintProtoBuilder.build());
         }
 
         // if there are no hints, immediately end the request
         if (filteredHints.isEmpty()) {
             setResultAndFinish(HintRetrieveResult.NO_HINTS_AVAILABLE);
             return;
         }
 
         // otherwise, display the standard credential picker.
         renderPicker(filteredHints);
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void renderPicker(List<Hint> hints) {
         setContentView(R.layout.hint_picker_layout);
 
         RecyclerView hintsView = (RecyclerView) findViewById(R.id.available_hints);
 
         hintsView.setAdapter(new HintPickerAdapter(hints));
         hintsView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     private boolean extractCallerAuthDomain() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         String callingPackage = callingActivity.getPackageName();
         List<AuthenticationDomain> authDomains =
                 AuthenticationDomain.listForPackage(this, callingPackage);
 
         if (authDomains.isEmpty()) {
             return false;
         }
 
         mCallerAuthDomain = authDomains.get(0);
         return true;
     }
 
     @UiThread
     private void setResultAndFinish(HintRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private final class HintPickerAdapter extends RecyclerView.Adapter<AccountViewHolder> implements
             ClickHandler<Hint> {
 
         List<Hint> mHints;
 
         HintPickerAdapter(List<Hint> hints) {
             mHints = hints;
         }
 
         @Override
         public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new AccountViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(AccountViewHolder holder, int position) {
             holder.bind(mHints.get(position), this);
         }
 
         @Override
         public int getItemCount() {
             return mHints.size();
         }
 
         @Override
         public void onClick(Hint clicked) {
             HintRetrieveResult result = new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_HINT_SELECTED)
                     .setHint(clicked)
                     .build();
 
             setResultAndFinish(result);
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index 42deb33..fe5e2f4 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -30,113 +30,115 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.ProtocolConstants;
-import org.openyolo.protocol.internal.CollectionConverter;
-import org.openyolo.protocol.internal.CredentialConverter;
 
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
 public class RetrieveCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "RetrieveCredential";
     private CredentialStorageClient mClient;
     private CredentialRetrieveRequest mRequest;
 
     /**
      * Creates the intent to handle releasing a credential to the calling app.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         // the format of this intent needs to be compatible with a "direct invocation" intent,
         // based on the spec (Section 4.3.1).
         Intent intent = new Intent(context, RetrieveCredentialActivity.class);
         intent.setAction(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
         intent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_REQUEST,
                 request.toProtocolBuffer().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
             mRequest = CredentialRetrieveRequest.fromRequestIntent(getIntent());
-        } catch (IOException e) {
+        } catch (MalformedDataException ex) {
             setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
         }
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
         if (!client.isUnlocked()) {
             Intent retrieveAfterUnlockIntent =
                     RetrieveCredentialActivity.createIntent(this, mRequest);
             retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
             Intent unlockIntent =
                     UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
             unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(unlockIntent);
             finish();
         } else {
             // TODO: we actually need the full set of requested domains from the original request,
             // not just those based on the package name.
 
             List<AuthenticationDomain> authDomains =
                     AuthenticationDomain.listForPackage(this, getCallingPackage());
 
             List<Credential> credentials;
             try {
-                credentials = CollectionConverter.toList(
-                        client.listCredentials(authDomains),
-                        CredentialConverter.PROTO_TO_CREDENTIAL);
+                credentials =
+                        CredentialTransformUtils.fromProtoList(client.listCredentials(authDomains));
             } catch (IOException ex) {
                 Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
                 finish();
                 return;
+            } catch (MalformedDataException ex) {
+                Log.w(LOG_TAG, "Unable to parse credentials from their protocol buffer form", ex);
+                finish();
+                return;
             }
 
             if (credentials.size() == 1) {
                 Intent autoSignInIntent =
                         AutoSignInActivity.createIntent(this, credentials.get(0));
                 autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(autoSignInIntent);
             } else {
                 Intent pickerIntent =
                         CredentialPickerActivity.createIntent(this, credentials);
                 pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(pickerIntent);
             }
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
index 8d1eba0..cdbe6db 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -29,2 +29,3 @@ import org.openyolo.protocol.CredentialSaveRequest;
 import org.openyolo.protocol.CredentialSaveResult;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.ProtocolConstants;
@@ -32,116 +33,116 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * Verifies the rights to save a credential, before proceeding to
  * {@link SaveCredentialConfirmationActivity}.
  */
 public class SaveCredentialActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
 
     private CredentialSaveRequest mRequest;
     private String mCallingPackage;
     private List<AuthenticationDomain> mAuthDomainsForApp;
     private CredentialStorageClient mStorageClient;
 
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         final byte[] encodedRequest =
                 getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_REQUEST);
 
         // Ensure the intent contains a save request
         if (null == encodedRequest) {
             Log.w(LOG_TAG, "No save request included in intent");
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         // Ensure the request can successfully be parsed from it's encoded form
         try {
             mRequest = CredentialSaveRequest.fromProtoBytes(encodedRequest);
-        } catch (IOException ex) {
-            Log.w(LOG_TAG, "Failed to decode save request");
+        } catch (MalformedDataException ex) {
+            Log.w(LOG_TAG, "Failed to decode save request", ex);
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         if (!verifyCaller()) {
             Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
                     + mRequest.getCredential().getAuthenticationDomain());
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(final CredentialStorageClient client) {
                 mStorageClient = client;
                 runOnUiThread(new AfterStorageConnect());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         if (mStorageClient != null) {
             mStorageClient.disconnect(this);
         }
     }
 
     @UiThread
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private boolean verifyCaller() {
         final ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         mCallingPackage = callingActivity.getPackageName();
         mAuthDomainsForApp = AuthenticationDomain.listForPackage(this, mCallingPackage);
 
         final AuthenticationDomain authDomain = mRequest.getCredential().getAuthenticationDomain();
         if (!mAuthDomainsForApp.contains(authDomain)) {
             Log.w(LOG_TAG, "App " + mCallingPackage
                     + " is not provably associated to authentication domain "
                     + authDomain
                     + " for the credential to be saved.");
             return false;
         }
 
         return true;
     }
 
     private final class AfterStorageConnect implements Runnable {
         @Override
         public void run() {
             try {
                 // Ensure authentication domain is not on never save list
                 if (mStorageClient.isOnNeverSaveList(mAuthDomainsForApp)) {
                     finishWithResult(CredentialSaveResult.PROVIDER_REFUSED);
                     return;
                 }
 
                 // Start confirm activity
                 Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
                         SaveCredentialActivity.this,
                         mCallingPackage,
                         mRequest.getCredential());
                 confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(confirmIntent);
                 finish();
             } catch (IOException ex) {
                 finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
index f0fb5de..c7207dc 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -35,134 +35,135 @@ import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.CredentialSaveResult;
+import org.openyolo.protocol.MalformedDataException;
 
 /**
  * Confirms with the user whether they want to save a credential provided by the
  * calling app. Verification of the app's right to save such a credential occurs
  * in {@link SaveCredentialActivity} before reaching this point.
  */
 public class SaveCredentialConfirmationActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
     private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
 
     @BindView(R.id.save_prompt)
     TextView mSavePromptView;
 
     private Credential mCredential;
     private String mCallingAppName;
 
     private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
     private final CountDownLatch mClientConnected = new CountDownLatch(1);
 
     /**
      * Creates an intent to confirm whether the user wishes to save the specified credential.
      */
     public static Intent createIntent(
             Context context,
             String callingPackage,
             Credential credential) {
         Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
         intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toProtobuf().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mCredential = Credential.fromProtoBytes(
                     getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
-        } catch (IOException e) {
+        } catch (MalformedDataException e) {
             Log.e(LOG_TAG, "Unable to decode credential", e);
             finishWithResult(CredentialSaveResult.UNSPECIFIED);
         }
 
         mCallingAppName = CallerUtil.getCallingAppName(this);
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 mClient.set(client);
                 mClientConnected.countDown();
             }
         });
 
         setContentView(R.layout.save_layout);
         ButterKnife.bind(this);
 
         String savePromptTemplate = getString(R.string.save_prompt_template);
         mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
     }
 
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         CredentialStorageClient client = mClient.get();
         if (client != null) {
             client.disconnect(this);
         }
     }
 
     @OnClick(R.id.save_button)
     void onSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
             finishWithResult(CredentialSaveResult.UNSPECIFIED);
             return;
         }
 
         if (client.isUnlocked()) {
             try {
                 client.upsertCredential(mCredential.toProtobuf());
                 finishWithResult(CredentialSaveResult.SAVED);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to write credential to storage");
                 finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         } else {
             Intent saveAfterUnlock = UnlockActivity.createIntent(
                     this,
                     true,
                     SaveAfterUnlockActivity.createIntent(this, mCredential.toProtobuf()));
             saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(saveAfterUnlock);
             finish();
         }
     }
 
     @OnClick(R.id.never_save_button)
     void onNeverSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             finishWithResult(CredentialSaveResult.USER_REFUSED);
             return;
         }
 
         try {
             client.addToNeverSaveList(mCredential.getAuthenticationDomain());
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to add app to never save list", e);
         }
 
         finishWithResult(CredentialSaveResult.USER_REFUSED);
     }
 
     private CredentialStorageClient getStorageClient() {
         try {
             mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
             return mClient.get();
         } catch (InterruptedException e) {
             Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
             return null;
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
index 827540b..a63b57f 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
@@ -17,3 +17,5 @@ package org.openyolo.protocol;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.valid4j.Assertive.require;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationDomain;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.valid4j.Validation.validate;
 
@@ -35,225 +37,237 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.protocol.internal.CustomMatchers;
-import org.valid4j.Assertive;
 
 
 /**
  * A URI-based representation of an authentication domain, which determines the scope within which
  * a credential is valid. An authentication domain may have multiple equivalent representations,
  * such as when apps and sites share the same authentication system. The responsibility for
  * determining whether two given authentication domains are equivalent lies with the credential
  * provider.
  *
  * <p>Two broad classes of authentication domain are defined in the OpenYOLO
  * specification : Android authentication domains, of form
  * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
  * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
  * with no path, query or fragment. They must therefore always be of form
  * {@code scheme://authority}.
  */
 @SuppressLint("PackageManagerGetSignatures")
 public final class AuthenticationDomain implements Comparable<AuthenticationDomain> {
 
     private static final String DIGEST_SHA_512 = "SHA-512";
     private static final String SCHEME_ANDROID = "android";
     private static final String SCHEME_HTTP = "http";
     private static final String SCHEME_HTTPS = "https";
 
     private final String mUriStr;
 
     /**
      * Initially null, created on-demand for each thread from mUriStr.
      */
     private final ThreadLocal<Uri> mParsedUri = new ThreadLocal<>();
 
     /**
      * Creates an authentication domain that represents the current package, as identified
      * by the provided context's {@link Context#getPackageName() getPackageName} method.
      */
     @NonNull
     public static AuthenticationDomain getSelfAuthDomain(@NonNull Context context) {
-        require(context, notNullValue());
+        validate(context, notNullValue(), IllegalArgumentException.class);
 
         PackageManager pm = context.getPackageManager();
         String packageName = context.getPackageName();
         PackageInfo packageInfo;
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             throw new IllegalStateException("Unable to find package info for " + packageName);
         }
 
         return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
     }
 
     /**
      * Creates the list of all authentication domains that represent the specified package.
      * The list will contain a distinct entry for every signature related to the application.
      */
     @NonNull
     public static List<AuthenticationDomain> listForPackage(
             @NonNull Context context,
             @Nullable String packageName) {
-        require(context, notNullValue());
+        validate(context, notNullValue(), IllegalArgumentException.class);
 
         PackageManager pm = context.getPackageManager();
         PackageInfo packageInfo;
         if (TextUtils.isEmpty(packageName)) {
             return Collections.emptyList();
         }
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             return Collections.emptyList();
         }
 
         ArrayList<AuthenticationDomain> authDomains =
                 new ArrayList<>(packageInfo.signatures.length);
         for (Signature signature : packageInfo.signatures) {
             authDomains.add(createAndroidAuthDomain(packageName, signature));
         }
 
         return authDomains;
     }
 
     /**
      * Creates an Android authentication domain (of form {@code android://SIGNATURE@PACKAGE}),
      * given the provided package name and signature.
      */
     @NonNull
     public static AuthenticationDomain createAndroidAuthDomain(
             @NonNull String packageName,
             @NonNull Signature signature) {
-        require(!TextUtils.isEmpty(packageName), "packageName must not be null or empty");
-        require(signature, notNullValue());
+        validate(packageName, notNullOrEmptyString(), IllegalArgumentException.class);
+        validate(signature, notNullValue(), IllegalArgumentException.class);
 
         return new AuthenticationDomain(
                 new Uri.Builder()
                         .scheme(SCHEME_ANDROID)
                         .encodedAuthority(generateSignatureHash(signature) + "@" + packageName)
                         .build()
                         .toString());
     }
 
     /**
      * Creates an authentication domain from its protocol buffer equivalent, in byte form.
-     * @throws IOException if the protocol buffer cannot be parsed.
+     * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     @NonNull
     public static AuthenticationDomain fromProtobufBytes(@NonNull byte[] protobufBytes)
-            throws IOException {
-        return fromProtobuf(Protobufs.AuthenticationDomain.parseFrom(protobufBytes));
+            throws MalformedDataException {
+        validate(protobufBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.AuthenticationDomain.parseFrom(protobufBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException("Unable to parse the given protocol buffer", ex);
+        }
     }
 
     /**
      * Creates an authentication domain from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is invalid.
      */
     @NonNull
     public static AuthenticationDomain fromProtobuf(
-            @NonNull Protobufs.AuthenticationDomain authDomain) {
-        return new AuthenticationDomain(authDomain.getUri());
+            @NonNull Protobufs.AuthenticationDomain authDomain) throws MalformedDataException {
+        validate(authDomain, notNullValue(), MalformedDataException.class);
+
+        try {
+            return new AuthenticationDomain(authDomain.getUri());
+        } catch (IllegalArgumentException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     @NonNull
     static String generateSignatureHash(@NonNull Signature signature) {
         try {
             MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_512);
             byte[] hashBytes = digest.digest(signature.toByteArray());
             return Base64.encodeToString(hashBytes, Base64.URL_SAFE).replace("\n", "");
         } catch (NoSuchAlgorithmException e) {
             throw new IllegalStateException(
                     "Platform does not support" + DIGEST_SHA_512 + " hashing");
         }
     }
 
     /**
      * Creates an authentication domain from the provided String representation. If the string
      * provided is not a valid authentication domain, an {@link IllegalArgumentException}
      * will be thrown.
      */
     public AuthenticationDomain(@NonNull String authDomainString) {
-        mUriStr = Assertive.require(
+        mUriStr = validate(
                 authDomainString,
-                CustomMatchers.isValidAuthenticationDomain());
+                isValidAuthenticationDomain(),
+                IllegalArgumentException.class);
     }
 
     /**
      * Determines whether the authentication domain refers to an Android application.
      */
     public boolean isAndroidAuthDomain() {
         return SCHEME_ANDROID.equals(getParsedUri().getScheme());
     }
 
     /**
      * Determines whether the authentication domain refers to a Web domain.
      */
     public boolean isWebAuthDomain() {
         Uri parsedUri = getParsedUri();
         return SCHEME_HTTP.equals(parsedUri.getScheme())
                 || SCHEME_HTTPS.equals(parsedUri.getScheme());
     }
 
     /**
      * Retrieves the Android package name from the authentication domain. If the authentication
      * domain does not represent an Android application, an {@link IllegalStateException} will
      * be thrown.
      */
     @NonNull
     public String getAndroidPackageName() {
         if (!isAndroidAuthDomain()) {
             throw new IllegalStateException("Authentication domain is not an Android domain");
         }
         return getParsedUri().getHost();
     }
 
     /**
      * Creates a protocol buffer representation of the authentication domain, for transmission
      * or storage.
      */
     public Protobufs.AuthenticationDomain toProtobuf() {
         return Protobufs.AuthenticationDomain.newBuilder()
                 .setUri(mUriStr)
                 .build();
     }
 
     /**
      * Retrieves the string form of the authentication domain.
      */
     @NonNull
     public String toString() {
         return mUriStr;
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (!(obj instanceof AuthenticationDomain)) {
             return false;
         }
 
         return compareTo((AuthenticationDomain) obj) == 0;
     }
 
     @Override
     public int hashCode() {
         return mUriStr.hashCode();
     }
 
     @Override
     public int compareTo(@NonNull AuthenticationDomain authenticationDomain) {
         return mUriStr.compareTo(authenticationDomain.mUriStr);
     }
 
     private Uri getParsedUri() {
         Uri parsedUri = mParsedUri.get();
         if (parsedUri == null) {
             parsedUri = Uri.parse(mUriStr);
             mParsedUri.set(parsedUri);
         }
 
         return parsedUri;
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationMethod.java b/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
index c4afa08..2f76a7e 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
@@ -16,3 +16,4 @@ package org.openyolo.protocol;
 
-import static org.valid4j.Assertive.require;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Validation.validate;
 
@@ -24,68 +25,88 @@ import org.openyolo.protocol.internal.CustomMatchers;
 /**
  * A URI-based representation of an authentication method, which describes how a credential is
  * used to authenticate a user.
  */
 public final class AuthenticationMethod implements Comparable<AuthenticationMethod> {
 
     /**
      * Creates an authentication method from its protocol buffer equivalent, in byte form.
-     * @throws IOException if the protocol buffer cannot be parsed.
+     * @throws MalformedDataException if the given protocol buffer byte array is null or the parsed
+     *     protocol buffer is not valid.
      */
-    public static AuthenticationMethod fromProtobufBytes(byte[] protoBufBytes) throws IOException {
-        return fromProtobuf(Protobufs.AuthenticationMethod.parseFrom(protoBufBytes));
+    public static AuthenticationMethod fromProtobufBytes(@NonNull byte[] protoBufBytes)
+            throws MalformedDataException {
+        validate(protoBufBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.AuthenticationMethod.parseFrom(protoBufBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     /**
      * Creates an authentication method from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is null or the parsed protocol
+     *      buffer is not valid.
      */
-    public static AuthenticationMethod fromProtobuf(Protobufs.AuthenticationMethod authMethod) {
-        return new AuthenticationMethod(authMethod.getUri());
+    public static AuthenticationMethod fromProtobuf(
+            @NonNull Protobufs.AuthenticationMethod authMethod) throws MalformedDataException {
+        validate(authMethod, notNullValue(), MalformedDataException.class);
+
+        try {
+            return new AuthenticationMethod(authMethod.getUri());
+        } catch (IllegalArgumentException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     private final String mUri;
 
     /**
      * Creates an authentication method from a URI string.
      */
     public AuthenticationMethod(@NonNull String authMethodUriStr) {
-        mUri = require(authMethodUriStr, CustomMatchers.isValidAuthenticationMethod());
+        mUri = validate(
+                authMethodUriStr,
+                CustomMatchers.isValidAuthenticationMethod(),
+                IllegalArgumentException.class);
     }
 
     /**
      * Creates a protocol buffer representation of the authentication method, for transmission or
      * storage.
      */
     public Protobufs.AuthenticationMethod toProtobuf() {
         return Protobufs.AuthenticationMethod.newBuilder()
                 .setUri(mUri)
                 .build();
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (!(obj instanceof AuthenticationMethod)) {
             return false;
         }
 
         return compareTo((AuthenticationMethod)obj) == 0;
     }
 
     @Override
     public int hashCode() {
         return mUri.hashCode();
     }
 
     @Override
     public int compareTo(@NonNull AuthenticationMethod authMethod) {
         return mUri.compareTo(authMethod.mUri);
     }
 
     @Override
     public String toString() {
         return mUri;
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 4e6351e..2d79377 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -16,3 +16,2 @@ package org.openyolo.protocol;
 
-import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -22,3 +21,3 @@ import static org.openyolo.protocol.internal.CustomMatchers.nullOr;
 import static org.openyolo.protocol.internal.StringUtil.nullifyEmptyString;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -29,9 +28,8 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.text.TextUtils;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
+import com.google.protobuf.InvalidProtocolBufferException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import org.openyolo.protocol.internal.AuthenticationDomainConverters;
-import org.openyolo.protocol.internal.AuthenticationMethodConverters;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -40,416 +38,401 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a credential for use in sign-in. This provides a higher-level,
  * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
  * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     /**
      * Creates a credential from its protocol buffer equivalent, in byte form.
-     * @throws IOException if the protocol buffer cannot be parsed.
+     * @throws MalformedDataException if the given protocol buffer is invalid.
      */
-    public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
-        return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
+    public static Credential fromProtoBytes(@NonNull byte[] credentialProtoBytes)
+            throws MalformedDataException {
+        validate(credentialProtoBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
+        } catch (InvalidProtocolBufferException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     /**
      * Creates a credential from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is invalid.
      */
-    public static Credential fromProtobuf(Protobufs.Credential credential) {
+    public static Credential fromProtobuf(Protobufs.Credential credential)
+            throws MalformedDataException {
         return new Credential.Builder(credential).build();
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationDomain mAuthDomain;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPicture;
 
     @Nullable
     private final String mPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
-    private Credential(
-            @NonNull String id,
-            @NonNull AuthenticationDomain authDomain,
-            @NonNull AuthenticationMethod authMethod,
-            @Nullable String displayName,
-            @Nullable Uri displayPicture,
-            @Nullable String password,
-            @Nullable String idToken,
-            @NonNull Map<String, ByteString> additionalProps) {
-        mId = id;
-        mAuthDomain = authDomain;
-        mAuthMethod = authMethod;
-        mDisplayName = displayName;
-        mDisplayPicture = displayPicture;
-        mPassword = password;
-        mIdToken = idToken;
-        mAdditionalProps = additionalProps;
+    private Credential(Builder builder) {
+        mId = builder.mId;
+        mAuthDomain = builder.mAuthDomain;
+        mAuthMethod = builder.mAuthMethod;
+        mDisplayName = builder.mDisplayName;
+        mDisplayPicture = builder.mDisplayPicture;
+        mPassword = builder.mPassword;
+        mIdToken = builder.mIdToken;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
     public Protobufs.Credential toProtobuf() {
         Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .setAuthDomain(mAuthDomain.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPicture != null) {
             builder.setDisplayPictureUri(mDisplayPicture.toString());
         }
 
         if (mPassword != null) {
             builder.setPassword(mPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
     @NonNull
     public AuthenticationDomain getAuthenticationDomain() {
         return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPicture;
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
         return mPassword;
     }
 
     /**
      * An ID token which provides "proof of access" to the identifier for this credential, if
      * available.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
             mAdditionalProps,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
         private String mId;
         private AuthenticationMethod mAuthMethod;
         private AuthenticationDomain mAuthDomain;
         private String mDisplayName;
         private Uri mDisplayPicture;
         private String mPassword;
         private String mIdToken;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
+         * @throws MalformedDataException if the given protocol buffer is invalid.
          */
-        private Builder(@NonNull Protobufs.Credential proto) {
-            // required properties
-            setIdentifier(proto.getId());
-            setAuthenticationMethod(
-                    AuthenticationMethodConverters.PROTOBUF_TO_OBJECT
-                            .convert(proto.getAuthMethod()));
-            setAuthenticationDomain(
-                    AuthenticationDomainConverters.PROTOBUF_TO_OBJECT
-                            .convert(proto.getAuthDomain()));
-
-            // optional properties
-
-            setIdToken(proto.getIdToken());
-            setDisplayName(proto.getDisplayName());
-            setDisplayPicture(proto.getDisplayPictureUri());
-            setPassword(proto.getPassword());
-            setAdditionalProperties(
-                    CollectionConverter.convertMapValues(
-                            proto.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        private Builder(@NonNull Protobufs.Credential proto) throws MalformedDataException {
+            try {
+                // required properties
+                setIdentifier(proto.getId());
+                setAuthenticationMethod(AuthenticationMethod.fromProtobuf(proto.getAuthMethod()));
+                setAuthenticationDomain(AuthenticationDomain.fromProtobuf(proto.getAuthDomain()));
+
+                // optional properties
+
+                setIdToken(proto.getIdToken());
+                setDisplayName(proto.getDisplayName());
+                setDisplayPicture(proto.getDisplayPictureUri());
+                setPassword(proto.getPassword());
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                proto.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
          * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
                     new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
-            require(!TextUtils.isEmpty(identifier), "identifier must not be null or empty");
+            validate(identifier, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
-            require(domain, notNullValue());
+            validate(domain, notNullValue(), IllegalArgumentException.class);
             mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
         public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
-            require(authMethod, notNullValue());
+            validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
             mPassword = nullifyEmptyString(password);
             return this;
         }
 
         /**
          * Specifies the ID token for the credential. If a null or empty value is provided, this
          * is equivalent to remove the ID token from the credential.
          */
         @NonNull
         public Builder setIdToken(String idToken) {
             this.mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
-            require(displayPicture, nullOr(isWebUri()));
+            validate(displayPicture, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
-            if (additionalProps == null) {
-                mAdditionalProps.clear();
-                return this;
-            }
-
-            require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
-            require(additionalProps.values(), everyItem(notNullValue()));
+            mAdditionalProps =
+                AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
-            mAdditionalProps = CollectionConverter.convertMapValues(
-                    additionalProps,
-                    ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
-            return new Credential(
-                    mId,
-                    mAuthDomain,
-                    mAuthMethod,
-                    mDisplayName,
-                    mDisplayPicture,
-                    mPassword,
-                    mIdToken,
-                    mAdditionalProps);
+            return new Credential(this);
         }
     }
 
     private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
-                Protobufs.Credential proto = Protobufs.Credential.parseFrom(encodedBytes);
-                return new Credential.Builder(proto).build();
-            } catch (IOException ex) {
+                return Credential.fromProtoBytes(encodedBytes);
+            } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index e78582d..63c8638 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -19,3 +19,3 @@ import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAd
 import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -33,169 +33,158 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
  */
 public final class CredentialDeleteRequest {
 
     /**
-     * Creates a credential deletion request from its protocol buffer equivalent.
-     * @throws MalformedDataException if the protocol buffer is null or contains invalid data.
+     * Creates a credential deletion request from its protocol buffer equivalent, in byte array
+     * form.
+     * @throws MalformedDataException if the given protocol buffer is invalid.
      */
-    public static CredentialDeleteRequest fromProtobuf(
-            @Nullable Protobufs.CredentialDeleteRequest proto)
+    public static CredentialDeleteRequest fromProtobufBytes(@NonNull byte[] protobufBytes)
             throws MalformedDataException {
-        if (proto == null) {
-            throw new MalformedDataException("credential delete proto is not defined");
-        }
+        validate(protobufBytes, notNullValue(), MalformedDataException.class);
 
         try {
-            return new Builder(proto).build();
-        } catch (RequireViolation ex) {
-            throw new MalformedDataException("credential deletion request contains invalid data");
+            return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
+        } catch (InvalidProtocolBufferException ex) {
+            throw new MalformedDataException("unable to parse credential deletion request", ex);
         }
     }
 
     /**
-     * Creates a credential deletion request from its protocol buffer equivalent, in byte array
-     * form.
-     * @throws MalformedDataException if the protocol buffer is null or cannot be parsed from the
-     *     byte array.
+     * Creates a credential deletion request from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is invalid.
      */
-    public static CredentialDeleteRequest fromProtobufBytes(
-            @Nullable byte[] protobufBytes)
+    public static CredentialDeleteRequest fromProtobuf(
+            @NonNull Protobufs.CredentialDeleteRequest proto)
             throws MalformedDataException {
-        if (protobufBytes == null) {
-            throw new MalformedDataException("credential deletion request not defined");
-        }
+        validate(proto, notNullValue(), MalformedDataException.class);
 
-        try {
-            return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
-        } catch (InvalidProtocolBufferException ex) {
-            throw new MalformedDataException("unable to parse credential deletion request", ex);
-        }
+        return new Builder(proto).build();
     }
 
+
     /**
      * Extracts a credential deletion request from a request intent.
      * @throws MalformedDataException if the provided intent is null, is missing the byte array
      *     extra for the request, or the request contains invalid data.
      */
     public static CredentialDeleteRequest fromRequestIntent(
             @Nullable Intent requestIntent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_REQUEST,
                         Protobufs.CredentialDeleteRequest.parser(),
                         "deletion request missing or contains invalid data",
                         requestIntent));
     }
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be deleted.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties specified by the client as part of this
      * deletion request.
      */
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Converts the request to its protocol buffer equivalent.
      */
     public Protobufs.CredentialDeleteRequest toProtobuf() {
         return Protobufs.CredentialDeleteRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Creates instances of {@link CredentialDeleteRequest}.
      */
     public static final class Builder {
 
         @NonNull
         private Credential mCredential;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion request, based on the properties
          * contained in the provided protocol buffer.
          */
-        public Builder(Protobufs.CredentialDeleteRequest proto) {
-            setCredentialFromProto(proto.getCredential());
-            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        private Builder(Protobufs.CredentialDeleteRequest proto) throws MalformedDataException {
+            try {
+                setCredential(Credential.fromProtobuf(proto.getCredential()));
+                setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * credential object.
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be deleted. Must not be null.
          */
         public Builder setCredential(@NonNull Credential credential) {
-            require(credential, notNullValue());
-            mCredential = credential;
-            return this;
-        }
+            validate(credential, notNullValue(), IllegalArgumentException.class);
 
-        private Builder setCredentialFromProto(@Nullable Protobufs.Credential credentialProto) {
-            require(credentialProto, notNullValue());
-            setCredential(Credential.fromProtobuf(credentialProto));
+            mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(
                 @Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion request, from the specified properties.
          */
         public CredentialDeleteRequest build() {
             return new CredentialDeleteRequest(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index 588b191..a2eecfd 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -16,2 +16,5 @@ package org.openyolo.protocol;
 
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Validation.validate;
+
 import android.content.Intent;
@@ -28,261 +31,260 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  */
 public final class CredentialDeleteResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult UNKNOWN =
             new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
     private static final String UNABLE_TO_EXTRACT_RESULT =
             "Unable to extract or parse the credential deletion result";
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
-     * @throws MalformedDataException if the protocol buffer contains invalid data.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
             throws MalformedDataException {
-        try {
-            return new CredentialDeleteResult.Builder(proto).build();
-        } catch (RequireViolation ex) {
-            throw new MalformedDataException(
-                    "credential deletion result contains invalid data", ex);
-        }
+        validate(proto, notNullValue(), IllegalArgumentException.class);
+
+        return new CredentialDeleteResult.Builder(proto).build();
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
-     * @throws MalformedDataException if the protocol buffer could not be parsed from the byte
-     *     array, or contains invalid data.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
             throws MalformedDataException {
-        if (protoBytes == null) {
-            throw new MalformedDataException("credential deletion result bytes cannot be null");
-        }
+        validate(protoBytes, notNullValue(), MalformedDataException.class);
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
         } catch (InvalidProtocolBufferException ex) {
-            throw new MalformedDataException("credential deletion result could not be parsed",  ex);
+            throw new MalformedDataException(ex);
         }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
      * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
     public static CredentialDeleteResult fromResultIntentData(
             @Nullable Intent intent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_RESULT,
                         Protobufs.CredentialDeleteResult.parser(),
                         UNABLE_TO_EXTRACT_RESULT,
                         intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * credential deletion result, if available.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
     public Intent toResultIntentData() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
+         * @throws MalformedDataException if the protocol buffer could not be parsed from the
+         *     intent.
          */
-        public Builder(Protobufs.CredentialDeleteResult proto) {
-            setResultCode(proto.getResultCodeValue());
-            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        private Builder(Protobufs.CredentialDeleteResult proto) throws MalformedDataException {
+            try {
+                setResultCode(proto.getResultCodeValue());
+                setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion result. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index 4ff4631..82bcb89 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -25,3 +25,2 @@ import static org.openyolo.protocol.internal.CustomMatchers.isHttpsUriStr;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
-import static org.valid4j.Assertive.require;
 import static org.valid4j.Validation.validate;
@@ -34,3 +33,2 @@ import android.support.annotation.Nullable;
 import java.io.IOException;
-import java.nio.charset.Charset;
 import java.util.Collections;
@@ -48,355 +46,319 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class CredentialRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
-            @NonNull Protobufs.CredentialRetrieveRequest proto) {
+            @NonNull Protobufs.CredentialRetrieveRequest proto) throws MalformedDataException {
+        validate(proto, notNullValue(), MalformedDataException.class);
+
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
-     * @throws IOException if the request could not be parsed and validated.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
-            throws IOException {
-        return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
+            throws MalformedDataException {
+        validate(protoBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
-     * @throws IOException if the intent does not contain a retrieve request, or the contained
-     *     request could not be parsed and validated.
+     * @throws MalformedDataException if the intent does not contain a retrieve request, or the
+     *     contained request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
-            throws IOException {
+            throws MalformedDataException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
-            throw new IOException("credential retrieve request missing in intent data");
+            throw new MalformedDataException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
     private CredentialRetrieveRequest(Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalParams);
     }
 
     /**
      * The set of authentication methods that the requester supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The set of token providers that the requester supports. These are used by the
      * credential provider and the OpenYOLO client library to attempt to acquire a "proof of access"
      * ID token for any returned credential.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
-    /**
-     * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
-     * string.
-     */
-    @Nullable
-    public String getAdditionalPropertyAsString(@NonNull String key) {
-        validate(key, notNullValue(), IllegalArgumentException.class);
-
-        if (mAdditionalProps.containsKey(key)) {
-            return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
-        }
-        return null;
-    }
-
-    /**
-     * Retrieves the raw, byte-array value of the named additional parameter.
-     */
-    @Nullable
-    public byte[] getAdditionalProperty(@NonNull String key) {
-        validate(key, notNullValue(), IllegalArgumentException.class);
-
-        return mAdditionalProps.get(key);
-    }
-
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
+         * @throws MalformedDataException if the given protocol buffer is not valid.
          */
-        public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
-            validate(requestProto, notNullValue(), IllegalArgumentException.class);
+        private Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto)
+                throws MalformedDataException {
+            validate(requestProto, notNullValue(), MalformedDataException.class);
 
-            setAuthenticationMethods(CollectionConverter.toSet(
-                    requestProto.getAuthMethodsList(),
-                    AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
+            try {
+                setAuthenticationMethods(CollectionConverter.toSet(
+                        requestProto.getAuthMethodsList(),
+                        AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
 
-            setTokenProviders(CollectionConverter.convertMapValues(
-                    requestProto.getSupportedTokenProvidersMap(),
-                    TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
+                setTokenProviders(CollectionConverter.convertMapValues(
+                        requestProto.getSupportedTokenProvidersMap(),
+                        TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
 
-            setAdditionalProperties(
-                    CollectionConverter.convertMapValues(
-                            requestProto.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                requestProto.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
-            require(tokenProviderUri, isHttpsUriStr());
+            validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
+
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
-        /**
-         * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
-         * parameter name and value must be non-null.
-         *
-         * @see CredentialRetrieveRequest#getAdditionalPropertyAsString(String)
-         */
-        public Builder addAdditionalProperty(
-                @NonNull String name,
-                @NonNull String value) {
-            validate(value, notNullValue(), IllegalArgumentException.class);
-
-            addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
-            return this;
-        }
-
-        /**
-         * Adds an additional parameter. Both the parameter name and value must be non-null.
-         */
-        public Builder addAdditionalProperty(String name, byte[] value) {
-            validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
-            validate(value, notNullValue(), IllegalArgumentException.class);
-
-            mAdditionalParams.put(name, value);
-            return this;
-        }
-
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public CredentialRetrieveRequest build() {
             return new CredentialRetrieveRequest(this);
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
-                return new CredentialRetrieveRequest.Builder(
-                        Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
-                        .build();
-            } catch (IOException ex) {
+                return CredentialRetrieveRequest.fromProtobufBytes(protoBytes);
+            } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 3ab5c64..19cffe9 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -16,2 +16,5 @@ package org.openyolo.protocol;
 
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Validation.validate;
+
 import android.content.Intent;
@@ -20,3 +23,3 @@ import android.support.annotation.Nullable;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
+import com.google.protobuf.InvalidProtocolBufferException;
 import java.util.Collections;
@@ -29,239 +32,257 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the user selected a hint, that has been returned as part of this response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
-     * @throws IOException if the request could not be parsed or validated.
+     * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
-            throws IOException {
-        return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
+            throws MalformedDataException {
+        validate(protobufBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
+        } catch (InvalidProtocolBufferException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer form of the request was invalid.
      */
-    public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto) {
+    public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto)
+            throws MalformedDataException {
+        validate(proto, notNullValue(), MalformedDataException.class);
+
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
+         * @throws MalformedDataException if the given protocol buffer was invalid.
          */
-        private Builder(Protobufs.CredentialRetrieveResult proto) {
-            setResultCode(proto.getResultCodeValue());
-            setCredentialFromProto(proto.getCredential());
-            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        private Builder(Protobufs.CredentialRetrieveResult proto) throws MalformedDataException {
+            validate(proto, notNullValue(), MalformedDataException.class);
+
+            try {
+                setResultCode(proto.getResultCodeValue());
+                setCredentialFromProto(proto.getCredential());
+                setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
-        private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
+        private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential)
+                throws MalformedDataException {
             if (!Protobufs.Credential.getDefaultInstance().equals(credential)) {
                 mCredential = Credential.fromProtobuf(credential);
             } else {
                 mCredential = null;
             }
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                             additionalProperties);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
index bf01e19..7dfec2f 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
@@ -17,3 +17,3 @@ package org.openyolo.protocol;
 import static org.hamcrest.core.IsNull.notNullValue;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -32,189 +32,198 @@ import org.openyolo.protocol.internal.ClientVersionUtil;
 import org.openyolo.protocol.internal.CollectionConverter;
-import org.openyolo.protocol.internal.CredentialConverter;
 
 /**
  * A request to save a given {@link Credential credential}. To make the request the client
  * encodes it in its associated protocol buffer byte array form in an activity intent
  * via the {@link ProtocolConstants#EXTRA_SAVE_REQUEST} extra.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credentials</a>
  */
 public final class CredentialSaveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link CredentialSaveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialSaveRequest> CREATOR = new CredentialSaveRequestCreator();
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save request from its protocol buffer byte array form.
-     * @throws IOException if the given save request could not be decoded.
+     * @throws MalformedDataException if the given protocol buffer was invalid.
      *
      * @see #toProtocolBuffer()
      */
-    public static CredentialSaveRequest fromProtoBytes(byte[] credentialSaveRequestBytes)
-            throws IOException {
-        if (credentialSaveRequestBytes == null) {
-            throw new IOException("Unable to decode credential save request from null array");
+    public static CredentialSaveRequest fromProtoBytes(byte[] protoBytes)
+            throws MalformedDataException {
+        validate(protoBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            Protobufs.CredentialSaveRequest request =
+                    Protobufs.CredentialSaveRequest.parseFrom(protoBytes);
+            return new CredentialSaveRequest.Builder(request).build();
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
         }
-
-        Protobufs.CredentialSaveRequest request =
-                Protobufs.CredentialSaveRequest.parseFrom(credentialSaveRequestBytes);
-
-        return new CredentialSaveRequest.Builder(request).build();
     }
 
     /**
      * Creates a credential save request from its protocol buffer form.
+     * @throws MalformedDataException if the given protocol buffer was invalid.
      *
      * @see #toProtocolBuffer()
      */
-    public static CredentialSaveRequest fromProtobuf(Protobufs.CredentialSaveRequest request) {
+    public static CredentialSaveRequest fromProtobuf(Protobufs.CredentialSaveRequest request)
+            throws MalformedDataException {
+        validate(request, notNullValue(), MalformedDataException.class);
+
         return new CredentialSaveRequest.Builder(request).build();
     }
 
     /**
      * Creates a {@link CredentialSaveRequest} from the given {@link Credential}.
      */
     public static CredentialSaveRequest fromCredential(Credential credential) {
         return new Builder(credential).build();
     }
 
     private CredentialSaveRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be saved.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
             mAdditionalProperties,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialSaveRequest toProtocolBuffer() {
         return Protobufs.CredentialSaveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProperties)
                 .build();
     }
 
     /**
      * Creates {@link CredentialSaveRequest} instances.
      */
     public static final class Builder {
 
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Recreates a save request from its protocol buffer form.
          *
          * @see CredentialSaveRequest#toProtocolBuffer()
          */
-        public Builder(@NonNull Protobufs.CredentialSaveRequest request) {
-            require(request, notNullValue());
-
-            setCredential(CredentialConverter.PROTO_TO_CREDENTIAL.convert(request.getCredential()));
-            setAdditionalProperties(
-                    CollectionConverter.convertMapValues(
-                            request.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        private Builder(@NonNull Protobufs.CredentialSaveRequest request)
+                throws MalformedDataException {
+            validate(request, notNullValue(), MalformedDataException.class);
+
+            try {
+                setCredential(Credential.fromProtobuf(request.getCredential()));
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                request.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of defining a save request, specifying the credential to be saved.
          *
          * @see Credential
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be saved. The provided credential must be non-null.
          *
          * @see Credential
          */
         public Builder setCredential(@NonNull Credential credential) {
-            require(credential, notNullValue());
+            validate(credential, notNullValue(), IllegalArgumentException.class);
 
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * save request. A null map is treated as an empty map.
          */
         @NonNull
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential save request.
          */
         public CredentialSaveRequest build() {
             return new CredentialSaveRequest(this);
         }
     }
 
     private static final class CredentialSaveRequestCreator
             implements Creator<CredentialSaveRequest> {
         @Override
         public CredentialSaveRequest createFromParcel(Parcel source) {
             int length = source.readInt();
             byte[] encodedRequest = new byte[length];
             source.readByteArray(encodedRequest);
 
             try {
                 return CredentialSaveRequest.fromProtoBytes(encodedRequest);
-            } catch (IOException ex) {
+            } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialSaveRequest[] newArray(int size) {
             return new CredentialSaveRequest[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
index afd9cb2..68dae7b 100644
--- a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -17,3 +17,3 @@ package org.openyolo.protocol;
 import static org.hamcrest.core.IsNull.notNullValue;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -31,212 +31,227 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential save request. Contains a result code,
  * indicating whether the request was successful or not, and an optional set of additional,
  * non-standard result properties.
  *
  * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
  *     OpenYOLO specification: Saving Credentials</a>
  */
 public final class CredentialSaveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential sent to the provider was saved.
      */
     public static final int CODE_SAVED =
             Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
 
     /**
      * Indicates the provider refused to save the credential, due to some policy restriction. For
      * example, a provider may refuse to update an existing credential if it is stored in a shared
      * keychain. The client SHOULD NOT request to save this credential again.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to save the credential, by either pressing the
      * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
      * that is not an explicit refusal to delete the credential. The client MAY request to save this
      * credential again at a later time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates the user refused the request to save this credential. The client SHOULD NOT request
      * to save this credential again.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
 
     /**
      * Pre-built save result for an unspecified outcome. Carries no additional properties.
      */
     public static final CredentialSaveResult UNSPECIFIED =
             new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
 
     /**
      * Pre-built save result that indicates the credential was saved. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult SAVED =
             new CredentialSaveResult.Builder(CODE_SAVED).build();
 
     /**
      * Pre-built save result that indicates the request was malformed. Carries no additional
      * properties.
      */
     public static final CredentialSaveResult BAD_REQUEST =
             new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the user. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult USER_REFUSED =
             new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
 
     /**
      * Pre-built save result that indicates the request was refused by the provider. Carries no
      * additional properties.
      */
     public static final CredentialSaveResult PROVIDER_REFUSED =
             new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     private final int mResultCode;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a credential save result from its protocol buffer byte equivalent.
-     * @throws IOException if the result could not be parsed or validated.
+     * @throws MalformedDataException if the result could not be parsed or validated.
      */
     public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
-            throws IOException {
-        return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
+            throws MalformedDataException {
+        validate(protobufBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     /**
      * Creates a credential save result from its protocol buffer equivalent.
+     * @throws MalformedDataException if the result could not be parsed or validated.
      */
-    public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto) {
+    public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto)
+            throws MalformedDataException {
+        validate(proto, notNullValue(), MalformedDataException.class);
+
         return new CredentialSaveResult.Builder(proto).build();
     }
 
     /**
      * Creates a protocol buffer representation of the credential save result, for transmission
      * or storage.
      */
     public Protobufs.CredentialSaveResult toProtobuf() {
         Protobufs.CredentialSaveResult.Builder builder =
                 Protobufs.CredentialSaveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProperties);
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential save result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_SAVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     private CredentialSaveResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProperties = builder.mAdditionalProps;
     }
 
     /**
      * The result code for the credential save operation.
      */
     @NonNull
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link CredentialSaveResult} instances.
      */
     public static final class Builder {
         private int mResultCode = CODE_UNKNOWN;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result given the mandatory status
          * code.
+         * @throws MalformedDataException if the given protocol buffer was not valid.
          */
-        public Builder(Protobufs.CredentialSaveResult proto) {
-            require(proto, notNullValue());
-
-            setResultCode(proto.getResultCodeValue());
-            setAdditionalProperties(
-                    CollectionConverter.convertMapValues(
-                            proto.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        private Builder(Protobufs.CredentialSaveResult proto) throws MalformedDataException {
+            validate(proto, notNullValue(), MalformedDataException.class);
+
+            try {
+                setResultCode(proto.getResultCodeValue());
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                proto.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Seeds a credential save result from its protocol buffer equivalent.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
 
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
 
             return this;
         }
 
         /**
          * Finalizes the creation of the credential save result.
          */
         public CredentialSaveResult build() {
             return new CredentialSaveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Hint.java b/protocol/java/org/openyolo/protocol/Hint.java
index dbb2fca..adb6d77 100644
--- a/protocol/java/org/openyolo/protocol/Hint.java
+++ b/protocol/java/org/openyolo/protocol/Hint.java
@@ -22,3 +22,3 @@ import static org.openyolo.protocol.internal.CustomMatchers.nullOr;
 import static org.openyolo.protocol.internal.StringUtil.nullifyEmptyString;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -39,347 +39,357 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a hint for use in account discovery or account creation. This provides a
  * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential protocol
  * buffer} that is returned by the provider.
  *
  * <p>Hints must have an {@link #getIdentifier() identifier} and an
  * an {@link #getAuthenticationMethod() authentication method}, but all other properties are
  * optional.
  */
 public final class Hint implements Parcelable {
 
     /**
      * Parcelable reader for {@link Hint} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Hint> CREATOR = new HintCreator();
 
     /**
      * Creates a hint from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
-    public static Hint fromProtobuf(Protobufs.Hint proto) {
+    public static Hint fromProtobuf(Protobufs.Hint proto) throws MalformedDataException {
         return new Hint.Builder(proto).build();
     }
 
     /**
      * Creates a hint from its protocol buffer equivalent, in byte array form.
-     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     * @throws MalformedDataException if the protocol buffer cannot be parsed from the byte array.
      */
-    public static Hint fromProtobufBytes(byte[] protoBytes) throws IOException {
-        return fromProtobuf(Protobufs.Hint.parseFrom(protoBytes));
+    public static Hint fromProtobufBytes(byte[] protoBytes) throws MalformedDataException {
+        validate(protoBytes, notNullValue(), MalformedDataException.class);
+        try {
+            return fromProtobuf(Protobufs.Hint.parseFrom(protoBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPictureUri;
 
     @Nullable
     private final String mGeneratedPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Hint(Hint.Builder builder) {
         mId = builder.mId;
         mAuthMethod = builder.mAuthMethod;
         mDisplayName = builder.mDisplayName;
         mDisplayPictureUri = builder.mDisplayPictureUri;
         mGeneratedPassword = builder.mGeneratedPassword;
         mIdToken = builder.mIdToken;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint, for transmission or storage.
      */
     public Protobufs.Hint toProtobuf() {
         Protobufs.Hint.Builder builder = Protobufs.Hint.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPictureUri != null) {
             builder.setDisplayPictureUri(mDisplayPictureUri.toString());
         }
 
         if (mGeneratedPassword != null) {
             builder.setGeneratedPassword(mGeneratedPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The hint identifier, for use in discovering an existing account within the context of the
      * authentication method and authentication domain (which is implicitly that of the requester),
      * or creating a new account.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication domain associated with the hint.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * A suggested display name for accounts created using this hint, if available.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * A suggested profile picture for accounts created using this hint. if available.
      */
     @Nullable
     public Uri getDisplayPictureUri() {
         return mDisplayPictureUri;
     }
 
     /**
      * A suggested password for use with accounts created using this hint, if available.
      */
     @Nullable
     public String getGeneratedPassword() {
         return mGeneratedPassword;
     }
 
     /**
      * An ID token that provides "proof of access" to the hint identifier, if available.
      * When provided this can be used either as a means of authentication in its
      * own right, or as a means to bypass manual proof of access verification, such as by sending
      * an email with a verification link or an SMS with a code.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the hint.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] hintBytes = toProtobuf().toByteArray();
         dest.writeInt(hintBytes.length);
         dest.writeByteArray(hintBytes);
     }
 
     /**
      * Creates instances of {@link Hint}.
      */
     public static final class Builder {
 
         @NonNull
         private String mId;
 
         @NonNull
         private AuthenticationMethod mAuthMethod;
 
         @Nullable
         private String mDisplayName;
 
         @Nullable
         private Uri mDisplayPictureUri;
 
         @Nullable
         private String mGeneratedPassword;
 
         @Nullable
         private String mIdToken;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull AuthenticationMethod authMethod) {
             setIdentifier(id);
             setAuthMethod(authMethod);
         }
 
         /**
          * Starts the process of creating a hint, with the mandatory properties specified.
          */
         public Builder(
                 @NonNull String id,
                 @NonNull String authMethod) {
             this(id, new AuthenticationMethod(authMethod));
         }
 
         /**
          * Starts the process of creating a hint, based on the properties of the provided
          * protocol buffer representation of the credential. The protocol buffer must contain
          * valid data for a hint.
          */
-        public Builder(
-                @NonNull Protobufs.Hint proto) {
-            require(proto, notNullValue());
-            setIdentifier(proto.getId());
-            setAuthMethod(proto.getAuthMethod().getUri());
-            setDisplayName(proto.getDisplayName());
-            setDisplayPictureUri(proto.getDisplayPictureUri());
-            setGeneratedPassword(proto.getGeneratedPassword());
-            setIdToken(proto.getIdToken());
-            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        private Builder(@NonNull Protobufs.Hint proto) throws MalformedDataException {
+            validate(proto, notNullValue(), MalformedDataException.class);
+
+            try {
+                setIdentifier(proto.getId());
+                setAuthMethod(proto.getAuthMethod().getUri());
+                setDisplayName(proto.getDisplayName());
+                setDisplayPictureUri(proto.getDisplayPictureUri());
+                setGeneratedPassword(proto.getGeneratedPassword());
+                setIdToken(proto.getIdToken());
+                setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Specifies the identifier for the hint. Must not be null or empty.
          */
         public Builder setIdentifier(@NonNull String id) {
-            require(id, notNullOrEmptyString());
+            validate(id, notNullOrEmptyString(), IllegalArgumentException.class);
             mId = id;
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint, in string form. Must be a valid
          * authentication method URI.
          *
          * @see AuthenticationMethod
          */
         public Builder setAuthMethod(@NonNull String authMethod) {
-            require(authMethod, isValidAuthenticationMethod());
+            validate(authMethod, isValidAuthenticationMethod(), IllegalArgumentException.class);
             mAuthMethod = new AuthenticationMethod(authMethod);
             return this;
         }
 
         /**
          * Specifies the authentication method for the hint. Must not be null.
          */
         public Builder setAuthMethod(@NonNull AuthenticationMethod authMethod) {
-            require(authMethod, notNullValue());
+            validate(authMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the display name for the hint. Empty values are treated as null.
          */
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Empty values are
          * treated as null. Non-empty values must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable String displayPictureUri) {
             setDisplayPictureUri(nullifyEmptyString(displayPictureUri) != null
                             ? Uri.parse(displayPictureUri)
                             : null);
             return this;
         }
 
         /**
          * Specifies the display picture URI for the hint, in string form. Non-null values
          * must be valid http(s) URIs.
          */
         public Builder setDisplayPictureUri(@Nullable Uri displayPictureUri) {
-            require(displayPictureUri, nullOr(isWebUri()));
+            validate(displayPictureUri, nullOr(isWebUri()), IllegalArgumentException.class);
             mDisplayPictureUri = displayPictureUri;
             return this;
         }
 
         /**
          * Specifies the generated password for the hint. Empty values are treated as null.
          */
         public Builder setGeneratedPassword(@Nullable String generatedPassword) {
             mGeneratedPassword = nullifyEmptyString(generatedPassword);
             return this;
         }
 
         /**
          * Specifies the "proof of access" ID token for the hint. Empty values are treated as null.
          */
         public Builder setIdToken(@Nullable String idToken) {
             mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the hint.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 @Nullable Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the {@link Hint hint} instance with the specified properties.
          */
         public Hint build() {
             return new Hint(this);
         }
     }
 
     private static final class HintCreator implements Creator<Hint> {
 
         @Override
         public Hint createFromParcel(Parcel source) {
             int length = source.readInt();
             byte[] hintBytes = new byte[length];
             source.readByteArray(hintBytes);
             try {
                 return Hint.fromProtobufBytes(hintBytes);
-            } catch (IOException e) {
-                throw new IllegalArgumentException("Unable to parse hint from parcel");
+            } catch (MalformedDataException ex) {
+                throw new IllegalArgumentException("Unable to parse hint from parcel", ex);
             }
         }
 
         @Override
         public Hint[] newArray(int size) {
             return new Hint[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
index 8748813..86759a4 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
@@ -16,7 +16,10 @@ package org.openyolo.protocol;
 
-import static org.hamcrest.CoreMatchers.everyItem;
+import static java.util.Collections.EMPTY_SET;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.core.IsEqual.equalTo;
 import static org.openyolo.protocol.internal.CustomMatchers.isHttpsUriStr;
-import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -28,3 +31,2 @@ import com.google.protobuf.ByteString;
 import java.io.IOException;
-import java.nio.charset.Charset;
 import java.util.Collections;
@@ -34,2 +36,3 @@ import java.util.Map;
 import java.util.Set;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
 import org.openyolo.protocol.internal.AuthenticationMethodConverters;
@@ -42,375 +45,345 @@ import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
 public class HintRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRetrieveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRetrieveRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, TokenRequestInfo> mTokenProviders;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
     public static HintRetrieveRequest forEmailAndPasswordAccount() {
         return new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
-     * @throws IOException if the hint request could not be decoded.
+     * @throws MalformedDataException if the given hint protocol buffer was not valid.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtoBytes(byte[] hintRequestProtoBytes)
-            throws IOException {
-        if (hintRequestProtoBytes == null) {
-            throw new IOException("Unable to decode hint request from null array");
+            throws MalformedDataException {
+        validate(hintRequestProtoBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
         }
-        return new HintRetrieveRequest.Builder(
-                Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
-                .build();
+    }
+
+    /**
+     * Reads a hint request from its protocol buffer form.
+     * @throws MalformedDataException if the given hint protocol buffer was not valid.
+     *
+     * @see #toProtocolBuffer().
+     */
+    @NonNull
+    public static HintRetrieveRequest fromProtobuf(Protobufs.HintRetrieveRequest protobuf)
+            throws MalformedDataException {
+        validate(protobuf, notNullValue(), MalformedDataException.class);
+
+        return new HintRetrieveRequest.Builder(protobuf).build();
     }
 
     private HintRetrieveRequest(@NonNull Builder builder) {
         mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
         mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
         mPasswordSpec = builder.mPasswordSpec;
         mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The token providers supported by the requester, with the per-provider request info
      * message.
      */
     @NonNull
     public Map<String, TokenRequestInfo> getTokenProviders() {
         return mTokenProviders;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProperties,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
-    /**
-     * Retrieves the value of the named additional parameter, where the value is a UTF-8
-     * encoded string.
-     */
-    @Nullable
-    public String getAdditionalPropertyAsString(@NonNull String key) {
-        require(key, notNullValue());
-        if (mAdditionalProperties.containsKey(key)) {
-            return mAdditionalProperties.get(key).toString(Charset.forName("UTF-8"));
-        }
-        return null;
-    }
-
-    /**
-     * Retrieves the raw, byte-array value of the named additional parameter.
-     */
-    @Nullable
-    public byte[] getAdditionalProperty(@NonNull String key) {
-        require(key, notNullValue());
-        return mAdditionalProperties.get(key).toByteArray();
-    }
-
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllSupportedTokenProviders(
                         CollectionConverter.convertMapValues(
                                 mTokenProviders,
                                 TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(mAdditionalProperties)
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
         private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
+         * @throws MalformedDataException if the given hint protocol buffer was not valid.
          *
          * @see HintRetrieveRequest#toProtocolBuffer()
          */
-        public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
-            require(requestProto, notNullValue());
-            setAuthenticationMethods(CollectionConverter.toSet(
-                    requestProto.getAuthMethodsList(),
-                    AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
-            setTokenProviders(CollectionConverter.convertMapValues(
-                    requestProto.getSupportedTokenProvidersMap(),
-                    TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
-            setPasswordSpecification(
-                    new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
-            setAdditionalProperties(
-                    CollectionConverter.convertMapValues(
-                            requestProto.getAdditionalPropsMap(),
-                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        private Builder(@NonNull Protobufs.HintRetrieveRequest requestProto)
+                throws MalformedDataException {
+            validate(requestProto, notNullValue(), MalformedDataException.class);
+
+            try {
+                setAuthenticationMethods(CollectionConverter.toSet(
+                        requestProto.getAuthMethodsList(),
+                        AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
+                setTokenProviders(CollectionConverter.convertMapValues(
+                        requestProto.getSupportedTokenProvidersMap(),
+                        TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
+                setPasswordSpecification(
+                        PasswordSpecification.fromProtobuf(requestProto.getPasswordSpec()));
+                setAdditionalProperties(
+                        CollectionConverter.convertMapValues(
+                                requestProto.getAdditionalPropsMap(),
+                                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(
                 @NonNull AuthenticationMethod authMethod,
                 @NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
                 @NonNull AuthenticationMethod authMethod,
                 AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
-            require(authMethods, notNullValue());
-            require(!authMethods.contains(null), "every authentication methods must be non-null");
-            require(!authMethods.isEmpty(), "At least one authentication method must be specified");
+            validate(authMethods, notNullValue(), IllegalArgumentException.class);
+            validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
+            validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
-            require(authenticationMethod, notNullValue());
+            validate(authenticationMethod, notNullValue(), IllegalArgumentException.class);
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies the token providers supported by the requester, and any token provider
          * specific information required to acquire usable ID tokens. A null map is treated
          * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
          * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
          * request info message.
          */
         public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
             if (tokenProviders == null) {
                 mTokenProviders.clear();
                 return this;
             }
 
             for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
                 addTokenProvider(entry.getKey(), entry.getValue());
             }
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the default token request info
          * message specified.
          */
         public Builder addTokenProvider(@NonNull String tokenProviderUri) {
             addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
             return this;
         }
 
         /**
          * Adds a token provider supported by the requester, with the specified token request info
          * message for token retrieval. A null token request info message is treated as equivalent
          * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
          */
         public Builder addTokenProvider(
                 @NonNull String tokenProviderUri,
                 @Nullable TokenRequestInfo info) {
-            require(tokenProviderUri, isHttpsUriStr());
+            validate(tokenProviderUri, isHttpsUriStr(), IllegalArgumentException.class);
             if (info == null) {
                 info = TokenRequestInfo.DEFAULT;
             }
 
             mTokenProviders.put(tokenProviderUri, info);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
-        public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
-            require(additionalParams, notNullValue());
-            require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
-            require(additionalParams.values(), everyItem(notNullValue()));
-            mAdditionalProps = CollectionConverter.convertMapValues(
-                    additionalParams,
-                    ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
-            return this;
-        }
-
-        /**
-         * Adds an additional, non-standard parameter to the hint request with a string value, that
-         * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
-         * key must be non-empty.
-         */
-        @NonNull
-        public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
-            require(value, notNullValue());
-            addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
-            return this;
-        }
-
-        /**
-         * Adds an additional, non-standard parameter to the hint request, that will be encoded as
-         * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
-         */
-        @NonNull
-        public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
-            require(name, notNullOrEmptyString());
-            require(value, notNullValue());
-            mAdditionalProps.put(name, ByteString.copyFrom(value));
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
-            require(passwordSpec, notNullValue());
+            validate(passwordSpec, notNullValue(), IllegalArgumentException.class);
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRetrieveRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRetrieveRequest build() {
             return new HintRetrieveRequest(this);
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRetrieveRequest> {
         @Override
         public HintRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
-                return new HintRetrieveRequest.Builder(
-                        Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
-                        .build();
-            } catch (IOException ex) {
+                return HintRetrieveRequest.fromProtoBytes(protoBytes);
+            } catch (MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRetrieveRequest[] newArray(int size) {
             return new HintRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
index f5369ad..493ecdf 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -16,2 +16,5 @@ package org.openyolo.protocol;
 
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Validation.validate;
+
 import android.content.Intent;
@@ -30,243 +33,257 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
  * of the request, and the response may contain a hint.
  */
 public final class HintRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN = ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the hint request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST = ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the user selected a hint, that has been returned as part of this response.
      */
     public static final int CODE_HINT_SELECTED = ResultCode.HINT_SELECTED_VALUE;
 
     /**
      * Indicates that no hints are available that meet the requirements of the hint request.
      */
     public static final int CODE_NO_HINTS_AVAILABLE = ResultCode.NO_HINTS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user  canceled the selection of a hint in a manner that indicates they
      * wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that The user canceled the selection of a hint in a manner that indicates they do
      * not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED = ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built hint result for an unspecified outcome. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult UNKNOWN =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_UNKNOWN).build();
 
     /**
      * Pre-built hint result for a bad request. Carries no hint or additional properties.
      */
     public static final HintRetrieveResult BAD_REQUEST =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built hint result for when no hints are available. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult NO_HINTS_AVAILABLE =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_NO_HINTS_AVAILABLE).build();
 
     /**
      * Pre-built hint result for when the user requests manual authentication. Carries no hint
      * or additional properties.
      */
     public static final HintRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new HintRetrieveResult.Builder(
                     HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH)
                     .build();
 
     /**
      * Pre-built hint result for when the user canceled the selection of a hint in a manner that
      * indicates they do not wish to authenticate at this time. Carries no hint or additional
      * properties.
      */
     public static final HintRetrieveResult USER_CANCELED =
             new HintRetrieveResult.Builder(HintRetrieveResult.CODE_USER_CANCELED).build();
 
     /**
      * Creates a hint result from its protocol buffer equivalent.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
-    public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto) {
+    public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto)
+            throws MalformedDataException {
         return new HintRetrieveResult.Builder(proto).build();
     }
 
     /**
      * Creates a hint result from its protocol buffer equivalent, in byte array form.
-     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
      */
     public static HintRetrieveResult fromProtobufBytes(byte[] protoBytes)
-            throws IOException {
-        return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
+            throws MalformedDataException {
+        validate(protoBytes, notNullValue(), MalformedDataException.class);
+
+        try {
+            return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
+        } catch (IOException ex) {
+            throw new MalformedDataException(ex);
+        }
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Hint mHint;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
-    private HintRetrieveResult(
-            int resultCode,
-            @Nullable Hint hint,
-            @NonNull Map<String, ByteString> additionalProps) {
-        mResultCode = resultCode;
-        mHint = hint;
-        mAdditionalProps = additionalProps;
+    private HintRetrieveResult(Builder builder) {
+        mResultCode = builder.mResultCode;
+        mHint = builder.mHint;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * Creates a protocol buffer representation of the hint retrieve result, for transmission or
      * storage.
      */
     public Protobufs.HintRetrieveResult toProtobuf() {
         Protobufs.HintRetrieveResult.Builder builder =
                 Protobufs.HintRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mHint != null) {
             builder.setHint(mHint.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this hint retrieve result, that a provider should
      * return as its hint activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_HINT_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * The hint retrieve result code.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The hint returned as part of the hint result, if available.
      */
     @Nullable
     public Hint getHint() {
         return mHint;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * hint result, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link HintRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @Nullable
         private Hint mHint;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a hint retrieve result, based on the properties
          * contained in the provided protocol buffer.
          */
-        public Builder(@NonNull Protobufs.HintRetrieveResult proto) {
-            setResultCode(proto.getResultCodeValue());
-            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
-            setHintFromProto(proto.getHint());
+        private Builder(@NonNull Protobufs.HintRetrieveResult proto) throws MalformedDataException {
+            validate(proto, notNullValue(), MalformedDataException.class);
+
+            try {
+                setResultCode(proto.getResultCodeValue());
+                setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+                setHintFromProto(proto.getHint());
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Starts the process of describing a hint retrieve result, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the returned hint, if available.
          */
         public Builder setHint(@Nullable Hint hint) {
             mHint = hint;
             return this;
         }
 
-        private Builder setHintFromProto(@Nullable Protobufs.Hint hint) {
-            mHint = (hint != null) ? Hint.fromProtobuf(hint) : null;
+        private Builder setHintFromProto(@Nullable Protobufs.Hint hint)
+                throws MalformedDataException {
+            if (null == hint) {
+                mHint = null;
+            } else {
+                mHint = Hint.fromProtobuf(hint);
+            }
+
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. A null map is treated as an empty map. For a non-null map, all keys and values
          * must not be null, and the keys must not be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProps) {
             mAdditionalProps =
                     AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates the hint retrieve result, from the specified properties.
          */
         public HintRetrieveResult build() {
-            return new HintRetrieveResult(
-                    mResultCode,
-                    mHint,
-                    Collections.unmodifiableMap(mAdditionalProps));
+            return new HintRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/MalformedDataException.java b/protocol/java/org/openyolo/protocol/MalformedDataException.java
index aec9c14..0ec4fdc 100644
--- a/protocol/java/org/openyolo/protocol/MalformedDataException.java
+++ b/protocol/java/org/openyolo/protocol/MalformedDataException.java
@@ -17,19 +17,26 @@ package org.openyolo.protocol;
 /**
  * Indicates that an OpenYOLO message is missing or could not parsed.
  */
 public class MalformedDataException extends OpenYoloException {
 
     /**
      * Describes the exception with a human-readable string, for debugging.
      */
     public MalformedDataException(String message) {
         super(message);
     }
 
+    /**
+     * Specifies the root cause of the exception.
+     */
+    public MalformedDataException(Throwable cause) {
+        super(cause);
+    }
+
     /**
      * Specifies the root cause of the exception, and a higher-level description for debugging.
      */
     public MalformedDataException(String message, Throwable rootCause) {
         super(message, rootCause);
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/PasswordSpecification.java b/protocol/java/org/openyolo/protocol/PasswordSpecification.java
index 4e56973..e9fc386 100644
--- a/protocol/java/org/openyolo/protocol/PasswordSpecification.java
+++ b/protocol/java/org/openyolo/protocol/PasswordSpecification.java
@@ -19,2 +19,3 @@ import static org.openyolo.protocol.internal.InternalConstants.HASH_PRIME;
 import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -40,791 +41,807 @@ import java.util.TreeSet;
 /**
  * Specification of an acceptable set of passwords, expressed in terms of allowed and required
  * sets of characters and a size range. Only ASCII printable characters are supported.
  *
  * <p>
  * Example Specifications:
  *
  * <ul>
  *     <li>
  *     A 12-16 character password that must contain at least one digit and one upper-case letter:
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .ofLength(12, 16)
  *             .allow(ALL_PRINTABLE)
  *             .require(NUMERALS, 1)
  *             .require(UPPER_ALPHA, 1)
  *             .build();
  *     }
  *     </li>
  *     <li>
  *     A 6-digit pin number:
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .allow(NUMERALS)
  *             .ofLength(6,6)
  *             .build();
  *     }
  *     </li>
  *     <li>
  *     An 8-12 character password permitting only alphanumeric characters
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .ofLength(8,12)
  *             .allow(LOWER_ALPHA)
  *             .allow(UPPER_ALPHA)
  *             .allow(NUMERALS)
  *             .build();
  *     }
  *     </li>
  * </ul>
  * </p>
  */
 public final class PasswordSpecification implements Parcelable {
 
     /**
      * Parcelable {@link android.os.Parcelable.Creator Creator} for PasswordSpecification instances.
      */
     public static final Creator<PasswordSpecification> CREATOR = new PasswordSpecificationCreator();
 
     /**
      * The set of lower case ASCII characters (a-z).
      */
     public static final String LOWER_ALPHA = "abcdefghijklmnopqrstuvwxyz";
 
     /**
      * The set of lower case ASCII characters, omitting those which are difficult to distinguish
      * from other alphanumeric characters. The omitted characters are:
      * <ul>
      * <li>l (lima), often confused with 1 (one) and I (india, upper case)</li>
      * <li>u (uniform), often confused with v (victor)</li>
      * <li>v (victor), often confused with u (uniform)</li>
      * <li>w (whiskey), often confused with vv (victor victor)</li>
      * </ul>
      */
     public static final String LOWER_ALPHA_DISTINGUISHABLE = "abcdefghijkmnopqrstxyz";
 
     /**
      * The set of upper case ASCII characters (A-Z).
      */
     public static final String UPPER_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
     /**
      * The set of upper case ASCII characters, omitting those which can be difficult to distinguish
      * from other alphanumeric characters. The omitted characters are:
      * <ul>
      * <li>I (india), often confused with 1 (one) and l (lima, lower case)</li>
      * <li>O (oscar), often confused with 0 (zero)</li>
      * <li>U (uniform), often confused with v (victor)</li>
      * <li>V (victor), often confused with u (uniform)</li>
      * <li>W (whiskey), often confused with vv (victor victor)</li>
      * <li>Z (zulu), often confused with 2 (two)</li>
      * </ul>
      */
     public static final String UPPER_ALPHA_DISTINGUISHABLE = "ABCDEFGHJKLMNPQRSTXY";
 
     /**
      * The set of ASCII numerals (0-9).
      */
     public static final String NUMERALS = "1234567890";
 
     /**
      * The set of ASCII numerals, omitting those which can be difficult to distinguish from other
      * alphanumeric characters. The omitted characters are:
      * <ul>
      * <li>0 (zero), often confused with O (oscar, upper case)</li>
      * <li>1 (one), often confused with I (india, upper case) and l (lima, lower case)</li>
      * <li>2 (two), often confused with Z (zulu, upper case)</li>
      * </ul>
      */
     public static final String NUMERALS_DISTINGUISHABLE = "3456789";
 
     /**
      * The set of all alpha-numeric ASCII characters (a-z, A-Z, 0-9).
      */
     public static final String ALPHANUMERIC = LOWER_ALPHA + UPPER_ALPHA + NUMERALS;
 
     /**
      * The set of all printable ASCII symbols.
      */
     public static final String SYMBOLS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
 
     /**
      * The set of all printable ASCII characters.
      */
     public static final String ALL_PRINTABLE =
             LOWER_ALPHA + UPPER_ALPHA + NUMERALS + SYMBOLS;
 
     /**
      * The set of all alphanumeric characters (and space) which are easily
      * distinguished. Specifically, this excludes:
      * <ul>
      * <li>I (india, upper case), often confused with 1 (one) and l (lima, lower case)</li>
      * <li>l (lima, lower case), often confused with 1 (one) and I (india, upper case)</li>
      * <li>O (oscar, upper case), often confused with 0 (zero)</li>
      * <li>U (uniform, lower and upper case), often confused with v (victor)</li>
      * <li>V (victor, lower and upper case), often confused with u (uniform)</li>
      * <li>W (whiskey, lower and upper case), often confused with vv (victor victor)</li>
      * <li>Z (zulu), often confused with 2 (two)</li>
      * <li>0 (zero), often confused with O (oscar, upper case)</li>
      * <li>1 (one), often confused with I (india, upper case) and l (lima, lower case)</li>
      * <li>2 (two), often confused with Z (zulu, upper case)</li>
      * </ul>
      */
     public static final String ALPHANUMERIC_DISTINGUISHABLE =
             LOWER_ALPHA_DISTINGUISHABLE + UPPER_ALPHA_DISTINGUISHABLE + NUMERALS_DISTINGUISHABLE;
 
     /**
      * The minimum password length used by {@link #DEFAULT PasswordSpecification.DEFAULT}.
      */
     public static final int DEFAULT_MIN_PASSWORD_LENGTH = 12;
 
     /**
      * The maximum password length used by {@link #DEFAULT PasswordSpecification.DEFAULT}.
      */
     public static final int DEFAULT_MAX_PASSWORD_LENGTH = 16;
 
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({PASSWORD_CONFORMS,
             PASSWORD_LENGTH_MISMATCH,
             PASSWORD_REQUIRED_CHARACTER_MISSING,
             PASSWORD_DISALLOWED_CHARACTER})
     public @interface ConformanceMask {}
 
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({PASSWORD_LENGTH_MISMATCH,
             PASSWORD_REQUIRED_CHARACTER_MISSING,
             PASSWORD_DISALLOWED_CHARACTER})
     public @interface ConformanceError {}
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password conforms to the specification.
      */
     public static final int PASSWORD_CONFORMS = 0B0000;
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password is not within the required size bounds.
      */
     public static final int PASSWORD_LENGTH_MISMATCH = 0B0001;
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password is missing one or more required characters.
      */
     public static final int PASSWORD_REQUIRED_CHARACTER_MISSING = 0B0010;
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password contains a disallowed character.
      */
     public static final int PASSWORD_DISALLOWED_CHARACTER = 0B0100;
 
     /**
      * The default password specification used by the credentials API when no alternative is
      * provided. This specification should be compatible with the majority of password based
      * authentication systems and has sufficient entropy to be secure against offline attacks.
      * The specification permits passwords between 12 and 16 characters in length, composed of at
      * least one lower case letter, one upper case letter, and one numeral. All other characters
      * must be alphanumeric.
      *
      * <p>Characters which are difficult to distinguish are disallowed in this specification,
      * as it is tailored towards password generation rather than validation - see
      * {@link #DEFAULT_FOR_VALIDATION} for a password specification suited to validating user
      * entered passwords.
      */
     public static final PasswordSpecification DEFAULT = new PasswordSpecification.Builder()
             .ofLength(DEFAULT_MIN_PASSWORD_LENGTH, DEFAULT_MAX_PASSWORD_LENGTH)
             .allow(ALPHANUMERIC_DISTINGUISHABLE)
             .require(LOWER_ALPHA_DISTINGUISHABLE, 1)
             .require(UPPER_ALPHA_DISTINGUISHABLE, 1)
             .require(NUMERALS_DISTINGUISHABLE, 1)
             .build();
 
     /**
      * A default password specification, intended for use in validating user entered passwords.
      * This differs from {@link #DEFAULT} in that characters which are difficult to distinguish
      * are permitted.
      */
     public static final PasswordSpecification DEFAULT_FOR_VALIDATION =
             new PasswordSpecification.Builder()
                     .ofLength(DEFAULT_MIN_PASSWORD_LENGTH, DEFAULT_MAX_PASSWORD_LENGTH)
                     .allow(ALPHANUMERIC)
                     .require(LOWER_ALPHA, 1)
                     .require(UPPER_ALPHA, 1)
                     .require(NUMERALS, 1)
                     .build();
 
     private static final int ASCII_PRINTABLE_RANGE_LOWER = 32;
     private static final int ASCII_PRINTABLE_RANGE_UPPER = 126;
 
     /**
      * Utility method to check if the password is conformant to the specification defined.
      * @param result the result of the @link #checkConformance(String) checkConformance} method.
      * @return true if password is conforming to specs.
      */
     public static boolean checkResultForError(final int result, @ConformanceError final int mask) {
         return (result & mask) != 0;
     }
 
     /**
      * The set of allowed characters, represented as a string.
      */
     public final String allowedChars;
 
     /**
      * The required character sets for this specification.
      */
     public final SortedSet<RequiredCharSet> requiredCharSets;
 
     /**
      * The maximum acceptable size of a password.
      */
     public final int minimumSize;
 
     /**
      * The minimum acceptable size of a password.
      */
     public final int maximumSize;
 
     // the below fields are created on-demand, and are not serialized. They should not be
     // directly referenced, instead, use the associated getters to ensure they are correctly
     // instantiated.
     private Integer mHash;
     private Random mRandom;
     private int[] mRequiredSpecMapping;
     private int[] mRequiredCharCounts;
 
     private PasswordSpecification(
             String allowedChars,
             SortedSet<RequiredCharSet> requiredCharSets,
             int minimumSize,
             int maximumSize) {
         this.allowedChars = allowedChars;
         this.requiredCharSets = Collections.unmodifiableSortedSet(requiredCharSets);
         this.minimumSize = minimumSize;
         this.maximumSize = maximumSize;
     }
 
     /**
      * Determines whether the provided password conforms to the specification.
      *
      * @return a bit field which represents the status of the checks on this password.
      *     values are {@link #PASSWORD_CONFORMS} - 0 if the password conforms to the specification.
      *     Otherwise, an error code will be returned in the form of a bit field.
      *     (one comprised of the of the bits representing issues with this password
      *     {@link #PASSWORD_LENGTH_MISMATCH},
      *     {@link #PASSWORD_DISALLOWED_CHARACTER} or
      *     {@link #PASSWORD_REQUIRED_CHARACTER_MISSING}).
      *
      *     @see <a href="https://en.wikipedia.org/wiki/Bit_field">Bit Field</a> -
      *     A bit field is a data structure used in computer programming, to store information in
      *     the bits of a byte.
      */
     @ConformanceMask
     public int checkConformance(String password) {
         int result = PASSWORD_CONFORMS;
         if (TextUtils.isEmpty(password)) {
             result |= PASSWORD_LENGTH_MISMATCH;
         }
 
         if (isOutsideRange(password.length(), minimumSize, maximumSize)) {
             result |= PASSWORD_LENGTH_MISMATCH;
         }
 
         // in order to check the required and allowed characters, we attempt to match
         // each character against a required character set. If the requisite number of
         // characters have been matched against that required set, then they are checked
         // to see if they are allowed beyond this count (which allows for password
         // specifications with exact required counts, by having a disjoint set of
         // required characters from allowed characters).
         int[] requiredSpecMapping = getRequiredSpecMapping();
         int[] requiredSpecRemainingCounts = extractRequiredCharCounts();
 
         for (char c : password.toCharArray()) {
             if (!containsCharacter(allowedChars, c)) {
                 result |= PASSWORD_DISALLOWED_CHARACTER;
             }
 
             int requiredSpecIndex = requiredSpecMapping[getCharMappingIndex(c)];
             if (requiredSpecIndex >= 0) {
                 requiredSpecRemainingCounts[requiredSpecIndex]--;
             }
         }
 
         for (int remaining : requiredSpecRemainingCounts) {
             if (remaining > 0) {
                 result |= PASSWORD_REQUIRED_CHARACTER_MISSING;
                 break;
             }
         }
 
         return result;
     }
 
     /**
      * Generates a random password in conformance with the specification.
      */
     @NonNull
     public String generate() {
         int size = minimumSize + getRandom().nextInt(maximumSize - minimumSize + 1);
         ArrayList<Character> chars = new ArrayList<>(size);
 
         // select all the required characters
         for (RequiredCharSet set : requiredCharSets) {
             selectCharacters(set.chars, set.count, chars);
         }
 
         // select all remaining characters from the allowed characters set
         int remaining = size - chars.size();
         selectCharacters(allowedChars, remaining, chars);
 
         // randomly shuffle the characters, so the required characters do not occur in a
         // predictable position
         Collections.shuffle(chars);
         return charCollectionToString(chars);
     }
 
     /**
      * Translates the specification into a protocol buffer, for transmission or storage.
      */
     @NonNull
     public Protobufs.PasswordSpecification toProtocolBuffer() {
         return Protobufs.PasswordSpecification.newBuilder()
                 .setMinSize(minimumSize)
                 .setMaxSize(maximumSize)
                 .setAllowed(allowedChars)
                 .addAllRequiredSets(convertRequiredCharSetsToProto())
                 .build();
     }
 
     @Override
     public void writeToParcel(Parcel out, int flags) {
         byte[] encoded = toProtocolBuffer().toByteArray();
         out.writeInt(encoded.length);
         out.writeByteArray(encoded);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (obj == null || !(obj instanceof PasswordSpecification)) {
             return false;
         }
 
         PasswordSpecification other = (PasswordSpecification)obj;
 
         if (this.minimumSize != other.minimumSize
                 || this.maximumSize != other.maximumSize
                 || !this.allowedChars.equals(other.allowedChars)) {
             return false;
         }
 
         if (this.requiredCharSets.size() != other.requiredCharSets.size()) {
             return false;
         }
 
         Iterator<RequiredCharSet> thisRequiredSetIter = this.requiredCharSets.iterator();
         Iterator<RequiredCharSet> otherRequiredSetIter = other.requiredCharSets.iterator();
 
         while (thisRequiredSetIter.hasNext()) {
             if (!thisRequiredSetIter.next().equals(otherRequiredSetIter.next())) {
                 return false;
             }
         }
 
         return true;
     }
 
     @Override
     public int hashCode() {
         if (mHash != null) {
             return mHash;
         }
 
         int hash = minimumSize;
         hash = hash * HASH_PRIME + maximumSize;
         hash = hash * HASH_PRIME + allowedChars.hashCode();
 
         for (RequiredCharSet set : requiredCharSets) {
             hash = hash * HASH_PRIME + set.chars.hashCode();
             hash = hash * HASH_PRIME + set.count;
         }
 
         mHash = hash;
         return mHash;
     }
 
     private List<Protobufs.RequiredCharSet> convertRequiredCharSetsToProto() {
         List<Protobufs.RequiredCharSet> convertedRequiredCharSets = new ArrayList<>();
 
         for (RequiredCharSet set : requiredCharSets) {
             convertedRequiredCharSets.add(
                     Protobufs.RequiredCharSet.newBuilder()
                             .setChars(set.chars)
                             .setCount(set.count)
                             .build());
         }
 
         return convertedRequiredCharSets;
     }
 
     /**
      * Extracts a mapping from an adjusted character index (where the lowest printable ascii
      * character is given index 0) to the required character spec that it corresponds to,
      * or -1 if the character is not part of any required set.
      */
     private int[] getRequiredSpecMapping() {
         if (mRequiredSpecMapping != null) {
             return mRequiredSpecMapping;
         }
 
         int[] requiredSpecMapping =
                 new int[ASCII_PRINTABLE_RANGE_UPPER - ASCII_PRINTABLE_RANGE_LOWER + 1];
         Arrays.fill(requiredSpecMapping, -1);
 
         int specIndex = 0;
         for (RequiredCharSet set : requiredCharSets) {
             for (char c : set.chars.toCharArray()) {
                 requiredSpecMapping[getCharMappingIndex(c)] = specIndex;
             }
             specIndex++;
         }
 
         mRequiredSpecMapping = requiredSpecMapping;
         return mRequiredSpecMapping;
     }
 
     /**
      * Determines the provided character's adjusted index in the required character spec mapping,
      * where the lowest printable ascii character is given index 0.
      */
     private static int getCharMappingIndex(char ch) {
         return ch - ASCII_PRINTABLE_RANGE_LOWER;
     }
 
     private void selectCharacters(String chars, int count, ArrayList<Character> result) {
         Random random = getRandom();
         for (int i = 0; i < count; i++) {
             result.add(chars.charAt(random.nextInt(chars.length())));
         }
     }
 
     private boolean containsCharacter(String chars, char ch) {
         int pos = Arrays.binarySearch(chars.toCharArray(), ch);
         return (pos >= 0 && pos < chars.length() && chars.charAt(pos) == ch);
     }
 
     private int[] extractRequiredCharCounts() {
         if (mRequiredCharCounts == null) {
             mRequiredCharCounts = new int[requiredCharSets.size()];
             int index = 0;
             for (RequiredCharSet set : requiredCharSets) {
                 mRequiredCharCounts[index] = set.count;
                 index++;
             }
         }
 
         int[] requiredCharCounts = new int[mRequiredCharCounts.length];
         System.arraycopy(
                 mRequiredCharCounts,
                 0, // source index
                 requiredCharCounts,
                 0, // destination index
                 mRequiredCharCounts.length);
         return requiredCharCounts;
     }
 
     private Random getRandom() {
         if (mRandom != null) {
             return mRandom;
         }
 
         mRandom = new SecureRandom();
         return mRandom;
     }
 
     private static String charCollectionToString(Collection<Character> chars) {
         char[] charArray = new char[chars.size()];
         int pos = 0;
         for (char c : chars) {
             charArray[pos++] = c;
         }
 
         return new String(charArray);
     }
 
     private static boolean isOutsideRange(int val, int lowerBound, int upperBound) {
         return val < lowerBound || val > upperBound;
     }
 
+    /**
+     * Creates a {@link PasswordSpecification} instance from the given protocol buffer
+     * representation.
+     * @throws MalformedDataException if the given protocol buffer is not valid.
+     */
+    public static PasswordSpecification fromProtobuf(
+            @NonNull Protobufs.PasswordSpecification protobuf) throws MalformedDataException {
+        validate(protobuf, notNullValue(), MalformedDataException.class);
+
+        return new Builder(protobuf).build();
+    }
+
     /**
      * Produces {@link PasswordSpecification} instances. At least one call to
      * {@link #allow(String)} or {@link #require(String,int)} must be made to specify the set of
      * characters that the password can contain. The password size range will default to
      * {@link #DEFAULT_MIN_PASSWORD_LENGTH} to {@link #DEFAULT_MAX_PASSWORD_LENGTH},
      * which may be overridden.
      */
     public static class Builder {
 
         private final TreeSet<Character> mAllowedCharSet = new TreeSet<>();
         private final TreeSet<RequiredCharSet> mRequiredCharSets = new TreeSet<>();
         private int mMinimumSize = -1;
         private int mMaximumSize = -1;
 
         /**
          * Recreates a password specification from its protocol buffer form.
          */
-        public Builder(Protobufs.PasswordSpecification proto) {
-            this.ofLength(proto.getMinSize(), proto.getMaxSize());
-            this.allow(proto.getAllowed());
-            for (Protobufs.RequiredCharSet set : proto.getRequiredSetsList()) {
-                this.require(set.getChars(), set.getCount());
+        private Builder(Protobufs.PasswordSpecification proto) throws MalformedDataException {
+            try {
+                this.ofLength(proto.getMinSize(), proto.getMaxSize());
+                this.allow(proto.getAllowed());
+                for (Protobufs.RequiredCharSet set : proto.getRequiredSetsList()) {
+                    this.require(set.getChars(), set.getCount());
+                }
+            } catch (InvalidSpecificationError er) {
+                throw new MalformedDataException(er);
             }
         }
 
         /**
          * Starts the process of defining a password specification.
          */
         public Builder() {}
 
         /**
          * Declares that the provided set of characters may occur in a password,
          * zero or more times.
          * @param allowedChars A set of characters which may occur in a password. Duplicate
          *     characters in the string, or provided over multiple calls to allow,
          *     will be ignored.
          * @throws InvalidSpecificationError if the string is null or empty, or contains
          *     characters which are not in the ascii printable range.
          */
         public Builder allow(@NonNull String allowedChars) {
             mAllowedCharSet.addAll(checkAndSortChars(allowedChars, "allowedChars"));
             return this;
         }
 
         /**
          * Declares that at least as many characters as specified must exist in the password,
          * drawn from the provided set. The character set must not overlap with any
          * other required character set, and must be a subset of the allowed character set.
          *
          * @param requiredChars A set of characters from which the required count will be selected.
          *     Duplicate characters will be ignored.
          * @param count The number of characters which will be selected from the required character
          *     set. Must be at least 1.
          * @throws InvalidSpecificationError if the string is null or empty, contains
          *     characters which are not in the ascii printable range, or exist within another
          *     required set of characters.
          */
         public Builder require(@NonNull String requiredChars, int count) {
             if (count < 1) {
                 throw new InvalidSpecificationError("count must be at least 1");
             }
 
             TreeSet<Character> requiredCharSet = checkAndSortChars(requiredChars, "requiredChars");
             mAllowedCharSet.addAll(requiredCharSet);
             mRequiredCharSets.add(
                     new RequiredCharSet(
                             charCollectionToString(requiredCharSet),
                             count));
             return this;
         }
 
         /**
          * Declares that the password must be within a certain size range.
          * @param minimumSize
          *     The minimum size of the password. Must be at least 1.
          * @param  maximumSize
          *     The maximum size of the password. Must be at least as large as {@code minimumSize}.
          */
         public Builder ofLength(int minimumSize, int maximumSize) {
             if (minimumSize < 1) {
                 throw new InvalidSpecificationError("minimumSize must be at least 1");
             }
 
             if (minimumSize > maximumSize) {
                 throw new InvalidSpecificationError(
                         "maximumSize must be greater than or equal to minimumSize");
             }
 
             mMinimumSize = minimumSize;
             mMaximumSize = maximumSize;
 
             return this;
         }
 
         /**
          * Produces a {@link PasswordSpecification} instance, if the configuration specified on the
          * builder is valid.
          *
          * @throws InvalidSpecificationError if the specification is invalid.
          */
         public PasswordSpecification build() {
             if (mAllowedCharSet.isEmpty()) {
                 throw new InvalidSpecificationError("no allowed characters specified");
             }
 
             if (mMinimumSize < 0) {
                 // the length of the password was never set
                 throw new InvalidSpecificationError(
                         "minimum and maximum size of password not specified");
             }
 
             checkRequiredCharsTotalCount();
             checkRequiredCharsDisjoint();
 
             return new PasswordSpecification(
                     charCollectionToString(mAllowedCharSet),
                     mRequiredCharSets,
                     mMinimumSize,
                     mMaximumSize);
         }
 
         private TreeSet<Character> checkAndSortChars(String chars, String paramName) {
             if (TextUtils.isEmpty(chars)) {
                 throw new InvalidSpecificationError(paramName + " cannot be null or empty");
             }
 
             TreeSet<Character> filteredChars = new TreeSet<>();
 
             for (char c : chars.toCharArray()) {
                 if (isOutsideRange(c, ASCII_PRINTABLE_RANGE_LOWER, ASCII_PRINTABLE_RANGE_UPPER)) {
                     throw new InvalidSpecificationError(
                             paramName + " must only contain ASCII printable characters");
                 }
                 filteredChars.add(c);
             }
 
             return filteredChars;
         }
 
         private void checkRequiredCharsTotalCount() {
             int count = 0;
             for (RequiredCharSet set : mRequiredCharSets) {
                 count += set.count;
             }
 
             if (count > mMaximumSize) {
                 throw new InvalidSpecificationError(
                         "required character count cannot be greater than the max password size");
             }
         }
 
         private void checkRequiredCharsDisjoint() {
             boolean[] charsUsed =
                     new boolean[ASCII_PRINTABLE_RANGE_UPPER - ASCII_PRINTABLE_RANGE_LOWER + 1];
 
             for (RequiredCharSet set : mRequiredCharSets) {
                 for (char c : set.chars.toCharArray()) {
                     if (charsUsed[c - ASCII_PRINTABLE_RANGE_LOWER]) {
                         throw new InvalidSpecificationError("character " + c
                                 + " occurs in more than one required character set");
                     }
                     charsUsed[c - ASCII_PRINTABLE_RANGE_LOWER] = true;
                 }
             }
         }
     }
 
     /**
      * The error type that is thrown in an attempt is made to construct an invalid specification.
      */
     public static class InvalidSpecificationError extends Error {
         /**
          * Creates an InvalidSpecificationError with the provided reason.
          */
         public InvalidSpecificationError(String reason) {
             super(reason);
         }
     }
 
     /**
      * Represents a required character set, where a password must contain at least as many
      * characters as specified, drawn from the specified set.
      */
     private static final class RequiredCharSet implements Comparable<RequiredCharSet> {
 
         /**
          * The set of characters from which the required characters must be drawn.
          */
         public final String chars;
 
         /**
          * The minimum number of characters that must occur in the password, drawn from
          * {@link #chars}.
          */
         public final int count;
 
         private RequiredCharSet(String chars, int count) {
             this.chars = chars;
             this.count = count;
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (obj == null || !(obj instanceof RequiredCharSet)) {
                 return false;
             }
 
             RequiredCharSet other = (RequiredCharSet) obj;
             return this.chars.equals(other.chars) && this.count == other.count;
         }
 
         @Override
         public int hashCode() {
             return count * HASH_PRIME + chars.hashCode();
         }
 
         @Override
         public int compareTo(@NonNull RequiredCharSet other) {
             require(other, notNullValue());
 
             // sort by count then chars
             if (this.count < other.count) {
                 return -1;
             }
 
             if (this.count > other.count) {
                 return 1;
             }
 
             return chars.compareTo(other.chars);
         }
     }
 
     private static final class PasswordSpecificationCreator
             implements Creator<PasswordSpecification> {
 
         @Override
         public PasswordSpecification createFromParcel(Parcel parcel) {
             int encodedSize = parcel.readInt();
             byte[] encoded = new byte[encodedSize];
             parcel.readByteArray(encoded);
 
             Protobufs.PasswordSpecification proto;
             try {
                 proto = Protobufs.PasswordSpecification.parseFrom(encoded);
-            } catch (IOException ex) {
+                return PasswordSpecification.fromProtobuf(proto);
+            } catch (IOException | MalformedDataException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
 
-            return new PasswordSpecification.Builder(proto).build();
         }
 
         @Override
         public PasswordSpecification[] newArray(int size) {
             return new PasswordSpecification[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/TokenRequestInfo.java b/protocol/java/org/openyolo/protocol/TokenRequestInfo.java
index 3c87071..f566691 100644
--- a/protocol/java/org/openyolo/protocol/TokenRequestInfo.java
+++ b/protocol/java/org/openyolo/protocol/TokenRequestInfo.java
@@ -16,2 +16,3 @@ package org.openyolo.protocol;
 
+import static org.hamcrest.core.IsNull.notNullValue;
 import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAdditionalProperties;
@@ -19,2 +20,3 @@ import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAd
 import static org.openyolo.protocol.internal.StringUtil.nullifyEmptyString;
+import static org.valid4j.Validation.validate;
 
@@ -23,3 +25,3 @@ import android.support.annotation.Nullable;
 import com.google.protobuf.ByteString;
-import com.google.protobuf.InvalidProtocolBufferException;
+import java.io.IOException;
 import java.util.Collections;
@@ -29,172 +31,175 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Optional parameters for an token provider, used for requesting an ID token.
  */
 public final class TokenRequestInfo {
 
     /**
      * A default token request info message, containing no defined properties.
      */
     public static final TokenRequestInfo DEFAULT =
             new TokenRequestInfo.Builder().build();
 
     /**
      * Creates a {@link TokenRequestInfo} from its protocol buffer equivalent.
      * @throws MalformedDataException if the protocol buffer could not be parsed or validated.
      */
-    public static TokenRequestInfo fromProtobuf(
-            @NonNull Protobufs.TokenRequestInfo proto)
+    public static TokenRequestInfo fromProtobuf(@NonNull Protobufs.TokenRequestInfo proto)
             throws MalformedDataException {
-        try {
-            return new TokenRequestInfo.Builder(proto).build();
-        } catch (RequireViolation ex) {
-            throw new MalformedDataException("Token request info contains invalid data", ex);
-        }
+        validate(proto, notNullValue(), IllegalArgumentException.class);
+
+        return new TokenRequestInfo.Builder(proto).build();
     }
 
     /**
      * Creates a {@link TokenRequestInfo} from its protocol buffer byte array equivalent.
      * @throws MalformedDataException if the protocol buffer could not be parsed or validated.
      */
     public static TokenRequestInfo fromProtobufBytes(@NonNull byte[] protoBytes)
             throws MalformedDataException {
+        validate(protoBytes, notNullValue(), IllegalArgumentException.class);
+
         try {
             return fromProtobuf(Protobufs.TokenRequestInfo.parseFrom(protoBytes));
-        } catch (InvalidProtocolBufferException ex) {
+        } catch (IOException ex) {
             throw new MalformedDataException("Unable to parse token request info proto", ex);
         }
     }
 
     @Nullable
     private final String mClientId;
 
     @Nullable
     private final String mNonce;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private TokenRequestInfo(Builder builder) {
         mClientId = builder.mClientId;
         mNonce = builder.mNonce;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * An optional client ID, used to identify the current application for the purposes of
      * ID token retrieval and generation. Where accepted by the token provider, this should
      * be used as the audience ("aud" claim) in returned ID token.
      */
     @Nullable
     public String getClientId() {
         return mClientId;
     }
 
     /**
      * An optional nonce, used to protect against ID token replay attacks. Where accepted
      * by the token provider, this should appear as the nonce claim in the ID token.
      */
     @Nullable
     public String getNonce() {
         return mNonce;
     }
 
     /**
      * A map of additional, non-standard properties for transmission to the token provider.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Converts the request into its protocol buffer equivalent, for storage or transmission.
      */
     public Protobufs.TokenRequestInfo toProtobuf() {
         Protobufs.TokenRequestInfo.Builder builder = Protobufs.TokenRequestInfo.newBuilder();
 
         if (mClientId != null) {
             builder.setClientId(mClientId);
         }
 
         if (mNonce != null) {
             builder.setNonce(mNonce);
         }
 
         builder.putAllAdditionalProps(mAdditionalProps);
         return builder.build();
     }
 
     /**
      * Creates instances of {@link TokenRequestInfo}.
      */
     public static final class Builder {
 
         private String mClientId;
         private String mNonce;
         private Map<String, ByteString> mAdditionalProps;
 
         /**
          * Starts the process of describing a token request information message, to pass to
          * a token provider.
          */
         public Builder() {
             mAdditionalProps = new HashMap<>();
         }
 
         /**
          * Starts the process of describing a token request information message, using
          * the data stored within the provided protocol buffer equivalent.
+         * @throws MalformedDataException if the given protocol buffer is not valid.
          */
-        public Builder(Protobufs.TokenRequestInfo proto) {
-            mClientId = nullifyEmptyString(proto.getClientId());
-            mNonce = nullifyEmptyString(proto.getNonce());
-            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        private Builder(Protobufs.TokenRequestInfo proto) throws MalformedDataException {
+            try {
+                mClientId = nullifyEmptyString(proto.getClientId());
+                mNonce = nullifyEmptyString(proto.getNonce());
+                setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+            } catch (IllegalArgumentException ex) {
+                throw new MalformedDataException(ex);
+            }
         }
 
         /**
          * Specifies the client ID to pass to the token provider. Empty values are treated
          * as equivalent to null.
          */
         public Builder setClientId(@Nullable String clientId) {
             mClientId = nullifyEmptyString(clientId);
             return this;
         }
 
         /**
          * Specifies the nonce value to pass to the token provider. Empty values are treated
          * as equivalent to null.
          */
         public Builder setNonce(@Nullable String nonce) {
             mNonce = nullifyEmptyString(nonce);
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to pass to the token
          * provider. A null map is treated as equivalent to an empty map. The map must
          * not contain null keys or null values, and must not contain an empty key.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             mAdditionalProps = validateAdditionalProperties(additionalProps);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 @NonNull Map<String, ByteString> additionalProps) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProps);
             return this;
         }
 
         /**
          * Creates a {@link TokenRequestInfo} instance using the properties described
          * to the builder.
          */
         public TokenRequestInfo build() {
             return new TokenRequestInfo(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java b/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
index df73384..8353fd1 100644
--- a/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
+++ b/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
@@ -19,3 +19,3 @@ import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -27,43 +27,55 @@ import java.util.Map;
 /**
  * Utility methods for the conversion and manipulation of additional property maps.
  */
 public final class AdditionalPropertiesUtil {
 
     /**
      * Ensures that the provided map contains no null or empty keys, and no null values.
      * Treats a null map as an empty map.
      */
     public static Map<String, ByteString> validateAdditionalProperties(
             @Nullable Map<String, byte[]> additionalProps) {
         if (additionalProps == null) {
             return new HashMap<>();
         }
 
-        require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
-        require(additionalProps.values(), everyItem(notNullValue()));
+        validate(
+                additionalProps.keySet(),
+                everyItem(notNullOrEmptyString()),
+                IllegalArgumentException.class);
+        validate(
+                additionalProps.values(),
+                everyItem(notNullValue()),
+                IllegalArgumentException.class);
 
         return CollectionConverter.convertMapValues(
                 additionalProps,
                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
     }
 
     /**
      * Ensures that the provided protocol buffer sourced map contains no null or empty keys, and
      * no null values. Treats a null map as an empty map.
      */
     public static Map<String, ByteString> validateAdditionalPropertiesFromProto(
             @Nullable Map<String, ByteString> additionalProps) {
         if (additionalProps == null) {
             return new HashMap<>();
         }
 
-        require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
-        require(additionalProps.values(), everyItem(notNullValue()));
+        validate(
+                additionalProps.keySet(),
+                everyItem(notNullOrEmptyString()),
+                IllegalArgumentException.class);
+        validate(
+                additionalProps.values(),
+                everyItem(notNullValue()),
+                IllegalArgumentException.class);
 
         return additionalProps;
     }
 
     private AdditionalPropertiesUtil() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java b/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
deleted file mode 100644
index 69866f6..0000000
--- a/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.protocol.internal;
-
-import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.Protobufs;
-
-/**
- * Implementations of {@link ValueConverter} related to {@link AuthenticationDomain}.
- */
-public final class AuthenticationDomainConverters {
-
-    /**
-     * Creates {@link AuthenticationDomain} instances from strings.
-     */
-    public static final ValueConverter<String, AuthenticationDomain> STRING_TO_DOMAIN =
-            new StringToAuthenticationDomainConverter();
-
-    /**
-     * Extracts the string representation from {@link AuthenticationDomain} instances.
-     */
-    public static final ValueConverter<AuthenticationDomain, String> DOMAIN_TO_STRING =
-            new AuthenticationDomainToStringConverter();
-
-    /**
-     * Creates {@link AuthenticationDomain} instances from their protocol buffer form.
-     */
-    public static final ValueConverter<AuthenticationDomain, Protobufs.AuthenticationDomain>
-            OBJECT_TO_PROTOBUF = new ObjectToProtobufConverter();
-
-    /**
-     * Creates protocol buffers from {@link AuthenticationDomain} instances.
-     */
-    public static final ValueConverter<Protobufs.AuthenticationDomain, AuthenticationDomain>
-            PROTOBUF_TO_OBJECT = new ProtobufToObjectConverter();
-
-    private AuthenticationDomainConverters() {
-        throw new IllegalStateException("not intended to be constructed");
-    }
-
-    private static final class StringToAuthenticationDomainConverter
-            implements ValueConverter<String, AuthenticationDomain> {
-        @Override
-        public AuthenticationDomain convert(String value) {
-            return new AuthenticationDomain(value);
-        }
-    }
-
-    private static final class AuthenticationDomainToStringConverter
-            implements ValueConverter<AuthenticationDomain, String> {
-
-        @Override
-        public String convert(AuthenticationDomain value) {
-            return value.toString();
-        }
-    }
-
-    private static final class ObjectToProtobufConverter
-            implements ValueConverter<AuthenticationDomain, Protobufs.AuthenticationDomain> {
-
-
-        @Override
-        public Protobufs.AuthenticationDomain convert(AuthenticationDomain value) {
-            return value.toProtobuf();
-        }
-    }
-
-    private static final class ProtobufToObjectConverter
-            implements ValueConverter<Protobufs.AuthenticationDomain, AuthenticationDomain> {
-
-        @Override
-        public AuthenticationDomain convert(Protobufs.AuthenticationDomain value) {
-            return AuthenticationDomain.fromProtobuf(value);
-        }
-    }
-}
diff --git a/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java b/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java
index a86ab38..668f05a 100644
--- a/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java
+++ b/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java
@@ -20,35 +20,35 @@ import org.openyolo.protocol.Protobufs;
 /**
  * Implementations of {@link ValueConverter} related to authentication methods.
  */
 public final class AuthenticationMethodConverters {
 
     /**
      * Creates the protocol buffer equivalent of an {@link AuthenticationMethod}.
      */
     public static final ValueConverter<AuthenticationMethod, Protobufs.AuthenticationMethod>
             OBJECT_TO_PROTOBUF = new ObjectToProtobufConverter();
 
     /**
      * Creates an {@link AuthenticationMethod} from its protocol buffer equivalent.
      */
     public static final ValueConverter<Protobufs.AuthenticationMethod, AuthenticationMethod>
             PROTOBUF_TO_OBJECT = new ProtobufToObjectConverter();
 
     private static final class ObjectToProtobufConverter
-            implements ValueConverter<AuthenticationMethod, Protobufs.AuthenticationMethod> {
+            implements ValueConverter<AuthenticationMethod,Protobufs.AuthenticationMethod> {
 
         @Override
         public Protobufs.AuthenticationMethod convert(AuthenticationMethod value) {
             return value.toProtobuf();
         }
     }
 
     private static final class ProtobufToObjectConverter
             implements ValueConverter<Protobufs.AuthenticationMethod, AuthenticationMethod> {
 
         @Override
         public AuthenticationMethod convert(Protobufs.AuthenticationMethod value) {
             return new AuthenticationMethod(value.getUri());
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/CredentialConverter.java b/protocol/java/org/openyolo/protocol/internal/CredentialConverter.java
deleted file mode 100644
index 791fdb0..0000000
--- a/protocol/java/org/openyolo/protocol/internal/CredentialConverter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.protocol.internal;
-
-import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.Protobufs;
-
-/**
- * Converts credential instances to and from their protocol buffer equivalent.
- */
-public final class CredentialConverter {
-
-    /**
-     * Converts credential instances to their protocol buffer equivalent.
-     */
-    public static final ValueConverter<Credential, Protobufs.Credential> CREDENTIAL_TO_PROTO =
-            new CredentialToProtoConverter();
-
-    /**
-     * Converts credential instances from their protocol buffer equivalent.
-     */
-    public static final ValueConverter<Protobufs.Credential, Credential> PROTO_TO_CREDENTIAL =
-            new ProtoToCredentialConverter();
-
-    private static final class CredentialToProtoConverter
-            implements ValueConverter<Credential, Protobufs.Credential> {
-        @Override
-        public Protobufs.Credential convert(Credential value) {
-            return value.toProtobuf();
-        }
-    }
-
-    private static final class ProtoToCredentialConverter
-            implements ValueConverter<Protobufs.Credential, Credential> {
-        @Override
-        public Credential convert(Protobufs.Credential value) {
-            return Credential.fromProtobuf(value);
-        }
-    }
-}
diff --git a/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java b/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java
index aeb2368..a819b0e 100644
--- a/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java
+++ b/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java
@@ -16,2 +16,3 @@ package org.openyolo.protocol.internal;
 
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.Protobufs;
@@ -20,38 +21,42 @@ import org.openyolo.protocol.TokenRequestInfo;
 /**
  * ValueConverters for {@link TokenRequestInfo}.
  */
 public final class TokenRequestInfoConverters {
 
     /**
      * Converts token request info protocol buffers into their validated, public API form.
      */
     public static final ValueConverter<Protobufs.TokenRequestInfo, TokenRequestInfo>
             PROTOBUF_TO_OBJECT = new ProtobufToObjectConverter();
 
     /**
      * Converts token request info values into their protocol buffer equivalent.
      */
     public static final ValueConverter<TokenRequestInfo, Protobufs.TokenRequestInfo>
             OBJECT_TO_PROTOBUF = new ObjectToProtobufConverter();
 
     private TokenRequestInfoConverters() {
         throw new IllegalStateException("not intended to be constructed");
     }
 
     private static final class ProtobufToObjectConverter
             implements ValueConverter<Protobufs.TokenRequestInfo, TokenRequestInfo> {
         @Override
         public TokenRequestInfo convert(Protobufs.TokenRequestInfo proto) {
-            return new TokenRequestInfo.Builder(proto).build();
+            try {
+                return TokenRequestInfo.fromProtobuf(proto);
+            } catch (MalformedDataException ex) {
+                throw new IllegalArgumentException(ex);
+            }
         }
     }
 
     private static final class ObjectToProtobufConverter
             implements ValueConverter<TokenRequestInfo, Protobufs.TokenRequestInfo> {
         @Override
         public Protobufs.TokenRequestInfo convert(TokenRequestInfo value) {
             return value.toProtobuf();
         }
     }
 
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
index 057b991..06d5da4 100644
--- a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
+++ b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
@@ -22,2 +22,3 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.openyolo.protocol.TestConstants.INVALID_PROTO_BYTES;
 
@@ -28,5 +29,2 @@ import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.Signature;
-import android.net.Uri;
-import java.util.ArrayList;
-import java.util.List;
 import org.junit.Before;
@@ -38,181 +36,206 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
-import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.internal.AuthenticationDomainConverters;
-import org.openyolo.protocol.internal.CollectionConverter;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Unit tests for {@link AuthenticationDomain}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AuthenticationDomainTest {
 
     private static final String WEB_AUTH_DOMAIN_STR = "https://www.example.com";
 
     private static final String VALID_PACKAGE_NAME = "com.example.app";
 
     private static byte[] VALID_SIGNATURE_BYTES = new byte[]
             { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
     private static final String VALID_FINGERPRINT =
             "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                     + "7V4Lo8BdCxaA307H0HYkAw==";
 
     private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
             "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
 
     private static final PackageInfo VALID_PACKAGE_INFO = makeValidPackageInfo();
 
     private static PackageInfo makeValidPackageInfo() {
         PackageInfo packageInfo = new PackageInfo();
         packageInfo.signatures = new Signature[2];
         packageInfo.signatures[0] = new Signature(VALID_SIGNATURE_BYTES);
         packageInfo.signatures[1] = new Signature(new byte[16]);
 
         return packageInfo;
     }
 
+    private static final class ValidAuthDomain {
+        private static final String VALID_PACKAGE_NAME = "com.example.app";
+        private static final String VALID_FINGERPRINT =
+                "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
+                        + "7V4Lo8BdCxaA307H0HYkAw==";
+
+        private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
+                "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
+        public static final AuthenticationDomain INSTANCE =
+                new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING);
+    }
+
     @Mock
     PackageManager mockPackageManager;
     @Mock
     Context mockContext;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenReturn(VALID_PACKAGE_INFO);
         when(mockContext.getPackageName()).thenReturn(VALID_PACKAGE_NAME);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
     }
 
+    @Test
+    public void fromProtobufBytes_withValidInput_returnsEquivalent() throws Exception {
+        byte[] encodedAuthDomain = ValidAuthDomain.INSTANCE.toProtobuf().toByteArray();
+
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.fromProtobufBytes(encodedAuthDomain);
+
+        assertThat(authenticationDomain).isEqualTo(ValidAuthDomain.INSTANCE);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_withMalformedBytes_throwsMalformedDataException() throws Exception {
+        AuthenticationDomain.fromProtobufBytes(INVALID_PROTO_BYTES);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_withInvalidUri_throwsInvalidProtoBufferException() throws Exception {
+        byte[] invalidProtoBytes =
+                Protobufs.AuthenticationDomain.newBuilder()
+                        .setUri("Invalid uri")
+                        .build()
+                        .toByteArray();
+
+        AuthenticationDomain.fromProtobufBytes(invalidProtoBytes);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobuf_withInvalidUri_throwsInvalidProtoBufferException() throws Exception {
+        Protobufs.AuthenticationDomain invalidProto =
+            Protobufs.AuthenticationDomain.newBuilder()
+                .setUri("Invalid uri")
+                .build();
+
+        AuthenticationDomain.fromProtobuf(invalidProto);
+    }
+
     @Test
     public void getSelfAuthDomain_withValidInput_returnsValidDomain() throws Exception {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain).isNotNull();
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.toString())
                 .isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test
     public void listForPackage_forValidPackage_containsValidAuthenticationDomain() {
         assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME))
                 .contains(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
     }
 
     @Test
     public void listForPackage_forNullPackageName_returnsEmpty() throws Exception {
         assertThat(AuthenticationDomain.listForPackage(mockContext, null /* package */)).isEmpty();
     }
 
     @Test
     public void listForPackage_packageDoesNotExist_returnsEmpty() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenAnswer(new Answer<PackageInfo>() {
                     @Override
                     public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                         throw new NameNotFoundException();
                     }
                 });
 
         assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME)).isEmpty();
     }
 
-    @Test(expected = RequireViolation.class)
-    public void CreateAndroidAuthDomain_withNullDomain_throwsRequireViolation() throws Exception{
+    @Test(expected = IllegalArgumentException.class)
+    public void CreateAndroidAuthDomain_withNullDomain_throwsIllegalArgumentException()
+            throws Exception{
         AuthenticationDomain.createAndroidAuthDomain(null /* authDomain */, mock(Signature.class));
     }
 
     @Test
     public void validWebAuthDomain_hasExpectedBehaviour() {
         AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
 
         assertThat(authDomain.isAndroidAuthDomain()).isFalse();
         assertThat(authDomain.isWebAuthDomain()).isTrue();
 
         try {
             authDomain.getAndroidPackageName();
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void validAndroidAuthDomain_hasExpectedBehaviour(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.isWebAuthDomain()).isFalse();
 
         assertThat(authDomain.getAndroidPackageName()).isEqualTo(VALID_PACKAGE_NAME);
     }
 
     @Test
     public void getSelfAuthDomain_packageNotFoundException_throwsException() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
             .thenAnswer(new Answer<PackageInfo>() {
                 @Override
                 public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                     throw new NameNotFoundException();
                 }
             });
 
         try {
             AuthenticationDomain.getSelfAuthDomain(mockContext);
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
-    @Test
-    public void stringsToAuthDomainsConverter_withValidInput_returnsExpectValues()
-            throws Exception {
-        List<String> domains = new ArrayList<>();
-        domains.add("https://www.google.com");
-        domains.add("https://www.yahoo.com");
-        domains.add("https://www.facebook.com");
-
-        List<AuthenticationDomain> result =
-                CollectionConverter.toList(
-                        domains,
-                        AuthenticationDomainConverters.STRING_TO_DOMAIN);
-
-        assertThat(result.size()).isEqualTo(3);
-
-        assertThat(result.get(0).toString()).isEqualTo(domains.get(0));
-        assertThat(result.get(1).toString()).isEqualTo(domains.get(1));
-        assertThat(result.get(2).toString()).isEqualTo(domains.get(2));
-    }
-
     @Test
     public void equals_withEquivalent_returnsTrue() throws Exception {
         AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mockContext);
         AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomainA).isEqualTo(authDomainA);
         assertThat(authDomainA).isEqualTo(authDomainB);
 
         assertThat(authDomainA.compareTo(authDomainB)).isEqualTo(0);
     }
 
     @Test
     public void equals_withDifferentType_returnsFalse() throws Exception {
         AuthenticationDomain domain = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
         assertThat(domain).isNotEqualTo(WEB_AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testHashCode_equivalent() throws Exception {
         AuthenticationDomain authDomainA = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
         AuthenticationDomain authDomainB = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
 
         assertThat(authDomainA.hashCode()).isEqualTo(authDomainB.hashCode());
     }
 
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
index c9059cb..f18f012 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
@@ -25,3 +25,2 @@ import android.content.Intent;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
 import org.junit.Test;
@@ -30,155 +29,154 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Tests for {@link CredentialDeleteRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteRequestTest {
 
     // invalid as empty string keys are not permitted
     private static final Protobufs.CredentialDeleteRequest INVALID_PROTO =
             Protobufs.CredentialDeleteRequest.newBuilder()
                     .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
                     .build();
 
     private static final byte[] INVALID_PROTO_BYTES =
             new byte[] { 1, 2, 3, 4, 5 };
 
     private static final Credential CREDENTIAL =
             new Credential.Builder(
                     "alice@example.com",
                     AuthenticationMethods.EMAIL,
                     new AuthenticationDomain("https://example.com"))
             .build();
 
     @Test
     public void build() {
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPS)
                         .build();
 
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void build_nullCredential_throwsException() {
-        new CredentialDeleteRequest.Builder((Credential) null).build();
+    @Test(expected = IllegalArgumentException.class)
+    public void build_nullCredential_throwsIllegalArgumentException() {
+        new CredentialDeleteRequest.Builder(null).build();
     }
 
     @Test
     public void fromProtobuf() throws Exception {
         Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
                 .setCredential(CREDENTIAL.toProtobuf())
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromProtobuf(proto);
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_nullProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobuf_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobuf(INVALID_PROTO);
     }
 
     @Test
     public void fromProtobufBytes() throws Exception {
         Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
                 .setCredential(CREDENTIAL.toProtobuf())
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         CredentialDeleteRequest request =
                 CredentialDeleteRequest.fromProtobufBytes(proto.toByteArray());
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_nullArray_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO_BYTES);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
         CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO.toByteArray());
     }
 
     @Test
     public void toProtobuf() {
         Protobufs.CredentialDeleteRequest proto =
                 new CredentialDeleteRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPS)
                         .build()
                 .toProtobuf();
 
         assertThat(proto.hasCredential());
         checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
     }
 
     @Test
     public void fromRequestIntent() throws Exception {
         byte[] protoBytes =
                 new CredentialDeleteRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPS)
                         .build()
                         .toProtobuf()
                         .toByteArray();
 
         Intent requestIntent = new Intent();
         requestIntent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, protoBytes);
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromRequestIntent(requestIntent);
 
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_nullIntent_throwsException() throws Exception {
         CredentialDeleteRequest.fromRequestIntent(null);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_missingExtra_throwsException() throws Exception {
         Intent intent = new Intent();
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_wrongExtraType_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, "notAByteArray");
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProtoBytes_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO_BYTES);
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 
     @Test(expected = MalformedDataException.class)
     public void fromRequestIntent_invalidProto_throwsException() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO.toByteArray());
         CredentialDeleteRequest.fromRequestIntent(intent);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 1e3da45..9577363 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -22,6 +22,4 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 import android.os.Parcel;
-import java.io.IOException;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
@@ -34,112 +32,105 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
     @Test
     public void build_validInputs_shouldSucceed() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
         TestConstants.checkTokenProviderMap(request.getTokenProviders());
         TestConstants.checkAdditionalProps(request.getAdditionalProperties());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
-        new CredentialRetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
+    @Test(expected = MalformedDataException.class)
+    public void fromProto_withNull_throwsMalformedDataException() throws Exception {
+        CredentialRetrieveRequest.fromProtobuf(null);
     }
 
     @Test
     public void testWriteAndRead() {
         CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL)
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             TestConstants.checkTokenProviderMap(deserialized.getTokenProviders());
             TestConstants.checkAdditionalProps(deserialized.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
-
-    private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
-        assertThat(a.keySet()).isEqualTo(b.keySet());
-        for (T key : a.keySet()) {
-            assertThat(a.get(key)).isEqualTo(b.get(key));
-        }
-    }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
index 3c32dbc..ea5cfbf 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
@@ -22,3 +22,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TextFixtures.ValidProperties;
+import org.openyolo.protocol.TestFixtures.ValidProperties;
 import org.robolectric.RobolectricTestRunner;
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
index 89d782a..7e1f47d 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
@@ -22,3 +22,2 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 import android.os.Parcel;
-import java.io.IOException;
 import java.util.Map;
@@ -27,4 +26,4 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TextFixtures.ValidFacebookCredential;
-import org.openyolo.protocol.TextFixtures.ValidProperties;
+import org.openyolo.protocol.TestFixtures.ValidProperties;
+import org.openyolo.protocol.TestFixtures.ValidFacebookCredential;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -34,143 +33,142 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /** Unit tests for {@link CredentialSaveRequest} */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class CredentialSaveRequestTest {
 
     private static final class ValidClientVersion {
         public static final int MAJOR = 1;
         public static final int MINOR = 2;
         public static final int PATCH = 3;
         public static final String VENDOR = "com.customVendor";
 
         public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
                 .setMajor(MAJOR)
                 .setMinor(MINOR)
                 .setPatch(PATCH)
                 .setVendor(VENDOR)
                 .build();
     }
 
     private static final class ValidRequest {
         public static final Credential CREDENTIAL = ValidFacebookCredential.INSTANCE;
         public static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
         public static final CredentialSaveRequest INSTANCE =
                 new CredentialSaveRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(CredentialSaveRequest request) {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             ValidProperties.assertEqualTo(request.getAdditionalProperties());
         }
 
-        public static void assertEqualTo(Protobufs.CredentialSaveRequest request) {
+        public static void assertEqualTo(Protobufs.CredentialSaveRequest request) throws Exception {
             ValidFacebookCredential.assertEqualTo(request.getCredential());
             assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
 
             final Map<String, byte[]> additionalProperties =
                     CollectionConverter.convertMapValues(
                             request.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             ValidProperties.assertEqualTo(additionalProperties);
         }
     }
 
     @Before
     public void setup() {
         ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
     }
 
-    @Test(expected = IOException.class)
-    public void fromProtoBytes_withNull_throwsIOException() throws Exception {
+    @Test(expected = MalformedDataException.class)
+    public void fromProtoBytes_withNull_throwsMalformedDataException() throws Exception {
         CredentialSaveRequest.fromProtoBytes(null /* bytes */);
     }
 
     @Test()
     public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
         final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
-    public void forCredential_withValidCredential_returnsRequestForCredential() {
+    public void fromProto_withValidProto_resultIsEqual() throws Exception {
+        final CredentialSaveRequest request =
+            CredentialSaveRequest.fromProtobuf(ValidRequest.INSTANCE.toProtocolBuffer());
+
+        ValidRequest.assertEqualTo(request);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
+        CredentialSaveRequest.fromProtobuf(null);
+    }
+
+    @Test
+    public void fromCredential_withValidCredential_returnsRequestForCredential() {
         final CredentialSaveRequest request =
                 CredentialSaveRequest.fromCredential(ValidFacebookCredential.INSTANCE);
 
         assertThat(request.getCredential()).isSameAs(ValidFacebookCredential.INSTANCE);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void parcelAndUnparcel_withValidCredential_isEqual() {
         Parcel parcel = Parcel.obtain();
         ValidRequest.INSTANCE.writeToParcel(parcel, 0);
         parcel.setDataPosition(0);
         final CredentialSaveRequest request =
                 CredentialSaveRequest.CREATOR.createFromParcel(parcel);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
-    public void toProtocolBuffer_withValidCredential_containsClientVersion() {
+    public void toProtocolBuffer_withValidCredential_containsClientVersion() throws Exception {
         final Protobufs.CredentialSaveRequest protoRequest =
                 ValidRequest.INSTANCE.toProtocolBuffer();
 
         ValidRequest.assertEqualTo(protoRequest);
     }
 
     @Test
     public void builder_withValidCredential_resultIsEqual() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL).build();
 
         assertThat(request.getCredential()).isSameAs(ValidRequest.CREDENTIAL);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
-    @Test(expected = RequireViolation.class)
-    public void builder_withNullCredential_throwsRequiresViolation() {
+    @Test(expected = IllegalArgumentException.class)
+    public void builder_withNullCredential_throwsIllegalArgumentException() {
         new CredentialSaveRequest.Builder((Credential) null);
     }
 
-    @Test
-    public void builder_withValidProto_resultIsEqual() {
-        final CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidRequest.INSTANCE.toProtocolBuffer()).build();
-
-        ValidRequest.assertEqualTo(request);
-    }
-
-    @Test(expected = RequireViolation.class)
-    public void builder_withNullProto_throwsRequiresViolation() {
-        new CredentialSaveRequest.Builder((Protobufs.CredentialSaveRequest) null);
-    }
-
     public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
         CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
                         .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
                         .setAdditionalProperties(null)
                         .build();
 
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void builder_setAdditionalProperties_isSuccessful() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
                         .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
                         .build();
 
         ValidProperties.assertEqualTo(request.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
index 1c0dd27..c7e1e82 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
@@ -25,3 +25,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TextFixtures.ValidProperties;
+import org.openyolo.protocol.TestFixtures.ValidProperties;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -30,91 +30,90 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /** Unit tests for {@link CredentialSaveResult} */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class CredentialSaveResultTest {
 
     private static final class ValidResult {
         public static int RESULT_CODE = CredentialSaveResult.CODE_SAVED;
         public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
         public static final CredentialSaveResult INSTANCE =
                 new CredentialSaveResult.Builder(RESULT_CODE)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(CredentialSaveResult result) {
             assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
             ValidProperties.assertEqualTo(result.getAdditionalProperties());
         }
 
         public static void assertEqualTo(Protobufs.CredentialSaveResult resultProto) {
             assertThat(resultProto.getResultCodeValue()).isEqualTo(RESULT_CODE);
 
             final Map<String, byte[]> additionalProperties =
                     CollectionConverter.convertMapValues(
                             resultProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             ValidProperties.assertEqualTo(additionalProperties);
         }
     }
 
     @Test
     public void fromProtobufBytes_withValidProto_returnsEquivalentResult() throws Exception {
         final CredentialSaveResult result =
                 CredentialSaveResult.fromProtobufBytes(
                         ValidResult.INSTANCE.toProtobuf().toByteArray());
 
         ValidResult.assertEqualTo(result);
     }
 
     @Test
     public void fromProtobuf_withValidProto_returnsEquivalentResult() throws Exception {
         final CredentialSaveResult result =
                 CredentialSaveResult.fromProtobuf(ValidResult.INSTANCE.toProtobuf());
 
         ValidResult.assertEqualTo(result);
     }
 
     @Test
     public void toProtobuf_withValidResult_returnsEquivalentResult() throws Exception {
         ValidResult.assertEqualTo(ValidResult.INSTANCE.toProtobuf());
     }
 
     @Test
     public void toResultDataIntent_withValidResult_returnsValidIntent() throws Exception {
         final Intent resultIntent = ValidResult.INSTANCE.toResultDataIntent();
 
         final byte[] encodedResult =
                 resultIntent.getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_RESULT);
         ValidResult.assertEqualTo(CredentialSaveResult.fromProtobufBytes(encodedResult));
     }
 
-    @Test(expected = RequireViolation.class)
-    public void builder_withNullProto_throwsRequiresViolation() {
-        new CredentialSaveResult.Builder(null);
+    @Test(expected = MalformedDataException.class)
+    public void fromProto_withNullProto_throwsMalformedDataException() throws Exception {
+        CredentialSaveResult.fromProtobuf(null);
     }
 
     @Test
     public void builder_setAdditionalProperties_isSuccessful() {
         final CredentialSaveResult result =
                 new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
                         .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
                         .build();
 
         ValidResult.assertEqualTo(result);
     }
 
     @Test
     public void builder_setAdditionalPropertiesWithNull_isEmptyMap() {
         CredentialSaveResult result =
                 new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
                         .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
                         .setAdditionalProperties(null)
                         .build();
 
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 3c54a5f..c73aa07 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -25,289 +25,288 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.TextFixtures.ValidFacebookCredential;
+import org.openyolo.protocol.TestFixtures.ValidFacebookCredential;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     public static final String EMAIL_ID = "alice@example.com";
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
 
     @Test
-    public void fromProtobuf_withValidCredential_returnsEquivalentCredential() {
+    public void fromProtobuf_withValidCredential_returnsEquivalentCredential() throws Exception {
         Credential credential =
                 Credential.fromProtobuf(ValidFacebookCredential.INSTANCE.toProtobuf());
 
         ValidFacebookCredential.assertEqualTo(credential);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetIdToken_validInput_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(TestConstants.ALICE_ID_TOKEN)
                 .build();
 
         assertThat(cr.getIdToken()).isEqualTo(TestConstants.ALICE_ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(null)
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken("")
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
         @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index f08aff8..62ef4e3 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -17,6 +17,4 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.assertj.core.data.MapEntry.entry;
 
 import android.os.Parcel;
-import java.nio.charset.Charset;
 import java.util.HashMap;
@@ -29,289 +27,248 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setPasswordSpecification(originalSpec)
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         TestConstants.checkTokenProviderMap(request.getTokenProviders());
         TestConstants.checkAdditionalProps(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testForEmailAndPasswordAccount() {
         HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
 
             TestConstants.checkTokenProviderMap(read.getTokenProviders());
             TestConstants.checkAdditionalProps(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_constructor_nullRequestProto() {
-        new HintRetrieveRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
+    @Test(expected = MalformedDataException.class)
+    public void fromProto_withNull_throwsMalformedDataException() throws Exception {
+        HintRetrieveRequest.fromProtobuf(null);
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setAdditionalProperties_nullMap() {
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAdditionalProperties(null)
-                .build();
-    }
-
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalProperty_nullKey() {
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAdditionalProperty(null, "value")
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalProperty_emptyKey() {
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAdditionalProperty("", "value")
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalProperty_nullByteArrayValue() {
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAdditionalProperty("key", (byte[]) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalProperty_nullStringValue() {
-        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAdditionalProperty("key", (String) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
index 9c797ce..af7766e 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
@@ -25,6 +25,2 @@ import android.content.Intent;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
 import org.junit.Test;
@@ -36,93 +32,93 @@ import org.robolectric.annotation.Config;
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveResultTest {
 
     private static final String ALICE_ID = "alice@example.com";
     private static final Hint HINT =
             new Hint.Builder(
                     ALICE_ID,
                     AuthenticationMethods.EMAIL)
                     .build();
 
     @Test
     public void build() {
 
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isSameAs(HINT);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void buildSetHint_nullValue() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setHint(null)
                 .build();
 
         assertThat(result.getHint()).isNull();
     }
 
     @Test
     public void buildSetAdditionalProperties() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         assertThat(result.getAdditionalProperties()).hasSize(1);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toProtobuf() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         Protobufs.HintRetrieveResult proto = result.toProtobuf();
         assertThat(proto.getResultCodeValue()).isEqualTo(ResultCode.HINT_SELECTED_VALUE);
         assertThat(proto.hasHint());
         checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
     }
 
     @Test
-    public void fromProtobuf() {
+    public void fromProtobuf() throws Exception {
         Protobufs.HintRetrieveResult proto = Protobufs.HintRetrieveResult.newBuilder()
                 .setResultCode(ResultCode.HINT_SELECTED)
                 .setHint(Protobufs.Hint.newBuilder()
                         .setId(ALICE_ID)
                         .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf()))
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         HintRetrieveResult result = HintRetrieveResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isNotNull();
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
-    public void toResultIntentData() throws IOException {
+    public void toResultIntentData() throws Exception {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         Intent intent = result.toResultDataIntent();
         assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
         byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
 
         HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
         assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(readResult.getHint()).isNotNull();
         checkAdditionalProps(readResult.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintTest.java b/protocol/javatests/org/openyolo/protocol/HintTest.java
index 9cc51cb..273b981 100644
--- a/protocol/javatests/org/openyolo/protocol/HintTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintTest.java
@@ -22,4 +22,2 @@ import android.net.Uri;
 import android.os.Parcel;
-import java.io.IOException;
-import java.net.IDN;
 import java.util.HashMap;
@@ -30,309 +28,308 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintTest {
 
     private static final String ALICE_ID = "alice@example.com";
     private static final String ALICE_NAME = "Alice";
     private static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://avatars.example.com/alice";
     private static final Uri ALICE_DISPLAY_PICTURE_URI = Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
     private static final String PASSWORD = "correctH0rseBatterySt4ple";
     private static final String ID_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
             + "eyJzdWIiOiJ5b2xvIn0."
             + "BI1g9ns0shv6PKfwlhfPKwh5XzxQyg_el_35_wZbtsI";
 
     @Test
     public void build_minimalData() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL).build();
         assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
         assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
         assertThat(hint.getDisplayName()).isNull();
         assertThat(hint.getDisplayPictureUri()).isNull();
         assertThat(hint.getIdToken()).isNull();
         assertThat(hint.getAdditionalProperties()).isEmpty();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void build_nullId_shouldThrowException() {
         new Hint.Builder(
                 null,// id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void build_emptyId_shouldThrowException() {
         new Hint.Builder(
                 "", // id
                 AuthenticationMethods.EMAIL)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethod_shouldThrowException() {
         new Hint.Builder(
                 ALICE_ID,
                 (AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void build_nullAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
                 ALICE_ID,
                 (String) null)
                 .build();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void build_emptyAuthMethodStr_shouldThrowException() {
         new Hint.Builder(
                 ALICE_ID,
                 "")
                 .build();
     }
 
     @Test
     public void builderSetDisplayName() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayName(ALICE_NAME)
                 .build();
         assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
     }
 
     @Test
     public void builderSetDisplayName_nullValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayName(null)
                 .build();
 
         assertThat(hint.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetDisplayName_emptyValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayName("")
                 .build();
 
         assertThat(hint.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetDisplayPictureUri() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
                 .build();
         assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
     }
 
     @Test
     public void builderSetDisplayPictureUri_nullValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayPictureUri((Uri) null)
                 .build();
         assertThat(hint.getDisplayPictureUri()).isNull();
     }
 
-    @Test(expected=RequireViolation.class)
+    @Test(expected = IllegalArgumentException.class)
     public void builderSetDisplayPictureUri_nonHttp_shouldThrowException() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayPictureUri(Uri.parse("gopher://hello"))
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test
     public void builderSetDisplayPictureUriStr() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
                 .build();
         assertThat(hint.getDisplayPictureUri().toString()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
     }
 
     @Test
     public void builderSetDisplayPictureUriStr_nullValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayPictureUri((String) null)
                 .build();
         assertThat(hint.getDisplayPictureUri()).isNull();
     }
 
     @Test
     public void builderSetDisplayPictureUriStr_emptyValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setDisplayPictureUri("")
                 .build();
         assertThat(hint.getDisplayPictureUri()).isNull();
     }
 
     @Test
     public void builderSetGeneratedPassword() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setGeneratedPassword(PASSWORD)
                 .build();
 
         assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
     }
 
     @Test
     public void builderSetGeneratedPassword_nullValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setGeneratedPassword(null)
                 .build();
 
         assertThat(hint.getGeneratedPassword()).isNull();
     }
 
     @Test
     public void builderSetGeneratedPassword_emptyValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setGeneratedPassword("")
                 .build();
 
         assertThat(hint.getGeneratedPassword()).isNull();
     }
 
     @Test
     public void builderSetIdToken() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setIdToken(null)
                 .build();
 
         assertThat(hint.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setIdToken(null)
                 .build();
 
         assertThat(hint.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetAdditionalProps() {
         String additionalKey = "extra";
         byte[] additionalValue = "value".getBytes();
 
         Map<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(additionalKey, additionalValue);
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
 
         assertThat(hint.getAdditionalProperties()).hasSize(1);
         assertThat(hint.getAdditionalProperties()).containsKey(additionalKey);
         assertThat(hint.getAdditionalProperties().get(additionalKey)).isEqualTo(additionalValue);
     }
 
     @Test
     public void toProtobuf() {
         Hint hint = new Hint.Builder(
                 ALICE_ID,
                 AuthenticationMethods.EMAIL)
                 .setDisplayName(ALICE_NAME)
                 .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
                 .setGeneratedPassword(PASSWORD)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         Protobufs.Hint proto = hint.toProtobuf();
         assertThat(proto.getId()).isEqualTo(ALICE_ID);
         assertThat(proto.getAuthMethod().getUri())
                 .isEqualTo(AuthenticationMethods.EMAIL.toString());
         assertThat(proto.getDisplayName()).isEqualTo(ALICE_NAME);
         assertThat(proto.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
         assertThat(proto.getGeneratedPassword()).isEqualTo(PASSWORD);
         assertThat(proto.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
-    public void fromProtobuf() {
+    public void fromProtobuf() throws Exception {
         Protobufs.Hint proto = Protobufs.Hint.newBuilder()
                 .setId(ALICE_ID)
                 .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
                 .setDisplayName(ALICE_NAME)
                 .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
                 .setGeneratedPassword(PASSWORD)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         Hint hint = Hint.fromProtobuf(proto);
         assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
         assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
         assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
         assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
         assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
         assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
-    public void fromProtobufBytes() throws IOException {
+    public void fromProtobufBytes() throws Exception {
         Protobufs.Hint proto = Protobufs.Hint.newBuilder()
                 .setId(ALICE_ID)
                 .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
                 .setDisplayName(ALICE_NAME)
                 .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
                 .setGeneratedPassword(PASSWORD)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         Hint hint = Hint.fromProtobufBytes(proto.toByteArray());
         assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
         assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
         assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
         assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
         assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
         assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
     }
 
     @Test
     public void writeToAndReadFromParcel() {
         Hint hint = new Hint.Builder(
                 ALICE_ID,
                 AuthenticationMethods.EMAIL)
                 .setDisplayName(ALICE_NAME)
                 .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
                 .setGeneratedPassword(PASSWORD)
                 .setIdToken(ID_TOKEN)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             hint.writeToParcel(p, 0);
             p.setDataPosition(0);
             Hint readHint = Hint.CREATOR.createFromParcel(p);
 
             assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
             assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
             assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
             assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
             assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
             assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
         } finally {
             p.recycle();
         }
     }
 
     @Test
     public void describeContents() {
         Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL).build();
         assertThat(hint.describeContents()).isEqualTo(0);
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TextFixtures.java b/protocol/javatests/org/openyolo/protocol/TestFixtures.java
similarity index 94%
rename from protocol/javatests/org/openyolo/protocol/TextFixtures.java
rename to protocol/javatests/org/openyolo/protocol/TestFixtures.java
index e9774a4..e413df4 100644
--- a/protocol/javatests/org/openyolo/protocol/TextFixtures.java
+++ b/protocol/javatests/org/openyolo/protocol/TestFixtures.java
@@ -29,73 +29,76 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /** Collection of shared test constants */
-public final class TextFixtures {
+public final class TestFixtures {
     public static final class ValidProperties {
         public static final String PROPERTY_A_NAME = "Property A";
         public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
 
         public static final String PROPERTY_B_NAME = "Property B";
         public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
 
         public static final Map<String, byte[]> MAP_INSTANCE;
 
         static {
             MAP_INSTANCE = new HashMap<>();
             MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
             MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
         }
 
         public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
             Map<String, byte[]> byteMap =
                     CollectionConverter.convertMapValues(
                             map,
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             assertEqualTo(byteMap);
         }
 
         public static void assertEqualTo(Map<String, byte[]> map) {
             assertThat(map).hasSize(2);
             assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
             assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
         }
     }
 
+    public static final byte[] INVALID_PROTO_BYES =
+            new byte[] { 'i', 'n', 'v', 'a', 'l', 'i', 'd' };
+
     public static final class ValidFacebookCredential {
         public final static String ID = "bob@facebook.com";
         public final static String ID_TOKEN = "'His name is bob' - xoxo facebook";
         public final static AuthenticationMethod AUTHENTICATION_METHOD =
                 AuthenticationMethods.FACEBOOK;
         public final static String PASSWORD = "hunter2";
         public final static String DISPLAY_NAME = "Bob";
         public final static Uri DISPLAY_PICTURE_URL =
                 Uri.parse("https://pictures.facebook.com/bob_pics.jpeg");
         public final static Map<String, byte[]> ADDITIONAL_PROPERTIES =
                 ValidProperties.MAP_INSTANCE;
         public final static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
         public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
                 new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
 
         public final static Credential INSTANCE =
                 new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN)
                         .setDisplayName(DISPLAY_NAME)
                         .setDisplayPicture(DISPLAY_PICTURE_URL)
                         .setPassword(PASSWORD)
                         .setIdToken(ID_TOKEN)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(Credential credential) {
             assertThat(credential.getIdentifier()).isEqualTo(ID);
             assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
             assertThat(credential.getPassword()).isEqualTo(PASSWORD);
             assertThat(credential.getDisplayName()).isEqualTo(DISPLAY_NAME);
             assertThat(credential.getDisplayPicture()).isEqualTo(DISPLAY_PICTURE_URL);
             ValidProperties.assertEqualTo(credential.getAdditionalProperties());
             assertThat(credential.getAuthenticationMethod()).isEqualTo(AUTHENTICATION_METHOD);
             assertThat(credential.getAuthenticationDomain()).isEqualTo(AUTHENTICATION_DOMAIN);
         }
 
-        public static void assertEqualTo(Protobufs.Credential credential) {
+        public static void assertEqualTo(Protobufs.Credential credential) throws Exception {
             assertEqualTo(Credential.fromProtobuf(credential));
         }
     }
 }
diff --git a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
index 3d26146..86a57d3 100644
--- a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
+++ b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
@@ -22,3 +22,2 @@ import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import java.io.IOException;
 import java.util.HashSet;
@@ -27,61 +26,53 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.CredentialRetrieveRequest;
-import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.MalformedDataException;
 
 /**
  * Partial implementation of an OpenYOLO request receiver, that should be extended by providers.
  * This implementation handles some basic validation and decoding of the request before
  * handing the request to
  * {@link #processCredentialRequest(Context, BroadcastQuery, CredentialRetrieveRequest, Set)}.
  */
 public abstract class BaseCredentialQueryReceiver extends BaseBroadcastQueryReceiver {
 
     /**
      * Creates a receiver that will log errors to the specified log tag.
      */
     public BaseCredentialQueryReceiver(String logTag) {
         super(logTag);
     }
 
     @Override
     protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
-        Protobufs.CredentialRetrieveRequest requestProto;
-
-        try {
-            requestProto = Protobufs.CredentialRetrieveRequest.parseFrom(query.getQueryMessage());
-        } catch (NullPointerException | IOException ex) {
-            Log.w(mLogTag, "Failed to parse credential request message", ex);
-            new QueryResponseSender(context).sendResponse(query, null);
-            return;
-        }
 
         CredentialRetrieveRequest request;
         try {
-            request = new CredentialRetrieveRequest.Builder(requestProto).build();
-        } catch (NullPointerException | IllegalArgumentException ex) {
+            byte[] encodedProto = query.getQueryMessage().toByteArray();
+            request = CredentialRetrieveRequest.fromProtobufBytes(encodedProto);
+        } catch (MalformedDataException ex) {
             Log.w(mLogTag, "Credential request message failed field validation", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         // TODO: validate claimed authentication domains
         Set<AuthenticationDomain> requestorDomains =
                 new HashSet<>(AuthenticationDomain.listForPackage(
                     context,
                     query.getRequestingApp()));
 
         // Ensure the authentication domain of the requesting app can be determined
         if (requestorDomains.isEmpty()) {
             Log.w(mLogTag, "Unable to determine the authentication domain of the requesting app");
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         processCredentialRequest(context, query, request, requestorDomains);
     }
 
     protected abstract void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains);
 }

commit 3940fb00b4d50e739cf3ec7edac00a4e1526ba82
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Thu May 18 12:59:45 2017 -0700

    Fixed bug where Credential#fromProtobuf would ignore an IdToken present in the protobuffer (#59)

diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 9c6f6be..4e6351e 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -40,415 +40,416 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a credential for use in sign-in. This provides a higher-level,
  * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
  * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     /**
      * Creates a credential from its protocol buffer equivalent, in byte form.
      * @throws IOException if the protocol buffer cannot be parsed.
      */
     public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
         return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
     }
 
     /**
      * Creates a credential from its protocol buffer equivalent.
      */
     public static Credential fromProtobuf(Protobufs.Credential credential) {
         return new Credential.Builder(credential).build();
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationDomain mAuthDomain;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPicture;
 
     @Nullable
     private final String mPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Credential(
             @NonNull String id,
             @NonNull AuthenticationDomain authDomain,
             @NonNull AuthenticationMethod authMethod,
             @Nullable String displayName,
             @Nullable Uri displayPicture,
             @Nullable String password,
             @Nullable String idToken,
             @NonNull Map<String, ByteString> additionalProps) {
         mId = id;
         mAuthDomain = authDomain;
         mAuthMethod = authMethod;
         mDisplayName = displayName;
         mDisplayPicture = displayPicture;
         mPassword = password;
         mIdToken = idToken;
         mAdditionalProps = additionalProps;
     }
 
     /**
      * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
     public Protobufs.Credential toProtobuf() {
         Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .setAuthDomain(mAuthDomain.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPicture != null) {
             builder.setDisplayPictureUri(mDisplayPicture.toString());
         }
 
         if (mPassword != null) {
             builder.setPassword(mPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
     @NonNull
     public AuthenticationDomain getAuthenticationDomain() {
         return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPicture;
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
         return mPassword;
     }
 
     /**
      * An ID token which provides "proof of access" to the identifier for this credential, if
      * available.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
             mAdditionalProps,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
         private String mId;
         private AuthenticationMethod mAuthMethod;
         private AuthenticationDomain mAuthDomain;
         private String mDisplayName;
         private Uri mDisplayPicture;
         private String mPassword;
         private String mIdToken;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          */
-        public Builder(@NonNull Protobufs.Credential proto) {
+        private Builder(@NonNull Protobufs.Credential proto) {
             // required properties
             setIdentifier(proto.getId());
             setAuthenticationMethod(
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT
                             .convert(proto.getAuthMethod()));
             setAuthenticationDomain(
                     AuthenticationDomainConverters.PROTOBUF_TO_OBJECT
                             .convert(proto.getAuthDomain()));
 
             // optional properties
 
+            setIdToken(proto.getIdToken());
             setDisplayName(proto.getDisplayName());
             setDisplayPicture(proto.getDisplayPictureUri());
             setPassword(proto.getPassword());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             proto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
          * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
                     new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
             require(!TextUtils.isEmpty(identifier), "identifier must not be null or empty");
             mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             require(domain, notNullValue());
             mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
         public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
             require(authMethod, notNullValue());
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
             mPassword = nullifyEmptyString(password);
             return this;
         }
 
         /**
          * Specifies the ID token for the credential. If a null or empty value is provided, this
          * is equivalent to remove the ID token from the credential.
          */
         @NonNull
         public Builder setIdToken(String idToken) {
             this.mIdToken = nullifyEmptyString(idToken);
             return this;
         }
 
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             require(displayPicture, nullOr(isWebUri()));
             mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             if (additionalProps == null) {
                 mAdditionalProps.clear();
                 return this;
             }
 
             require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProps.values(), everyItem(notNullValue()));
 
             mAdditionalProps = CollectionConverter.convertMapValues(
                     additionalProps,
                     ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
             return new Credential(
                     mId,
                     mAuthDomain,
                     mAuthMethod,
                     mDisplayName,
                     mDisplayPicture,
                     mPassword,
                     mIdToken,
                     mAdditionalProps);
         }
     }
 
     private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
                 Protobufs.Credential proto = Protobufs.Credential.parseFrom(encodedBytes);
                 return new Credential.Builder(proto).build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
index 51debb3..89d782a 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
@@ -27,2 +27,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.TextFixtures.ValidFacebookCredential;
 import org.openyolo.protocol.TextFixtures.ValidProperties;
@@ -36,160 +37,140 @@ import org.valid4j.errors.RequireViolation;
 /** Unit tests for {@link CredentialSaveRequest} */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public final class CredentialSaveRequestTest {
 
     private static final class ValidClientVersion {
         public static final int MAJOR = 1;
         public static final int MINOR = 2;
         public static final int PATCH = 3;
         public static final String VENDOR = "com.customVendor";
 
         public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
                 .setMajor(MAJOR)
                 .setMinor(MINOR)
                 .setPatch(PATCH)
                 .setVendor(VENDOR)
                 .build();
     }
 
     private static final class ValidRequest {
-        public static final Credential CREDENTIAL = ValidCredential.INSTANCE;
+        public static final Credential CREDENTIAL = ValidFacebookCredential.INSTANCE;
         public static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
 
         public static final CredentialSaveRequest INSTANCE =
                 new CredentialSaveRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPERTIES)
                         .build();
 
         public static void assertEqualTo(CredentialSaveRequest request) {
-            ValidCredential.assertEqualTo(request.getCredential());
+            ValidFacebookCredential.assertEqualTo(request.getCredential());
             ValidProperties.assertEqualTo(request.getAdditionalProperties());
         }
 
         public static void assertEqualTo(Protobufs.CredentialSaveRequest request) {
-            ValidCredential.assertEqualTo(request.getCredential());
+            ValidFacebookCredential.assertEqualTo(request.getCredential());
             assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
 
             final Map<String, byte[]> additionalProperties =
                     CollectionConverter.convertMapValues(
                             request.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             ValidProperties.assertEqualTo(additionalProperties);
         }
     }
 
-    private static final class ValidCredential {
-        public final static String ID = "Credential ID";
-        public final static String AUTHENTICATION_DOMAIN_STRING = "https://.google.com";
-        public final static AuthenticationMethod AUTHENTICATION_METHOD =
-                AuthenticationMethods.FACEBOOK;
-        public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
-                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
-
-        public final static Credential INSTANCE =
-                new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN).build();
-
-        public static void assertEqualTo(Credential credential) {
-            assertThat(credential.getIdentifier()).isEqualTo(ID);
-        }
-
-        public static void assertEqualTo(Protobufs.Credential credential) {
-            assertThat(credential.getId()).isEqualTo(ID);
-        }
-    }
-
     @Before
     public void setup() {
         ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
     }
 
     @Test(expected = IOException.class)
     public void fromProtoBytes_withNull_throwsIOException() throws Exception {
         CredentialSaveRequest.fromProtoBytes(null /* bytes */);
     }
 
     @Test()
     public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
         final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
 
         final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
     public void forCredential_withValidCredential_returnsRequestForCredential() {
         final CredentialSaveRequest request =
-                CredentialSaveRequest.fromCredential(ValidCredential.INSTANCE);
+                CredentialSaveRequest.fromCredential(ValidFacebookCredential.INSTANCE);
 
-        assertThat(request.getCredential()).isSameAs(ValidCredential.INSTANCE);
+        assertThat(request.getCredential()).isSameAs(ValidFacebookCredential.INSTANCE);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void parcelAndUnparcel_withValidCredential_isEqual() {
         Parcel parcel = Parcel.obtain();
         ValidRequest.INSTANCE.writeToParcel(parcel, 0);
         parcel.setDataPosition(0);
         final CredentialSaveRequest request =
                 CredentialSaveRequest.CREATOR.createFromParcel(parcel);
 
         ValidRequest.assertEqualTo(request);
     }
 
     @Test
     public void toProtocolBuffer_withValidCredential_containsClientVersion() {
         final Protobufs.CredentialSaveRequest protoRequest =
                 ValidRequest.INSTANCE.toProtocolBuffer();
 
         ValidRequest.assertEqualTo(protoRequest);
     }
 
     @Test
     public void builder_withValidCredential_resultIsEqual() {
         final CredentialSaveRequest request =
-                new CredentialSaveRequest.Builder(ValidCredential.INSTANCE).build();
+                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL).build();
 
-        assertThat(request.getCredential()).isSameAs(ValidCredential.INSTANCE);
+        assertThat(request.getCredential()).isSameAs(ValidRequest.CREDENTIAL);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test(expected = RequireViolation.class)
     public void builder_withNullCredential_throwsRequiresViolation() {
         new CredentialSaveRequest.Builder((Credential) null);
     }
 
     @Test
     public void builder_withValidProto_resultIsEqual() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.INSTANCE.toProtocolBuffer()).build();
 
-        assertThat(request.getCredential().getIdentifier()).isEqualTo(ValidCredential.ID);
+        ValidRequest.assertEqualTo(request);
     }
 
     @Test(expected = RequireViolation.class)
     public void builder_withNullProto_throwsRequiresViolation() {
         new CredentialSaveRequest.Builder((Protobufs.CredentialSaveRequest) null);
     }
 
     public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
         CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
                         .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
                         .setAdditionalProperties(null)
                         .build();
 
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void builder_setAdditionalProperties_isSuccessful() {
         final CredentialSaveRequest request =
                 new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
                         .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
                         .build();
 
         ValidProperties.assertEqualTo(request.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 1fdc44e..3c54a5f 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -25,2 +25,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.TextFixtures.ValidFacebookCredential;
 import org.robolectric.RobolectricTestRunner;
@@ -30,275 +31,283 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     public static final String EMAIL_ID = "alice@example.com";
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
 
+    @Test
+    public void fromProtobuf_withValidCredential_returnsEquivalentCredential() {
+        Credential credential =
+                Credential.fromProtobuf(ValidFacebookCredential.INSTANCE.toProtobuf());
+
+        ValidFacebookCredential.assertEqualTo(credential);
+    }
+
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void builderSetIdToken_validInput_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(TestConstants.ALICE_ID_TOKEN)
                 .build();
 
         assertThat(cr.getIdToken()).isEqualTo(TestConstants.ALICE_ID_TOKEN);
     }
 
     @Test
     public void builderSetIdToken_nullValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken(null)
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
     @Test
     public void builderSetIdToken_emptyValue_shouldSucceed() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdToken("")
                 .build();
 
         assertThat(cr.getIdToken()).isNull();
     }
 
         @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TextFixtures.java b/protocol/javatests/org/openyolo/protocol/TextFixtures.java
index 73b4be8..e9774a4 100644
--- a/protocol/javatests/org/openyolo/protocol/TextFixtures.java
+++ b/protocol/javatests/org/openyolo/protocol/TextFixtures.java
@@ -21,2 +21,3 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
+import android.net.Uri;
 import com.google.protobuf.ByteString;
@@ -28,33 +29,73 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /** Collection of shared test constants */
 public final class TextFixtures {
     public static final class ValidProperties {
         public static final String PROPERTY_A_NAME = "Property A";
         public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
 
         public static final String PROPERTY_B_NAME = "Property B";
         public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
 
         public static final Map<String, byte[]> MAP_INSTANCE;
 
         static {
             MAP_INSTANCE = new HashMap<>();
             MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
             MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
         }
 
         public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
             Map<String, byte[]> byteMap =
                     CollectionConverter.convertMapValues(
                             map,
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
 
             assertEqualTo(byteMap);
         }
 
         public static void assertEqualTo(Map<String, byte[]> map) {
             assertThat(map).hasSize(2);
             assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
             assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
         }
     }
+
+    public static final class ValidFacebookCredential {
+        public final static String ID = "bob@facebook.com";
+        public final static String ID_TOKEN = "'His name is bob' - xoxo facebook";
+        public final static AuthenticationMethod AUTHENTICATION_METHOD =
+                AuthenticationMethods.FACEBOOK;
+        public final static String PASSWORD = "hunter2";
+        public final static String DISPLAY_NAME = "Bob";
+        public final static Uri DISPLAY_PICTURE_URL =
+                Uri.parse("https://pictures.facebook.com/bob_pics.jpeg");
+        public final static Map<String, byte[]> ADDITIONAL_PROPERTIES =
+                ValidProperties.MAP_INSTANCE;
+        public final static String AUTHENTICATION_DOMAIN_STRING = "https://accounts.google.com";
+        public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
+                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
+
+        public final static Credential INSTANCE =
+                new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN)
+                        .setDisplayName(DISPLAY_NAME)
+                        .setDisplayPicture(DISPLAY_PICTURE_URL)
+                        .setPassword(PASSWORD)
+                        .setIdToken(ID_TOKEN)
+                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+                        .build();
+
+        public static void assertEqualTo(Credential credential) {
+            assertThat(credential.getIdentifier()).isEqualTo(ID);
+            assertThat(credential.getIdToken()).isEqualTo(ID_TOKEN);
+            assertThat(credential.getPassword()).isEqualTo(PASSWORD);
+            assertThat(credential.getDisplayName()).isEqualTo(DISPLAY_NAME);
+            assertThat(credential.getDisplayPicture()).isEqualTo(DISPLAY_PICTURE_URL);
+            ValidProperties.assertEqualTo(credential.getAdditionalProperties());
+            assertThat(credential.getAuthenticationMethod()).isEqualTo(AUTHENTICATION_METHOD);
+            assertThat(credential.getAuthenticationDomain()).isEqualTo(AUTHENTICATION_DOMAIN);
+        }
+
+        public static void assertEqualTo(Protobufs.Credential credential) {
+            assertEqualTo(Credential.fromProtobuf(credential));
+        }
+    }
 }

commit a49f2afc0894a408123dab381718bca7ef6cd8a3
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Mon May 15 15:42:16 2017 -0700

    Replaced Android Client Id with Web Client Id (#57)
    
    * Replaced Android Client Id with Web Client Id

diff --git a/testapp/java/org/openyolo/testapp/TokenProviderInputView.java b/testapp/java/org/openyolo/testapp/TokenProviderInputView.java
index 4697440..e628b35 100644
--- a/testapp/java/org/openyolo/testapp/TokenProviderInputView.java
+++ b/testapp/java/org/openyolo/testapp/TokenProviderInputView.java
@@ -30,94 +30,94 @@ import org.openyolo.protocol.TokenRequestInfo;
 /**
  * Displays options for setting a supported token provider on an OpenYOLO request.
  */
 public class TokenProviderInputView extends LinearLayout {
 
     private static final String TAG = "TokenProvInputView";
 
     private static final String GOOGLE_TOKEN_PROVIDER_URI =
             "https://accounts.google.com";
 
     private static final String GOOGLE_CLIENT_ID =
-            "304746752269-k0i6b4qsant0mi47612phok7ihveohmp.apps.googleusercontent.com";
+            "304746752269-lah6bs2tt2pos45kr64obv3tblu6v2ma.apps.googleusercontent.com";
 
     @BindView(R.id.use_google)
     Button mUseGoogleSettings;
 
     @BindView(R.id.token_provider_uri_field)
     EditText mTokenProviderUriField;
 
     @BindView(R.id.client_id_field)
     EditText mClientIdField;
 
     @BindView(R.id.nonce_field)
     EditText mNonceField;
 
     /**
      * Standard view constructor.
      */
     public TokenProviderInputView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Standard view constructor.
      */
     public TokenProviderInputView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Standard view constructor.
      */
     public TokenProviderInputView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.token_provider_input_layout, this);
         ButterKnife.bind(view);
 
         mUseGoogleSettings.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View view) {
                 mTokenProviderUriField.setText(GOOGLE_TOKEN_PROVIDER_URI);
                 mClientIdField.setText(GOOGLE_CLIENT_ID);
             }
         });
     }
 
     /**
      * Creates a token provider request info map, based on the settings in the view.
      */
     public Map<String, TokenRequestInfo> getTokenProviders() {
         HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
         String tokenProviderUriStr = mTokenProviderUriField.getText().toString().trim();
 
         if (tokenProviderUriStr.isEmpty()) {
             return tokenProviders;
         }
 
         Uri tokenProviderUri = Uri.parse(tokenProviderUriStr);
         if (!"https".equals(tokenProviderUri.getScheme())) {
             return tokenProviders;
         }
 
         TokenRequestInfo.Builder infoBuilder = new TokenRequestInfo.Builder();
 
         String clientId = mClientIdField.getText().toString().trim();
         if (!clientId.isEmpty()) {
             infoBuilder.setClientId(clientId);
         }
 
         String nonce = mNonceField.getText().toString().trim();
         if (!nonce.isEmpty()) {
             infoBuilder.setNonce(nonce);
         }
 
         tokenProviders.put(tokenProviderUriStr, infoBuilder.build());
         return tokenProviders;
     }
 }

commit 3f6ea1205549de056b0f84474f23b85f2a53915a
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Mon May 15 14:45:13 2017 -0700

    Added unit tests for CredentialRetrieveResult (#56)
    
    * Fixed bug where credential retrieve result could throw RequiresViolation
    exception for when given a parsing from a valid protobuffer.
    
    * Added unit tests for CredentialRetrieveResult

diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 97bd8d6..3ab5c64 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -16,7 +16,2 @@ package org.openyolo.protocol;
 
-import static org.hamcrest.CoreMatchers.everyItem;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
-import static org.valid4j.Assertive.require;
-
 import android.content.Intent;
@@ -26,4 +21,6 @@ import com.google.protobuf.ByteString;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -32,245 +29,239 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the user selected a hint, that has been returned as part of this response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws IOException if the request could not be parsed or validated.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws IOException {
         return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
     }
 
     /**
      * Creates a credential retrieve result from its protocol buffer equivalent.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto) {
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
-    private CredentialRetrieveResult(
-            int resultCode,
-            Credential credential,
-            Map<String, ByteString> additionalProps) {
-        mResultCode = resultCode;
-        mCredential = credential;
-        mAdditionalProps = additionalProps;
+    private CredentialRetrieveResult(Builder builder) {
+        mResultCode = builder.mResultCode;
+        mCredential = builder.mCredential;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          */
-        public Builder(Protobufs.CredentialRetrieveResult proto) {
+        private Builder(Protobufs.CredentialRetrieveResult proto) {
             setResultCode(proto.getResultCodeValue());
             setCredentialFromProto(proto.getCredential());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
-        public Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
-            mCredential = credential != null ? Credential.fromProtobuf(credential) : null;
+        private Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
+            if (!Protobufs.Credential.getDefaultInstance().equals(credential)) {
+                mCredential = Credential.fromProtobuf(credential);
+            } else {
+                mCredential = null;
+            }
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
-            require(additionalProperties, notNullValue());
-            require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
-            require(additionalProperties.values(), everyItem(notNullValue()));
-
             mAdditionalProps =
-                    CollectionConverter.convertMapValues(
-                            additionalProperties,
-                            ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProperties);
             return this;
         }
 
-        Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProperties) {
-            require(additionalProperties, notNullValue());
-            require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
-            require(additionalProperties.values(), everyItem(notNullValue()));
-
-            mAdditionalProps = additionalProperties;
+        private Builder setAdditionalPropertiesFromProto(
+                Map<String, ByteString> additionalProperties) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
+                            additionalProperties);
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
-            return new CredentialRetrieveResult(mResultCode, mCredential, mAdditionalProps);
+            return new CredentialRetrieveResult(this);
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
new file mode 100644
index 0000000..3c32dbc
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveResultTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.content.Intent;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.TextFixtures.ValidProperties;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/** Unit tests for {@link CredentialRetrieveResult}. */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class CredentialRetrieveResultTest {
+
+  private static final class ValidCredential {
+    public static final String ID = "email@gogo.com";
+    public static final AuthenticationMethod AUTHENTICATION_METHOD = AuthenticationMethods.EMAIL;
+    public static final String AUTH_DOMAIN_STR = "https://www.example.com";
+    public static final AuthenticationDomain AUTHENTICATION_DOMAIN =
+        new AuthenticationDomain(AUTH_DOMAIN_STR);
+    public static final Credential INSTANCE =
+        new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN).build();
+
+    private static void assertEqualTo(Credential credential) {
+      assertThat(credential.getIdentifier()).isEqualTo(ID);
+    }
+
+    private static void assertEqualTo(Protobufs.Credential credential) {
+      assertThat(credential.getId()).isEqualTo(ID);
+    }
+  }
+
+  private static final class ValidCredentialSelectedResult {
+    public static int RESULT_CODE = CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED;
+    public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+
+    public static final CredentialRetrieveResult INSTANCE =
+        new CredentialRetrieveResult.Builder(RESULT_CODE)
+            .setCredential(ValidCredential.INSTANCE)
+            .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+            .build();
+
+    private static void assertEqualTo(Protobufs.CredentialRetrieveResult result) {
+      assertThat(result.getResultCodeValue()).isEqualTo(RESULT_CODE);
+      ValidCredential.assertEqualTo(result.getCredential());
+      ValidProperties.assertEqualTo(result.getAdditionalPropsMap(), false /* dummy */);
+    }
+
+    private static void assertEqualTo(CredentialRetrieveResult result) {
+      assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
+      ValidCredential.assertEqualTo(result.getCredential());
+      ValidProperties.assertEqualTo(result.getAdditionalProps());
+    }
+  }
+
+  private static final class ValidBadRequestResult {
+    public static int RESULT_CODE = CredentialRetrieveResult.CODE_BAD_REQUEST;
+    public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+
+    public static final CredentialRetrieveResult INSTANCE =
+        new CredentialRetrieveResult.Builder(RESULT_CODE)
+            .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+            .build();
+
+    private static void assertEqualTo(Protobufs.CredentialRetrieveResult result) {
+      assertThat(result.getResultCodeValue()).isEqualTo(RESULT_CODE);
+      assertThat(result.getCredential()).isEqualTo(Protobufs.Credential.getDefaultInstance());
+      ValidProperties.assertEqualTo(result.getAdditionalPropsMap(), false /* dummy */);
+    }
+
+    private static void assertEqualTo(CredentialRetrieveResult result) {
+      assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
+      assertThat(result.getCredential()).isNull();
+      ValidProperties.assertEqualTo(result.getAdditionalProps());
+    }
+  }
+
+  @Test
+  public void fromProtobufBytes_withValidCredentialSelectedResult_returnsEquivalent() throws Exception {
+    byte[] encodedBytes = ValidCredentialSelectedResult.INSTANCE.toProtobuf().toByteArray();
+
+    CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedBytes);
+
+    ValidCredentialSelectedResult.assertEqualTo(result);
+  }
+
+  @Test
+  public void fromProtobufBytes_withValidBadRequestResult_returnsEquivalent() throws Exception {
+    byte[] encodedBytes = ValidBadRequestResult.INSTANCE.toProtobuf().toByteArray();
+
+    CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedBytes);
+
+    ValidBadRequestResult.assertEqualTo(result);
+  }
+
+  @Test
+  public void toProtobuf_withValidCredentialSelectedResult_returnsEquivalent() throws Exception {
+    ValidCredentialSelectedResult.assertEqualTo(
+        ValidCredentialSelectedResult.INSTANCE.toProtobuf());
+  }
+
+  @Test
+  public void toProtobuf_withValidBadRequestResult_returnsEquivalent() throws Exception {
+    ValidBadRequestResult.assertEqualTo(ValidBadRequestResult.INSTANCE.toProtobuf());
+  }
+
+  @Test
+  public void toResultDataIntent_withValidRequest_encodesIntoIntent() throws Exception {
+    Intent intent = ValidBadRequestResult.INSTANCE.toResultDataIntent();
+
+    byte[] encodedResult = intent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT);
+    CredentialRetrieveResult result = CredentialRetrieveResult.fromProtobufBytes(encodedResult);
+    ValidBadRequestResult.assertEqualTo(result);
+  }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/TextFixtures.java b/protocol/javatests/org/openyolo/protocol/TextFixtures.java
index 563c0a0..73b4be8 100644
--- a/protocol/javatests/org/openyolo/protocol/TextFixtures.java
+++ b/protocol/javatests/org/openyolo/protocol/TextFixtures.java
@@ -21,28 +21,40 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
+import com.google.protobuf.ByteString;
 import java.util.HashMap;
 import java.util.Map;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
 
 /** Collection of shared test constants */
 public final class TextFixtures {
     public static final class ValidProperties {
         public static final String PROPERTY_A_NAME = "Property A";
         public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
 
         public static final String PROPERTY_B_NAME = "Property B";
         public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
 
         public static final Map<String, byte[]> MAP_INSTANCE;
 
         static {
             MAP_INSTANCE = new HashMap<>();
             MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
             MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
         }
 
+        public static void assertEqualTo(Map<String, ByteString> map, boolean dummy) {
+            Map<String, byte[]> byteMap =
+                    CollectionConverter.convertMapValues(
+                            map,
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+
+            assertEqualTo(byteMap);
+        }
+
         public static void assertEqualTo(Map<String, byte[]> map) {
             assertThat(map).hasSize(2);
             assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
             assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
         }
     }
 }

commit 76eeb298809deb893309e3850eff555d40752632
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Wed May 10 11:25:12 2017 -0700

    Token provider testing
    
    Adds the ability to set token provider request properties for
    hint and credential retrieve requests. Renders raw ID token
    response (placeholder for better rendering).
    
    A keystore for the test app is added so that Google ID token
    requests can be successfully made.

diff --git a/.gitignore b/.gitignore
index d6dbe4e..92b54ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
-*.keystore
+openyolo.keystore
 .gradle
diff --git a/build.gradle b/build.gradle
index 9c821d8..94923fb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,3 +1,2 @@
 apply from: 'config/localprops.gradle'
-apply from: 'config/keystore.gradle'
 
diff --git a/config/keystore.gradle b/config/keystore.gradle
deleted file mode 100644
index 82ea6b3..0000000
--- a/config/keystore.gradle
+++ /dev/null
@@ -1,28 +0,0 @@
-// creates a keystore with a random private key suitable for building dev
-// and release builds during active development.
-def generateKeystore = { keystoreFile ->
-    exec {
-        executable "keytool"
-        args [
-            "-genkey",
-            "-keystore", "openyolo.keystore",
-            "-alias", "openyolo",
-            "-keyalg", "RSA",
-            "-keysize", "2048",
-            "-validity", "10000",
-            "-keypass", "openyolo",
-            "-storepass", "openyolo",
-            "-dname", "CN=openyolo"
-        ]
-    }
-}
-
-// checks that a keystore exists in the expected location, and generates one
-// if it does not.
-ext.verifyKeystore = {
-    def keystoreFile = file(new File(projectDir, "openyolo.keystore"))
-    if (!keystoreFile.exists()) {
-        logger.lifecycle("openyolo.keystore missing - creating one")
-        generateKeystore(keystoreFile)
-    }
-}
diff --git a/testapp/build.gradle b/testapp/build.gradle
index d7a6bf1..5caa162 100644
--- a/testapp/build.gradle
+++ b/testapp/build.gradle
@@ -7,13 +7,27 @@ apply from:'../config/android-common.gradle'
 android {
     defaultConfig {
         applicationId "org.openyolo.testapp"
         project.archivesBaseName = "openyolo-testapp"
         vectorDrawables.useSupportLibrary = true
     }
+
+    signingConfigs {
+        debugAndRelease {
+            storeFile file("${projectDir}/testapp.keystore")
+            storePassword "testapp"
+            keyAlias "testapp"
+            keyPassword "testapp"
+        }
+    }
+
     buildTypes {
+        debug {
+            signingConfig signingConfigs.debugAndRelease
+        }
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+            signingConfig signingConfigs.debugAndRelease
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index e3fb97a..179c1b0 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -34,104 +34,113 @@ import org.openyolo.protocol.HintRetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
+    @BindView(R.id.token_providers_input)
+    TokenProviderInputView mTokenProviderInputView;
+
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
+    @BindView(R.id.id_token_view)
+    IdTokenView mIdTokenView;
+
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         // CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         HintRetrieveResult result = mApi.getHintRetrieveResult(data);
         Hint hint = result.getHint();
         if (hint != null) {
             mCredentialView.setFieldsFromHint(hint);
+            mIdTokenView.setIdToken(hint.getIdToken());
             return;
         }
 
         int errorStringResId;
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 errorStringResId = R.string.hint_bad_request;
                 break;
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 errorStringResId = R.string.hint_none_available;
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 errorStringResId = R.string.hint_user_canceled;
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 errorStringResId = R.string.hint_manual_auth;
                 break;
             default:
                 errorStringResId = R.string.hint_unknown_response;
         }
         showSnackbar(errorStringResId);
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
 
-        HintRetrieveRequest.Builder requestBuilder =
-                new HintRetrieveRequest.Builder(authenticationMethods);
+        HintRetrieveRequest request =
+                new HintRetrieveRequest.Builder(authenticationMethods)
+                        .setTokenProviders(mTokenProviderInputView.getTokenProviders())
+                        .build();
 
-        Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
+        Intent hintIntent = mApi.getHintRetrieveIntent(request);
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/IdTokenView.java b/testapp/java/org/openyolo/testapp/IdTokenView.java
new file mode 100644
index 0000000..dd4495d
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/IdTokenView.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+/**
+ * Displays an ID token.
+ */
+public class IdTokenView extends LinearLayout {
+
+    @BindView(R.id.raw_token)
+    TextView mRawTokenView;
+
+    /**
+     * Standard view constructor.
+     */
+    public IdTokenView(Context context) {
+        super(context);
+        initialize(context);
+    }
+
+    /**
+     * Standard view constructor.
+     */
+    public IdTokenView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initialize(context);
+    }
+
+    /**
+     * Standard view constructor.
+     */
+    public IdTokenView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        initialize(context);
+    }
+
+    private void initialize(Context context) {
+        View view = View.inflate(context, R.layout.id_token_layout, this);
+        ButterKnife.bind(view);
+    }
+
+    /**
+     * Specifies the ID token to display.
+     */
+    public void setIdToken(@Nullable String idToken) {
+        if (idToken == null) {
+            mRawTokenView.setText(R.string.no_token);
+            return;
+        }
+
+        mRawTokenView.setText(idToken);
+    }
+
+}
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index efbf34a..050cb8e 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -32,2 +32,3 @@ import org.openyolo.api.RetrieveCallback;
 import org.openyolo.protocol.AuthenticationMethod;
+import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.CredentialRetrieveRequest;
@@ -37,130 +38,140 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
+    @BindView(R.id.token_providers_input)
+    TokenProviderInputView mTokenProviderInputView;
+
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
+    @BindView(R.id.id_token_view)
+    IdTokenView mIdTokenView;
+
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
-        if (result.getCredential() != null) {
-            mCredentialView.setFieldsFromCredential(result.getCredential());
+        Credential credential = result.getCredential();
+        if (credential != null) {
+            mCredentialView.setFieldsFromCredential(credential);
+            mIdTokenView.setIdToken(credential.getIdToken());
             return;
         }
 
         int resultMessageId;
         switch (result.getResultCode()) {
             case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
                 resultMessageId = R.string.retrieve_no_credentials;
                 break;
             case CredentialRetrieveResult.CODE_BAD_REQUEST:
                 resultMessageId = R.string.retrieve_bad_request;
                 break;
             case CredentialRetrieveResult.CODE_USER_CANCELED:
                 resultMessageId = R.string.retrieve_user_canceled;
                 break;
             case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 resultMessageId = R.string.retrieve_manual_auth;
                 break;
             default:
                 resultMessageId = R.string.retrieve_unknown_response;
         }
 
         showSnackbar(resultMessageId);
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         CredentialRetrieveRequest request =
-                CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
+                new CredentialRetrieveRequest.Builder(authenticationMethods)
+                        .setTokenProviders(mTokenProviderInputView.getTokenProviders())
+                        .build();
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveBbqResponse> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveBbqResponse result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveBbqResponse result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.retrieve_no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/TokenProviderInputView.java b/testapp/java/org/openyolo/testapp/TokenProviderInputView.java
new file mode 100644
index 0000000..4697440
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/TokenProviderInputView.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.content.Context;
+import android.net.Uri;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.TokenRequestInfo;
+
+/**
+ * Displays options for setting a supported token provider on an OpenYOLO request.
+ */
+public class TokenProviderInputView extends LinearLayout {
+
+    private static final String TAG = "TokenProvInputView";
+
+    private static final String GOOGLE_TOKEN_PROVIDER_URI =
+            "https://accounts.google.com";
+
+    private static final String GOOGLE_CLIENT_ID =
+            "304746752269-k0i6b4qsant0mi47612phok7ihveohmp.apps.googleusercontent.com";
+
+    @BindView(R.id.use_google)
+    Button mUseGoogleSettings;
+
+    @BindView(R.id.token_provider_uri_field)
+    EditText mTokenProviderUriField;
+
+    @BindView(R.id.client_id_field)
+    EditText mClientIdField;
+
+    @BindView(R.id.nonce_field)
+    EditText mNonceField;
+
+    /**
+     * Standard view constructor.
+     */
+    public TokenProviderInputView(Context context) {
+        super(context);
+        initialize(context);
+    }
+
+    /**
+     * Standard view constructor.
+     */
+    public TokenProviderInputView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initialize(context);
+    }
+
+    /**
+     * Standard view constructor.
+     */
+    public TokenProviderInputView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        initialize(context);
+    }
+
+    private void initialize(Context context) {
+        View view = View.inflate(context, R.layout.token_provider_input_layout, this);
+        ButterKnife.bind(view);
+
+        mUseGoogleSettings.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                mTokenProviderUriField.setText(GOOGLE_TOKEN_PROVIDER_URI);
+                mClientIdField.setText(GOOGLE_CLIENT_ID);
+            }
+        });
+    }
+
+    /**
+     * Creates a token provider request info map, based on the settings in the view.
+     */
+    public Map<String, TokenRequestInfo> getTokenProviders() {
+        HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
+        String tokenProviderUriStr = mTokenProviderUriField.getText().toString().trim();
+
+        if (tokenProviderUriStr.isEmpty()) {
+            return tokenProviders;
+        }
+
+        Uri tokenProviderUri = Uri.parse(tokenProviderUriStr);
+        if (!"https".equals(tokenProviderUri.getScheme())) {
+            return tokenProviders;
+        }
+
+        TokenRequestInfo.Builder infoBuilder = new TokenRequestInfo.Builder();
+
+        String clientId = mClientIdField.getText().toString().trim();
+        if (!clientId.isEmpty()) {
+            infoBuilder.setClientId(clientId);
+        }
+
+        String nonce = mNonceField.getText().toString().trim();
+        if (!nonce.isEmpty()) {
+            infoBuilder.setNonce(nonce);
+        }
+
+        tokenProviders.put(tokenProviderUriStr, infoBuilder.build());
+        return tokenProviders;
+    }
+}
diff --git a/testapp/res/layout/delete_test_layout.xml b/testapp/res/layout/delete_test_layout.xml
index 7f7e29d..0350b36 100644
--- a/testapp/res/layout/delete_test_layout.xml
+++ b/testapp/res/layout/delete_test_layout.xml
@@ -1,41 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
-      style="@style/Headline"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/request"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/request"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/credential_to_delete"
       android:layout_width="match_parent"
       android:layout_height="match_parent">
     </org.openyolo.testapp.CredentialView>
 
     <Button
       android:id="@+id/delete_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/delete_button_content_description"
       android:text="@string/delete_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/hint_test_layout.xml b/testapp/res/layout/hint_test_layout.xml
index bb08077..bd3a620 100644
--- a/testapp/res/layout/hint_test_layout.xml
+++ b/testapp/res/layout/hint_test_layout.xml
@@ -1,58 +1,69 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
-      style="@style/Headline"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/request"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/request"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="@string/authentication_method_section_title"/>
+        android:text="@string/authentication_method_section_title"
+        android:textAppearance="@style/TextAppearance.AppCompat.Title" />
 
     <org.openyolo.testapp.AuthenticationMethodsInputView
         android:id="@+id/authentication_methods_input"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-    </org.openyolo.testapp.AuthenticationMethodsInputView>
+        android:layout_height="wrap_content" />
+
+    <org.openyolo.testapp.TokenProviderInputView
+        android:id="@+id/token_providers_input"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
 
     <Button
       android:id="@+id/hint_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/hint_button_content_description"
       android:text="@string/hint_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
-      style="@style/Headline"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/response"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/response"
+        android:paddingTop="16dp"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/hint_credential"
       android:layout_width="match_parent"
       android:layout_height="match_parent">
     </org.openyolo.testapp.CredentialView>
 
+    <org.openyolo.testapp.IdTokenView
+        android:id="@+id/id_token_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/id_token_layout.xml b/testapp/res/layout/id_token_layout.xml
new file mode 100644
index 0000000..b2c4990
--- /dev/null
+++ b/testapp/res/layout/id_token_layout.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+  <!-- TODO: parse and display ID token contents -->
+
+  <TextView
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:text="@string/id_token_view_header"
+      android:textAppearance="@style/TextAppearance.AppCompat.Title" />
+
+  <TextView
+      android:id="@+id/raw_token"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/retrieve_test_layout.xml b/testapp/res/layout/retrieve_test_layout.xml
index 83575f6..782cb9c 100644
--- a/testapp/res/layout/retrieve_test_layout.xml
+++ b/testapp/res/layout/retrieve_test_layout.xml
@@ -1,58 +1,71 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
-      style="@style/Headline"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/request"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/request"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
 
     <TextView
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/authentication_method_section_title"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/authentication_method_section_title"
+        android:paddingTop="8dp"
+        android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
 
     <org.openyolo.testapp.AuthenticationMethodsInputView
       android:id="@+id/authentication_methods_input"
       android:layout_width="match_parent"
-      android:layout_height="wrap_content">
-    </org.openyolo.testapp.AuthenticationMethodsInputView>
+      android:layout_height="wrap_content" />
+
+    <org.openyolo.testapp.TokenProviderInputView
+      android:id="@+id/token_providers_input"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content" />
 
     <Button
       android:id="@+id/retrieve_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/retrieve_button_content_description"
       android:text="@string/retrieve_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
-      style="@style/Headline"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/response"/>
+
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingTop="16dp"
+        android:text="@string/response"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/retrieve_credential"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
     </org.openyolo.testapp.CredentialView>
 
+    <org.openyolo.testapp.IdTokenView
+        android:id="@+id/id_token_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/save_test_layout.xml b/testapp/res/layout/save_test_layout.xml
index 75783a0..9e69720 100644
--- a/testapp/res/layout/save_test_layout.xml
+++ b/testapp/res/layout/save_test_layout.xml
@@ -1,41 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
-      style="@style/Headline"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/request"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/request"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/save_credential"
       android:layout_width="match_parent"
       android:layout_height="match_parent">
     </org.openyolo.testapp.CredentialView>
 
     <Button
       android:id="@+id/save_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/save_button_content_description"
       android:text="@string/save_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/token_provider_input_layout.xml b/testapp/res/layout/token_provider_input_layout.xml
new file mode 100644
index 0000000..479ac72
--- /dev/null
+++ b/testapp/res/layout/token_provider_input_layout.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingTop="16dp">
+
+  <TextView
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:text="@string/token_providers_header"
+      android:textAppearance="@style/TextAppearance.AppCompat.Title" />
+
+  <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="8dp"
+      android:orientation="horizontal"
+      tools:ignore="ButtonStyle">
+
+    <Button
+        android:id="@+id/use_google"
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:text="@string/use_google_token_provider"/>
+
+    <Button
+        android:id="@+id/clear_token_provider"
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_gravity="center_horizontal"
+        android:layout_weight="1"
+        android:text="@string/clear_token_provider"/>
+
+  </LinearLayout>
+
+
+  <android.support.design.widget.TextInputLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content">
+
+    <android.support.design.widget.TextInputEditText
+        android:id="@+id/token_provider_uri_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/token_provider_uri_field_hint"/>
+
+  </android.support.design.widget.TextInputLayout>
+
+  <android.support.design.widget.TextInputLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content">
+
+    <android.support.design.widget.TextInputEditText
+        android:id="@+id/client_id_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/client_id_field_hint"/>
+
+  </android.support.design.widget.TextInputLayout>
+
+  <android.support.design.widget.TextInputLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content">
+
+    <android.support.design.widget.TextInputEditText
+        android:id="@+id/nonce_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/nonce_field_hint"/>
+
+  </android.support.design.widget.TextInputLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 02c849a..88b7019 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,87 +1,95 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
     <string name="phone_authentication_method_checkbox_text">openyolo://phone</string>
     <string name="username_authentication_method_checkbox_text">openyolo://username</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="save_result_unkown">Unknown save result</string>
     <string name="save_result_saved">Credential Saved</string>
     <string name="save_result_bad_request">Malformed save request</string>
     <string name="save_result_provider_refused">Provider refused save request</string>
     <string name="save_result_user_canceled">User canceled save request</string>
     <string name="save_result_user_refused">User refused save request</string>
 
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
     <string name="no_available_delete_providers">"No available providers can delete this credential</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
     <string name="delete_result_unknown_response">Unknown delete response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
-    <string name="response">Response</string>
-    <string name="request">Request</string>
+    <string name="response">Response Properties</string>
+    <string name="request">Request Properties</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
+  <string name="token_providers_header">Supported token providers</string>
+    <string name="use_google_token_provider">Request Google ID tokens</string>
+    <string name="token_provider_uri_field_hint">Token provider URI</string>
+    <string name="client_id_field_hint">Client ID</string>
+    <string name="nonce_field_hint">Nonce</string>
+    <string name="clear_token_provider">Clear</string>
+    <string name="no_token">No token returned</string>
+    <string name="id_token_view_header">ID Token</string>
 
 </resources>
diff --git a/testapp/testapp.keystore b/testapp/testapp.keystore
new file mode 100644
index 0000000..a53c0ac
Binary files /dev/null and b/testapp/testapp.keystore differ

commit 4f02f13bf0135cf732d1648e5bdb20b85f79ea79
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Wed May 10 17:03:55 2017 -0700

    Add token provider maps to credential and hint requests

diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 426545e..9c6f6be 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -40,405 +40,415 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a credential for use in sign-in. This provides a higher-level,
  * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
  * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     /**
      * Creates a credential from its protocol buffer equivalent, in byte form.
      * @throws IOException if the protocol buffer cannot be parsed.
      */
     public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
         return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
     }
 
     /**
      * Creates a credential from its protocol buffer equivalent.
      */
     public static Credential fromProtobuf(Protobufs.Credential credential) {
         return new Credential.Builder(credential).build();
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationDomain mAuthDomain;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPicture;
 
     @Nullable
     private final String mPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Credential(
             @NonNull String id,
             @NonNull AuthenticationDomain authDomain,
             @NonNull AuthenticationMethod authMethod,
             @Nullable String displayName,
             @Nullable Uri displayPicture,
             @Nullable String password,
             @Nullable String idToken,
             @NonNull Map<String, ByteString> additionalProps) {
         mId = id;
         mAuthDomain = authDomain;
         mAuthMethod = authMethod;
         mDisplayName = displayName;
         mDisplayPicture = displayPicture;
         mPassword = password;
         mIdToken = idToken;
         mAdditionalProps = additionalProps;
     }
 
     /**
      * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
     public Protobufs.Credential toProtobuf() {
         Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .setAuthDomain(mAuthDomain.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPicture != null) {
             builder.setDisplayPictureUri(mDisplayPicture.toString());
         }
 
         if (mPassword != null) {
             builder.setPassword(mPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
     @NonNull
     public AuthenticationDomain getAuthenticationDomain() {
         return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPicture;
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
         return mPassword;
     }
 
     /**
      * An ID token which provides "proof of access" to the identifier for this credential, if
      * available.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
             mAdditionalProps,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
         private String mId;
         private AuthenticationMethod mAuthMethod;
         private AuthenticationDomain mAuthDomain;
         private String mDisplayName;
         private Uri mDisplayPicture;
         private String mPassword;
         private String mIdToken;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          */
         public Builder(@NonNull Protobufs.Credential proto) {
             // required properties
             setIdentifier(proto.getId());
             setAuthenticationMethod(
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT
                             .convert(proto.getAuthMethod()));
             setAuthenticationDomain(
                     AuthenticationDomainConverters.PROTOBUF_TO_OBJECT
                             .convert(proto.getAuthDomain()));
 
             // optional properties
 
             setDisplayName(proto.getDisplayName());
             setDisplayPicture(proto.getDisplayPictureUri());
             setPassword(proto.getPassword());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             proto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
          * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
                     new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
             require(!TextUtils.isEmpty(identifier), "identifier must not be null or empty");
             mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             require(domain, notNullValue());
             mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
         public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
             require(authMethod, notNullValue());
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
             mPassword = nullifyEmptyString(password);
             return this;
         }
 
+        /**
+         * Specifies the ID token for the credential. If a null or empty value is provided, this
+         * is equivalent to remove the ID token from the credential.
+         */
+        @NonNull
+        public Builder setIdToken(String idToken) {
+            this.mIdToken = nullifyEmptyString(idToken);
+            return this;
+        }
+
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             require(displayPicture, nullOr(isWebUri()));
             mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             if (additionalProps == null) {
                 mAdditionalProps.clear();
                 return this;
             }
 
             require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProps.values(), everyItem(notNullValue()));
 
             mAdditionalProps = CollectionConverter.convertMapValues(
                     additionalProps,
                     ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
             return new Credential(
                     mId,
                     mAuthDomain,
                     mAuthMethod,
                     mDisplayName,
                     mDisplayPicture,
                     mPassword,
                     mIdToken,
                     mAdditionalProps);
         }
     }
 
     private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
                 Protobufs.Credential proto = Protobufs.Credential.parseFrom(encodedBytes);
                 return new Credential.Builder(proto).build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index 69644ae..4ff4631 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -17,4 +17,2 @@ package org.openyolo.protocol;
 import static java.util.Collections.EMPTY_SET;
-import static java.util.Collections.unmodifiableMap;
-import static java.util.Collections.unmodifiableSet;
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -25,3 +23,5 @@ import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.CoreMatchers.nullValue;
+import static org.openyolo.protocol.internal.CustomMatchers.isHttpsUriStr;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.valid4j.Assertive.require;
 import static org.valid4j.Validation.validate;
@@ -35,2 +35,3 @@ import java.io.IOException;
 import java.nio.charset.Charset;
+import java.util.Collections;
 import java.util.HashMap;
@@ -44,292 +45,358 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.NoopValueConverter;
+import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class CredentialRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
             @NonNull Protobufs.CredentialRetrieveRequest proto) {
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
      * @throws IOException if the request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
             throws IOException {
         return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
      * @throws IOException if the intent does not contain a retrieve request, or the contained
      *     request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
             throws IOException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
             throw new IOException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
+    @NonNull
+    private final Map<String, TokenRequestInfo> mTokenProviders;
+
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
-    private CredentialRetrieveRequest(
-            @NonNull Set<AuthenticationMethod> authMethods,
-            @NonNull Map<String, byte[]> additionalParams) {
-        mAuthMethods = authMethods;
-        mAdditionalProps = additionalParams;
+    private CredentialRetrieveRequest(Builder builder) {
+        mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
+        mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalParams);
     }
 
     /**
-     * The set of authentication methods that the requestor supports. This is used to filter the set
+     * The set of authentication methods that the requester supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
+    /**
+     * The set of token providers that the requester supports. These are used by the
+     * credential provider and the OpenYOLO client library to attempt to acquire a "proof of access"
+     * ID token for any returned credential.
+     */
+    @NonNull
+    public Map<String, TokenRequestInfo> getTokenProviders() {
+        return mTokenProviders;
+    }
+
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         if (mAdditionalProps.containsKey(key)) {
             return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         return mAdditionalProps.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
+                .putAllSupportedTokenProviders(
+                        CollectionConverter.convertMapValues(
+                                mTokenProviders,
+                                TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
+        private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
         public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
             validate(requestProto, notNullValue(), IllegalArgumentException.class);
 
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
+
+            setTokenProviders(CollectionConverter.convertMapValues(
+                    requestProto.getSupportedTokenProvidersMap(),
+                    TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
+
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
+        /**
+         * Specifies the token providers supported by the requester, and any token provider
+         * specific information required to acquire usable ID tokens. A null map is treated
+         * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
+         * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
+         * request info message.
+         */
+        public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
+            if (tokenProviders == null) {
+                mTokenProviders.clear();
+                return this;
+            }
+
+            for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
+                addTokenProvider(entry.getKey(), entry.getValue());
+            }
+            return this;
+        }
+
+        /**
+         * Adds a token provider supported by the requester, with the default token request info
+         * message specified.
+         */
+        public Builder addTokenProvider(@NonNull String tokenProviderUri) {
+            addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
+            return this;
+        }
+
+        /**
+         * Adds a token provider supported by the requester, with the specified token request info
+         * message for token retrieval. A null token request info message is treated as equivalent
+         * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
+         */
+        public Builder addTokenProvider(
+                @NonNull String tokenProviderUri,
+                @Nullable TokenRequestInfo info) {
+            require(tokenProviderUri, isHttpsUriStr());
+            if (info == null) {
+                info = TokenRequestInfo.DEFAULT;
+            }
+
+            mTokenProviders.put(tokenProviderUri, info);
+            return this;
+        }
+
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
          * @see CredentialRetrieveRequest#getAdditionalPropertyAsString(String)
          */
         public Builder addAdditionalProperty(
                 @NonNull String name,
                 @NonNull String value) {
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalProperty(String name, byte[] value) {
             validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public CredentialRetrieveRequest build() {
-            return new CredentialRetrieveRequest(
-                    unmodifiableSet(mAuthMethods),
-                    unmodifiableMap(mAdditionalParams));
+            return new CredentialRetrieveRequest(this);
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new CredentialRetrieveRequest.Builder(
                         Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
index e91371d..8748813 100644
--- a/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
@@ -16,6 +16,5 @@ package org.openyolo.protocol;
 
-import static java.util.Collections.unmodifiableMap;
-import static java.util.Collections.unmodifiableSet;
 import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.protocol.internal.CustomMatchers.isHttpsUriStr;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
@@ -27,4 +26,6 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
 import java.io.IOException;
 import java.nio.charset.Charset;
+import java.util.Collections;
 import java.util.HashMap;
@@ -38,316 +39,378 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.NoopValueConverter;
+import org.openyolo.protocol.internal.TokenRequestInfoConverters;
 
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
 public class HintRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRetrieveRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRetrieveRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
+    @NonNull
+    private final Map<String, TokenRequestInfo> mTokenProviders;
+
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
-    private final Map<String, byte[]> mAdditionalProperties;
+    private final Map<String, ByteString> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
     public static HintRetrieveRequest forEmailAndPasswordAccount() {
         return new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws IOException if the hint request could not be decoded.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRetrieveRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws IOException {
         if (hintRequestProtoBytes == null) {
             throw new IOException("Unable to decode hint request from null array");
         }
         return new HintRetrieveRequest.Builder(
                 Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
                 .build();
     }
 
-    private HintRetrieveRequest(
-            @NonNull Set<AuthenticationMethod> authMethods,
-            @NonNull PasswordSpecification passwordSpec,
-            @NonNull Map<String, byte[]> additionalParams) {
-        mAuthMethods = authMethods;
-        mPasswordSpec = passwordSpec;
-        mAdditionalProperties = additionalParams;
+    private HintRetrieveRequest(@NonNull Builder builder) {
+        mAuthMethods = Collections.unmodifiableSet(builder.mAuthMethods);
+        mTokenProviders = Collections.unmodifiableMap(builder.mTokenProviders);
+        mPasswordSpec = builder.mPasswordSpec;
+        mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
+    /**
+     * The token providers supported by the requester, with the per-provider request info
+     * message.
+     */
+    @NonNull
+    public Map<String, TokenRequestInfo> getTokenProviders() {
+        return mTokenProviders;
+    }
+
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        return mAdditionalProperties;
+        return CollectionConverter.convertMapValues(
+                mAdditionalProperties,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8
      * encoded string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         require(key, notNullValue());
         if (mAdditionalProperties.containsKey(key)) {
-            return new String(mAdditionalProperties.get(key), Charset.forName("UTF-8"));
+            return mAdditionalProperties.get(key).toString(Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         require(key, notNullValue());
-        return mAdditionalProperties.get(key);
+        return mAdditionalProperties.get(key).toByteArray();
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
-                .putAllAdditionalProps(
-                    CollectionConverter.convertMapValues(
-                            mAdditionalProperties,
-                            ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
+                .putAllSupportedTokenProviders(
+                        CollectionConverter.convertMapValues(
+                                mTokenProviders,
+                                TokenRequestInfoConverters.OBJECT_TO_PROTOBUF))
+                .putAllAdditionalProps(mAdditionalProperties)
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
-        private Map<String, byte[]> mAdditionalProps = new HashMap<>();
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+        private Map<String, TokenRequestInfo> mTokenProviders = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          *
          * @see HintRetrieveRequest#toProtocolBuffer()
          */
         public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
+            setTokenProviders(CollectionConverter.convertMapValues(
+                    requestProto.getSupportedTokenProvidersMap(),
+                    TokenRequestInfoConverters.PROTOBUF_TO_OBJECT));
             setPasswordSpecification(
                     new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(
                 @NonNull AuthenticationMethod authMethod,
                 @NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
                 @NonNull AuthenticationMethod authMethod,
                 AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             require(authMethods, notNullValue());
             require(!authMethods.contains(null), "every authentication methods must be non-null");
             require(!authMethods.isEmpty(), "At least one authentication method must be specified");
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
             require(authenticationMethod, notNullValue());
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
+        /**
+         * Specifies the token providers supported by the requester, and any token provider
+         * specific information required to acquire usable ID tokens. A null map is treated
+         * as equivalent to an empty map. Keys must be valid https URIs. Null token request info
+         * messages are treated as equivalent to the {@link TokenRequestInfo#DEFAULT default} token
+         * request info message.
+         */
+        public Builder setTokenProviders(@Nullable Map<String, TokenRequestInfo> tokenProviders) {
+            if (tokenProviders == null) {
+                mTokenProviders.clear();
+                return this;
+            }
+
+            for (Map.Entry<String, TokenRequestInfo> entry : tokenProviders.entrySet()) {
+                addTokenProvider(entry.getKey(), entry.getValue());
+            }
+            return this;
+        }
+
+        /**
+         * Adds a token provider supported by the requester, with the default token request info
+         * message specified.
+         */
+        public Builder addTokenProvider(@NonNull String tokenProviderUri) {
+            addTokenProvider(tokenProviderUri, TokenRequestInfo.DEFAULT);
+            return this;
+        }
+
+        /**
+         * Adds a token provider supported by the requester, with the specified token request info
+         * message for token retrieval. A null token request info message is treated as equivalent
+         * to the {@link TokenRequestInfo#DEFAULT default} token request info message.
+         */
+        public Builder addTokenProvider(
+                @NonNull String tokenProviderUri,
+                @Nullable TokenRequestInfo info) {
+            require(tokenProviderUri, isHttpsUriStr());
+            if (info == null) {
+                info = TokenRequestInfo.DEFAULT;
+            }
+
+            mTokenProviders.put(tokenProviderUri, info);
+            return this;
+        }
+
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
-            mAdditionalProps = additionalParams;
+            mAdditionalProps = CollectionConverter.convertMapValues(
+                    additionalParams,
+                    ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request with a string value, that
          * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
          * key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
             require(value, notNullValue());
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request, that will be encoded as
          * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
-            mAdditionalProps.put(name, value);
+            mAdditionalProps.put(name, ByteString.copyFrom(value));
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             require(passwordSpec, notNullValue());
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRetrieveRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRetrieveRequest build() {
-            return new HintRetrieveRequest(
-                    unmodifiableSet(mAuthMethods),
-                    mPasswordSpec,
-                    unmodifiableMap(mAdditionalProps));
+            return new HintRetrieveRequest(this);
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRetrieveRequest> {
         @Override
         public HintRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new HintRetrieveRequest.Builder(
                         Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRetrieveRequest[] newArray(int size) {
             return new HintRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/TokenRequestInfo.java b/protocol/java/org/openyolo/protocol/TokenRequestInfo.java
new file mode 100644
index 0000000..3c87071
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/TokenRequestInfo.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAdditionalProperties;
+import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto;
+import static org.openyolo.protocol.internal.StringUtil.nullifyEmptyString;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.InvalidProtocolBufferException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Optional parameters for an token provider, used for requesting an ID token.
+ */
+public final class TokenRequestInfo {
+
+    /**
+     * A default token request info message, containing no defined properties.
+     */
+    public static final TokenRequestInfo DEFAULT =
+            new TokenRequestInfo.Builder().build();
+
+    /**
+     * Creates a {@link TokenRequestInfo} from its protocol buffer equivalent.
+     * @throws MalformedDataException if the protocol buffer could not be parsed or validated.
+     */
+    public static TokenRequestInfo fromProtobuf(
+            @NonNull Protobufs.TokenRequestInfo proto)
+            throws MalformedDataException {
+        try {
+            return new TokenRequestInfo.Builder(proto).build();
+        } catch (RequireViolation ex) {
+            throw new MalformedDataException("Token request info contains invalid data", ex);
+        }
+    }
+
+    /**
+     * Creates a {@link TokenRequestInfo} from its protocol buffer byte array equivalent.
+     * @throws MalformedDataException if the protocol buffer could not be parsed or validated.
+     */
+    public static TokenRequestInfo fromProtobufBytes(@NonNull byte[] protoBytes)
+            throws MalformedDataException {
+        try {
+            return fromProtobuf(Protobufs.TokenRequestInfo.parseFrom(protoBytes));
+        } catch (InvalidProtocolBufferException ex) {
+            throw new MalformedDataException("Unable to parse token request info proto", ex);
+        }
+    }
+
+    @Nullable
+    private final String mClientId;
+
+    @Nullable
+    private final String mNonce;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProps;
+
+    private TokenRequestInfo(Builder builder) {
+        mClientId = builder.mClientId;
+        mNonce = builder.mNonce;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
+    }
+
+    /**
+     * An optional client ID, used to identify the current application for the purposes of
+     * ID token retrieval and generation. Where accepted by the token provider, this should
+     * be used as the audience ("aud" claim) in returned ID token.
+     */
+    @Nullable
+    public String getClientId() {
+        return mClientId;
+    }
+
+    /**
+     * An optional nonce, used to protect against ID token replay attacks. Where accepted
+     * by the token provider, this should appear as the nonce claim in the ID token.
+     */
+    @Nullable
+    public String getNonce() {
+        return mNonce;
+    }
+
+    /**
+     * A map of additional, non-standard properties for transmission to the token provider.
+     */
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Converts the request into its protocol buffer equivalent, for storage or transmission.
+     */
+    public Protobufs.TokenRequestInfo toProtobuf() {
+        Protobufs.TokenRequestInfo.Builder builder = Protobufs.TokenRequestInfo.newBuilder();
+
+        if (mClientId != null) {
+            builder.setClientId(mClientId);
+        }
+
+        if (mNonce != null) {
+            builder.setNonce(mNonce);
+        }
+
+        builder.putAllAdditionalProps(mAdditionalProps);
+        return builder.build();
+    }
+
+    /**
+     * Creates instances of {@link TokenRequestInfo}.
+     */
+    public static final class Builder {
+
+        private String mClientId;
+        private String mNonce;
+        private Map<String, ByteString> mAdditionalProps;
+
+        /**
+         * Starts the process of describing a token request information message, to pass to
+         * a token provider.
+         */
+        public Builder() {
+            mAdditionalProps = new HashMap<>();
+        }
+
+        /**
+         * Starts the process of describing a token request information message, using
+         * the data stored within the provided protocol buffer equivalent.
+         */
+        public Builder(Protobufs.TokenRequestInfo proto) {
+            mClientId = nullifyEmptyString(proto.getClientId());
+            mNonce = nullifyEmptyString(proto.getNonce());
+            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        }
+
+        /**
+         * Specifies the client ID to pass to the token provider. Empty values are treated
+         * as equivalent to null.
+         */
+        public Builder setClientId(@Nullable String clientId) {
+            mClientId = nullifyEmptyString(clientId);
+            return this;
+        }
+
+        /**
+         * Specifies the nonce value to pass to the token provider. Empty values are treated
+         * as equivalent to null.
+         */
+        public Builder setNonce(@Nullable String nonce) {
+            mNonce = nullifyEmptyString(nonce);
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to pass to the token
+         * provider. A null map is treated as equivalent to an empty map. The map must
+         * not contain null keys or null values, and must not contain an empty key.
+         */
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
+            mAdditionalProps = validateAdditionalProperties(additionalProps);
+            return this;
+        }
+
+        private Builder setAdditionalPropertiesFromProto(
+                @NonNull Map<String, ByteString> additionalProps) {
+            mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProps);
+            return this;
+        }
+
+        /**
+         * Creates a {@link TokenRequestInfo} instance using the properties described
+         * to the builder.
+         */
+        public TokenRequestInfo build() {
+            return new TokenRequestInfo(this);
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java b/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
index 061be75..d380504 100644
--- a/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
+++ b/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
@@ -28,188 +28,198 @@ import org.hamcrest.Matcher;
 /**
  * Convenient hamcrest-based input validators.
  */
 public final class CustomMatchers {
 
     /**
      * Matcher for web URIs (http or https).
      */
     public static Matcher<Uri> isWebUri() {
         return UriMatcher.WEB_MATCHER;
     }
 
     /**
      * Matcher for HTTPS web URIs.
      */
     public static Matcher<Uri> isHttpsUri() {
         return UriMatcher.HTTPS_ONLY_MATCHER;
     }
 
+    /**
+     * Matcher for HTTPS web URIs, in string form.
+     */
+    public static Matcher<String> isHttpsUriStr() {
+        return StringUriMatcher.HTTPS_URI_STR;
+    }
+
     /**
      * Matcher for OpenYOLO authentication methods, in string form.
      */
     public static Matcher<String> isValidAuthenticationMethod() {
         return StringUriMatcher.AUTHENTICATION_METHOD_STR;
     }
 
     /**
      * Matcher for OpenYOLO authentication methods, in parsed Uri form.
      */
     public static Matcher<Uri> isValidAuthenticationMethodUri() {
         return UriMatcher.AUTHENTICATION_METHOD;
     }
 
     /**
      * Matcher for OpenYOLO authentication domains, in string form.
      */
     public static Matcher<String> isValidAuthenticationDomain() {
         return StringUriMatcher.AUTHENTICATION_DOMAIN_STR;
     }
 
     /**
      * Matcher for OpenYOLO authentication domains, in parsed Uri form.
      */
     public static Matcher<Uri> isValidAuthenticationDomainUri() {
         return UriMatcher.AUTHENTICATION_DOMAIN;
     }
 
     /**
      * Matcher for null values, or those which match the provided matcher.
      */
     public static <T> Matcher<T> nullOr(Matcher<T> matcher) {
         return new NullOrOtherMatcher<>(matcher);
     }
 
     /**
      * Matcher which only accepts non-null, non-empty strings.
      */
     public static Matcher<String> notNullOrEmptyString() {
         return NotNullOrEmptyStringMatcher.INSTANCE;
     }
 
     private static final class NotNullOrEmptyStringMatcher extends BaseMatcher<String> {
 
         private static final NotNullOrEmptyStringMatcher INSTANCE =
                 new NotNullOrEmptyStringMatcher();
 
         @Override
         public boolean matches(Object item) {
             if (item == null) {
                 return false;
             }
 
             if (!(item instanceof String)) {
                 return false;
             }
 
             return !TextUtils.isEmpty((String)item);
         }
 
         @Override
         public void describeTo(Description description) {
             description.appendText("is not a null or empty string");
         }
     }
 
     private static final class NullOrOtherMatcher<T> extends BaseMatcher<T> {
 
         final Matcher<T> mMatcher;
 
         NullOrOtherMatcher(Matcher<T> matcher) {
             mMatcher = matcher;
         }
 
         @Override
         public boolean matches(Object item) {
             return item == null || mMatcher.matches(item);
         }
 
         @Override
         public void describeTo(Description description) {
             description.appendText("null or ").appendDescriptionOf(mMatcher);
         }
     }
 
     private static final class StringUriMatcher extends CustomTypeSafeMatcher<String> {
 
+        static final StringUriMatcher HTTPS_URI_STR =
+                new StringUriMatcher(UriMatcher.HTTPS_ONLY_MATCHER);
+
         static final StringUriMatcher AUTHENTICATION_DOMAIN_STR =
                 new StringUriMatcher(UriMatcher.AUTHENTICATION_DOMAIN);
 
         static final StringUriMatcher AUTHENTICATION_METHOD_STR =
                 new StringUriMatcher(UriMatcher.AUTHENTICATION_METHOD);
 
         private final UriMatcher mUriMatcher;
 
         StringUriMatcher(UriMatcher matcher) {
             super(matcher.mUriDescriptor);
             mUriMatcher = matcher;
         }
 
         @Override
         protected boolean matchesSafely(String item) {
             Uri uri = Uri.parse(item);
             return mUriMatcher.matchesSafely(uri);
         }
     }
 
     private static final class UriMatcher extends CustomTypeSafeMatcher<Uri> {
 
         static final String SCHEME_HTTP = "http";
         static final String SCHEME_HTTPS = "https";
 
         static final UriMatcher AUTHENTICATION_DOMAIN = new UriMatcher(
                 Collections.<String>emptySet(),
                 false,
                 "an authentication domain");
 
         static final UriMatcher AUTHENTICATION_METHOD = new UriMatcher(
                 Collections.<String>emptySet(),
                 false,
                 "an authentication method");
 
         static final UriMatcher HTTPS_ONLY_MATCHER = new UriMatcher(
                 Collections.singleton(SCHEME_HTTPS),
                 true,
                 "an https URL");
 
         static final UriMatcher WEB_MATCHER = new UriMatcher(
                 new HashSet<>(Arrays.asList(SCHEME_HTTP, SCHEME_HTTPS)),
                 true,
                 "a web URL");
 
         final Set<String> mPermittedSchemes;
         final boolean mAllowPathQueryOrFragment;
         final String mUriDescriptor;
 
         UriMatcher(
                 Set<String> permittedSchemes,
                 boolean allowPathQueryOrFragment,
                 String uriDescriptor) {
             super(uriDescriptor);
             mPermittedSchemes = permittedSchemes;
             mAllowPathQueryOrFragment = allowPathQueryOrFragment;
             mUriDescriptor = uriDescriptor;
         }
 
         @Override
         protected boolean matchesSafely(Uri item) {
             if (!item.isAbsolute()
                     || !item.isHierarchical()
                     || TextUtils.isEmpty(item.getScheme())
                     || TextUtils.isEmpty(item.getAuthority())) {
                 return false;
             }
 
             if (!mPermittedSchemes.isEmpty() && !mPermittedSchemes.contains(item.getScheme())) {
                 return false;
             }
 
             if (mAllowPathQueryOrFragment) {
                 return true;
             }
 
             return TextUtils.isEmpty(item.getPath())
                     && item.getQuery() == null
                     && item.getFragment() == null;
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java b/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java
new file mode 100644
index 0000000..aeb2368
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/TokenRequestInfoConverters.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.TokenRequestInfo;
+
+/**
+ * ValueConverters for {@link TokenRequestInfo}.
+ */
+public final class TokenRequestInfoConverters {
+
+    /**
+     * Converts token request info protocol buffers into their validated, public API form.
+     */
+    public static final ValueConverter<Protobufs.TokenRequestInfo, TokenRequestInfo>
+            PROTOBUF_TO_OBJECT = new ProtobufToObjectConverter();
+
+    /**
+     * Converts token request info values into their protocol buffer equivalent.
+     */
+    public static final ValueConverter<TokenRequestInfo, Protobufs.TokenRequestInfo>
+            OBJECT_TO_PROTOBUF = new ObjectToProtobufConverter();
+
+    private TokenRequestInfoConverters() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+
+    private static final class ProtobufToObjectConverter
+            implements ValueConverter<Protobufs.TokenRequestInfo, TokenRequestInfo> {
+        @Override
+        public TokenRequestInfo convert(Protobufs.TokenRequestInfo proto) {
+            return new TokenRequestInfo.Builder(proto).build();
+        }
+    }
+
+    private static final class ObjectToProtobufConverter
+            implements ValueConverter<TokenRequestInfo, Protobufs.TokenRequestInfo> {
+        @Override
+        public Protobufs.TokenRequestInfo convert(TokenRequestInfo value) {
+            return value.toProtobuf();
+        }
+    }
+
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 222e34d..1e3da45 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -27,3 +27,2 @@ import java.util.Map;
 import java.util.Set;
-import org.junit.Before;
 import org.junit.Test;
@@ -33,128 +32,114 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
 
 /**
- * Battery of tests for CredentialRetrieveRequest
+ * Tests for {@link CredentialRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialRetrieveRequestTest {
 
-    private static final byte[] testBytes = new byte[]
-            {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    @Test
+    public void build_validInputs_shouldSucceed() {
+        CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setTokenProviders(TestConstants.createTokenProviderMap())
+                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .build();
 
-    private CredentialRetrieveRequest request;
+        assertThat(request.getAuthenticationMethods()).hasSize(1);
+        assertThat(request.getAuthenticationMethods()).contains(AuthenticationMethods.EMAIL);
+        TestConstants.checkTokenProviderMap(request.getTokenProviders());
+        TestConstants.checkAdditionalProps(request.getAdditionalProperties());
+    }
 
-    @Before
-    public void setUp() {
-        request = new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAdditionalProperty("a", "b")
-                .addAdditionalProperty("c", testBytes)
-                .build();
+    @Test(expected = IllegalArgumentException.class)
+    public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
+        new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
+        new CredentialRetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
     }
 
     @Test
     public void testWriteAndRead() {
+        CredentialRetrieveRequest request = new CredentialRetrieveRequest.Builder(
+                AuthenticationMethods.EMAIL)
+                .setTokenProviders(TestConstants.createTokenProviderMap())
+                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
+                .build();
+
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
-            assertMapsEqual(
-                    deserialized.getAdditionalProperties(),
-                    request.getAdditionalProperties());
+            TestConstants.checkTokenProviderMap(deserialized.getTokenProviders());
+            TestConstants.checkAdditionalProps(deserialized.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
-        new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
-        new CredentialRetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
-    }
-
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         CredentialRetrieveRequest request = CredentialRetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
-    @Test
-    public void testGetAdditionalProperties() {
-        assertThat(request.getAdditionalProperties()).isNotNull();
-        assertThat(request.getAdditionalProperties()).hasSize(2);
-        assertThat(request.getAdditionalPropertyAsString("a")).isEqualTo("b");
-        assertThat(request.getAdditionalProperty("c")).isEqualTo(testBytes);
-    }
-
-    @Test
-    public void testGetAuthMethods() {
-        assertThat(request.getAuthenticationMethods()).hasSize(1);
-        assertThat(request.getAuthenticationMethods())
-                .containsOnly(AuthenticationMethods.EMAIL);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testAdapter_nullArray() throws IOException {
-        Protobufs.CredentialRetrieveRequest.parseFrom((byte[]) null);
-    }
-
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 83bd4a0..1fdc44e 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -30,248 +30,275 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     public static final String EMAIL_ID = "alice@example.com";
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
+    public void builderSetIdToken_validInput_shouldSucceed() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setIdToken(TestConstants.ALICE_ID_TOKEN)
+                .build();
+
+        assertThat(cr.getIdToken()).isEqualTo(TestConstants.ALICE_ID_TOKEN);
+    }
+
+    @Test
+    public void builderSetIdToken_nullValue_shouldSucceed() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setIdToken(null)
+                .build();
+
+        assertThat(cr.getIdToken()).isNull();
+    }
+
+    @Test
+    public void builderSetIdToken_emptyValue_shouldSucceed() {
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
+                .setIdToken("")
+                .build();
+
+        assertThat(cr.getIdToken()).isNull();
+    }
+
+        @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index 000b518..f08aff8 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -32,290 +32,286 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
-                .addAdditionalProperty("a", new byte[] { 1, 2, 3})
-                .addAdditionalProperty("b", "hello")
+                .setTokenProviders(TestConstants.createTokenProviderMap())
                 .setPasswordSpecification(originalSpec)
+                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
-
-        assertThat(request.getAdditionalProperties())
-                .containsOnly(
-                        entry("a", new byte[] {1, 2, 3}),
-                        entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
+        TestConstants.checkTokenProviderMap(request.getTokenProviders());
+        TestConstants.checkAdditionalProps(request.getAdditionalProperties());
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
-
-        assertThat(request.getAdditionalProperty("a")).isEqualTo(new byte[] {1, 2, 3});
-        assertThat(request.getAdditionalPropertyAsString("b")).isEqualTo("hello");
-
-        assertThat(request.getAdditionalProperty("c")).isNull();
-        assertThat(request.getAdditionalPropertyAsString("d")).isNull();
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testForEmailAndPasswordAccount() {
         HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
             HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
         HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
+                .setTokenProviders(TestConstants.createTokenProviderMap())
+                .setAdditionalProperties(TestConstants.ADDITIONAL_PROPS)
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
+
+            TestConstants.checkTokenProviderMap(read.getTokenProviders());
+            TestConstants.checkAdditionalProps(read.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullRequestProto() {
         new HintRetrieveRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_emptySet() {
         new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullMap() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(null)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullKey() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty(null, "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_emptyKey() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("", "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullByteArrayValue() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (byte[]) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullStringValue() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/TestConstants.java b/protocol/javatests/org/openyolo/protocol/TestConstants.java
index 32dadb5..e2e0e77 100644
--- a/protocol/javatests/org/openyolo/protocol/TestConstants.java
+++ b/protocol/javatests/org/openyolo/protocol/TestConstants.java
@@ -18,2 +18,5 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
+import android.content.pm.Signature;
+import android.net.Uri;
+import android.util.Base64;
 import com.google.protobuf.ByteString;
@@ -25,28 +28,185 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Useful constants and associated verification methods for tests.
  */
 public final class TestConstants {
 
+    public static final String ALICE_EMAIL = "alice@example.com";
+    public static final String ALICE_NAME = "Alice McTesterson";
+    public static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://robohash.org/alice";
+    public static final Uri ALICE_DISPLAY_PICTURE_URI =
+            Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
+    public static final String ALICE_PASSWORD = "CorrectH0rseBatteryStapl3";
+
+    public static final String ALICE_ID_TOKEN =
+            "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSIsImF1ZCI"
+                    + "6IlhZWi5jbGllbnQuaWQiLCJpc3MiOiJpZHAuZXhhbXBsZS5jb20iLCJlbWFpbCI"
+                    + "6ImFsaWNlQGV4YW1wbGUuY29tIiwibmFtZSI6IkFsaWNlIE1jVGVzdGVyc29uIiw"
+                    + "icGljdHVyZSI6Imh0dHBzOi8vcm9ib2hhc2gub3JnL2FsaWNlIn0.2-D7AZ1C7mv"
+                    + "dLRf6Q7aqH8Ah4rlK1uuHPSU2HPImtyk";
+
+    public static final String CLIENT_ID = "XYZ.client.id";
+    public static final String NONCE = "asdf";
+
+    public static final String EXAMPLE_APP_PACKAGE_NAME = "com.example.app";
+
+    public static final byte[] EXAMPLE_APP_SIGNATURE_BYTES =
+            Base64.decode(
+                    "MIICwzCCAaugAwIBAgIEYUHE8DANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDEwd0"
+                    + "ZXN0aW5nMB4XDTE3MDUxMDIxMTY1M1oXDTQ0MDkyNTIxMTY1M1owEjEQMA4GA1UE"
+                    + "AxMHdGVzdGluZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ2+5bxE"
+                    + "24gsczcfwoAgJrerBGgew5rHiUYekp6nlfOlqQqJbC5KNKOr8qK1IF92MSrcphIw"
+                    + "CWWkp67Bqqe49nK3ce9kVHqhXjaz9w4HVex3N3kWt1r7s08lNax/67vTrfQXlDnI"
+                    + "1VDijm82vklmLtcXXnww10FQRKVdtxSkCmtUjmuYpLqFZY5cDIG5fpoeFhzoDolj"
+                    + "pfmYkDsFGEUVOIilrM70rdwziEuvXPVGIzI8Lz88OkdamtQ2dtWSFP+4O8tv6qSW"
+                    + "Q00/YAIm/RV2Z3NFIPma1n7GmTqm+QBM4lq8Irc24yL/a78nVT+fibfBOr7Iu02Z"
+                    + "qy4Rpkosq4bfgt8CAwEAAaMhMB8wHQYDVR0OBBYEFJXEQr/2vuy2E2o2lz8LRbZW"
+                    + "b/QzMA0GCSqGSIb3DQEBCwUAA4IBAQB5N++YqygWTFDwfCGgBT3pytaKVGbSujvB"
+                    + "ChmBry2kfT5SpZcMerTboxq+0Jny50jS+2FAl0apKYC56R+FZC3Zg1qUBlqcCOrZ"
+                    + "j2r7INQHWfiZo76zBjsaf9iDJwwDHKox5Bu8TK0Iux4hPi3J0hWg+MXDq6GUHQPT"
+                    + "aFfxVAPNjnu+BnMrdw3YwEGxUBNTm0BeJruF2Hvzt9s/HOJ4y70dhlnz3McrxSQ2"
+                    + "Tmlo1G0YwaTDO3jYDtD7CJ2V9EdAr9HjUeIlOiHwSHxDZexRxsiJf9rADP3Mqh7r"
+                    + "I+gmzIbXs+UA7nsHXVgTyg5NviDbmYcu/hqKOLf1UeMwAEjQu0U9",
+                    Base64.NO_PADDING);
+
+    public static final Signature EXAMPLE_APP_SIGNATURE =
+            new Signature(EXAMPLE_APP_SIGNATURE_BYTES);
+
+    public static final String EXAMPLE_APP_SHA256_FINGERPRINT =
+            "uHq8C9rrDcJ_MqkyeauSba4OYMSOJJqUDWEuMWiOdfo=";
+
+    public static final String EXAMPLE_APP_SHA512_FINGERPRINT =
+            "KSYmxK5qmKUKhNxHJYv__Tgg8nFXkm_w7mhJd_feckMW"
+                    + "NqBXGK7yhZugh4OVI5ffJn8_V4SEN-mqetuIqiqPVA==";
+
+    public static final AuthenticationDomain EXAMPLE_APP_AUTH_DOMAIN =
+            AuthenticationDomain.createAndroidAuthDomain(
+                    EXAMPLE_APP_PACKAGE_NAME,
+                    EXAMPLE_APP_SIGNATURE);
+
+    public static final String TOKEN_PROVIDER_1 = "https://idp1.example.com";
+    public static final String TOKEN_PROVIDER_2 = "https://idp2.example.com";
+
     public static final String ADDITIONAL_KEY = "extra";
     public static final byte[] ADDITIONAL_VALUE = "value".getBytes();
     public static final Map<String, byte[]> ADDITIONAL_PROPS;
+    public static final Map<String, ByteString> ADDITIONAL_PROPS_FOR_PROTO;
+
+    public static final byte[] INVALID_PROTO_BYTES = new byte[] { 1, 2, 3 };
 
     static {
         Map<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
         ADDITIONAL_PROPS = additionalProps;
+        ADDITIONAL_PROPS_FOR_PROTO = CollectionConverter.convertMapValues(
+                additionalProps,
+                ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
     }
 
     public static void checkAdditionalProps(Map<String, byte[]> additionalProps) {
         assertThat(additionalProps).isNotNull();
         assertThat(additionalProps).hasSize(1);
         assertThat(additionalProps).containsKey(ADDITIONAL_KEY);
         assertThat(additionalProps.get(ADDITIONAL_KEY)).isEqualTo(ADDITIONAL_VALUE);
     }
 
     public static void checkAdditionalPropsFromProto(Map<String, ByteString> additionalProps) {
         checkAdditionalProps(CollectionConverter.convertMapValues(
                 additionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
     }
+
+    public static TokenRequestInfo createTokenRequestInfo() {
+        return new TokenRequestInfo.Builder()
+                .setClientId(CLIENT_ID)
+                .setNonce(NONCE)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build();
+    }
+
+    public static Protobufs.TokenRequestInfo createTokenRequestInfoProto() {
+        return Protobufs.TokenRequestInfo.newBuilder()
+                .setClientId(CLIENT_ID)
+                .setNonce(NONCE)
+                .putAllAdditionalProps(ADDITIONAL_PROPS_FOR_PROTO)
+                .build();
+    }
+
+    public static void checkTokenRequestInfo(TokenRequestInfo info) {
+        assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
+        assertThat(info.getNonce()).isEqualTo(NONCE);
+        TestConstants.checkAdditionalProps(info.getAdditionalProperties());
+    }
+
+    public static void checkTokenRequestInfoProto(Protobufs.TokenRequestInfo info) {
+        assertThat(info.getClientId()).isEqualTo(CLIENT_ID);
+        assertThat(info.getNonce()).isEqualTo(NONCE);
+        TestConstants.checkAdditionalPropsFromProto(info.getAdditionalPropsMap());
+    }
+
+    public static Map<String, TokenRequestInfo> createTokenProviderMap() {
+        HashMap<String, TokenRequestInfo> tokenProviders = new HashMap<>();
+        tokenProviders.put(TOKEN_PROVIDER_1, createTokenRequestInfo());
+        tokenProviders.put(TOKEN_PROVIDER_2, null);
+        return tokenProviders;
+    }
+
+    public static void checkTokenProviderMap(Map<String, TokenRequestInfo> tokenProviders) {
+        assertThat(tokenProviders).hasSize(2);
+        assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_1);
+        assertThat(tokenProviders).containsKey(TOKEN_PROVIDER_2);
+        checkTokenRequestInfo(tokenProviders.get(TOKEN_PROVIDER_1));
+        assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getClientId()).isNull();
+        assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getNonce()).isNull();
+        assertThat(tokenProviders.get(TOKEN_PROVIDER_2).getAdditionalProperties()).isEmpty();
+    }
+
+    public static Credential createEmailCredential() {
+        return new Credential.Builder(
+                ALICE_EMAIL,
+                AuthenticationMethods.EMAIL,
+                EXAMPLE_APP_AUTH_DOMAIN)
+                .setDisplayName(ALICE_NAME)
+                .setDisplayPicture(ALICE_DISPLAY_PICTURE_URI)
+                .setPassword(ALICE_PASSWORD)
+                .setIdentifier(ALICE_ID_TOKEN)
+                .setIdToken(ALICE_ID_TOKEN)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build();
+    }
+
+    public static Protobufs.Credential createEmailCredentialProto() {
+        return Protobufs.Credential.newBuilder()
+                .setId(ALICE_EMAIL)
+                .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
+                .setAuthDomain(EXAMPLE_APP_AUTH_DOMAIN.toProtobuf())
+                .setDisplayName(ALICE_NAME)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
+                .setPassword(ALICE_PASSWORD)
+                .setIdToken(ALICE_ID_TOKEN)
+                .putAllAdditionalProps(ADDITIONAL_PROPS_FOR_PROTO)
+                .build();
+    }
+
+    public static void checkEmailCredential(Credential credential) {
+        assertThat(credential.getIdentifier()).isEqualTo(ALICE_EMAIL);
+        assertThat(credential.getAuthenticationMethod())
+                .isEqualTo(AuthenticationMethods.EMAIL);
+        assertThat(credential.getAuthenticationDomain()).isEqualTo(EXAMPLE_APP_AUTH_DOMAIN);
+        assertThat(credential.getDisplayName()).isEqualTo(ALICE_NAME);
+        assertThat(credential.getDisplayPicture()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+        assertThat(credential.getPassword()).isEqualTo(ALICE_PASSWORD);
+        assertThat(credential.getIdToken()).isEqualTo(ALICE_ID_TOKEN);
+    }
+
+    public static void checkEmailCredentialProto(Protobufs.Credential proto) {
+        assertThat(proto.getId()).isEqualTo(ALICE_EMAIL);
+        assertThat(proto.getAuthMethod().getUri())
+                .isEqualTo(AuthenticationMethods.EMAIL.toString());
+        assertThat(proto.getAuthDomain().getUri())
+                .isEqualTo(EXAMPLE_APP_AUTH_DOMAIN.toString());
+        assertThat(proto.getDisplayName()).isEqualTo(ALICE_NAME);
+        assertThat(proto.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
+        assertThat(proto.getIdToken()).isEqualTo(ALICE_ID_TOKEN);
+        checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
+    }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java b/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java
new file mode 100644
index 0000000..11b5255
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/TokenRequestInfoTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Tests for {@link TokenRequestInfo}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class TokenRequestInfoTest {
+
+    @Test
+    public void build_validInputs_shouldSucceed() {
+        TokenRequestInfo info = TestConstants.createTokenRequestInfo();
+        TestConstants.checkTokenRequestInfo(info);
+
+    }
+
+    @Test
+    public void builderSetClientId_nullValue_shouldSucceed() {
+        TokenRequestInfo info = new TokenRequestInfo.Builder()
+                .setClientId(null)
+                .build();
+
+        assertThat(info.getClientId()).isNull();
+    }
+
+    @Test
+    public void builderSetClientId_emptyValue_treatedAsNull() {
+        TokenRequestInfo info = new TokenRequestInfo.Builder()
+                .setClientId("")
+                .build();
+
+        assertThat(info.getClientId()).isNull();
+    }
+
+    @Test
+    public void builderSetNonce_nullValue_shouldSucceed() {
+        TokenRequestInfo info = new TokenRequestInfo.Builder()
+                .setNonce(null)
+                .build();
+
+        assertThat(info.getNonce()).isNull();
+    }
+
+    @Test
+    public void builderSetNonce_emptyValue_treatedAsNull() {
+        TokenRequestInfo info = new TokenRequestInfo.Builder()
+                .setNonce("")
+                .build();
+
+        assertThat(info.getNonce()).isNull();
+    }
+
+    @Test
+    public void fromProto_validInput_shouldSucceed() throws MalformedDataException {
+        Protobufs.TokenRequestInfo proto = TestConstants.createTokenRequestInfoProto();
+        TokenRequestInfo info = TokenRequestInfo.fromProtobuf(proto);
+        TestConstants.checkTokenRequestInfo(info);
+    }
+
+    @Test
+    public void fromProto_defaultInstance_shouldSucceed() throws MalformedDataException {
+        Protobufs.TokenRequestInfo proto = Protobufs.TokenRequestInfo.getDefaultInstance();
+
+        TokenRequestInfo info = TokenRequestInfo.fromProtobuf(proto);
+        assertThat(info.getClientId()).isNull();
+        assertThat(info.getNonce()).isNull();
+        assertThat(info.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtoBytes_invalidData_shouldThrowException() throws Exception {
+        TokenRequestInfo.fromProtobufBytes(TestConstants.INVALID_PROTO_BYTES);
+    }
+
+    @Test
+    public void toProto_validInput_shouldSucceed() {
+        TokenRequestInfo info = TestConstants.createTokenRequestInfo();
+        TestConstants.checkTokenRequestInfoProto(info.toProtobuf());
+    }
+}

commit 1f9e00031b2c7185fe7009715d7dbfae8b69d452
Author: Iain McGinniss <iainmcgin@gmail.com>
Date:   Wed May 10 08:53:52 2017 -0700

    Implementation of delete in Barbican (#46)
    
    This restructures the credential store in Barbican to hold each
    credential in a separate file, with a name derived from the
    authentication domain, authentication method and identifier. This
    allows for credential deletion without knowing the crypto key.

diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
index 82b33d4..4df4d76 100644
--- a/demoproviders/barbican/AndroidManifest.xml
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -1,146 +1,156 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="org.openyolo.demoprovider.barbican">
 
     <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name_short"
         android:supportsRtl="false"
         android:theme="@style/AppTheme"
         android:name=".Application">
 
         <activity
             android:name=".LaunchActivity"
             android:label="@string/app_name_short"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateHidden"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data
                     android:host="barbican.openyolo.org"
                     android:scheme="https" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".WelcomeActivity"
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".UnlockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".LockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="false" />
 
         <activity
             android:name=".CredentialListActivity"
             android:label="Stored Credentials"
             android:theme="@style/AppTheme"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity
             android:name=".CreateCredentialActivity"
             android:theme="@style/AppTheme"
             android:label="@string/create_credential_activity_label"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity android:name=".provider.RetrieveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.credential.retrieve"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.credential.save"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".provider.HintPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="true">
             <intent-filter>
                 <action android:name="org.openyolo.hint"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialConfirmationActivity"
                   android:theme="@style/AppTheme.Dialog"
                   android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveAfterUnlockActivity"
                   android:theme="@style/AppTheme.NoUi"
                   android:excludeFromRecents="true" />
 
         <activity
             android:name=".provider.AutoSignInActivity"
             android:theme="@style/AutoSignInTheme"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".provider.CredentialPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="false" />
 
+        <activity android:name=".provider.DeleteCredentialActivity"
+            android:theme="@style/AppTheme.Dialog"
+            android:exported="true"
+            android:excludeFromRecents="true">
+            <intent-filter>
+                <action android:name="org.openyolo.credential.delete"/>
+                <category android:name="org.openyolo" />
+            </intent-filter>
+        </activity>
+
         <activity
             android:name=".NeverSaveListActivity"
-            android:theme="@style/AppTheme"/>
+            android:theme="@style/AppTheme"
             android:exported="false" />
 
         <service
             android:name=".storage.CredentialStorageService"
             android:label="@string/credential_storage_service_label"
             android:enabled="true"
             android:exported="false"
             android:permission="org.openyolo.demoprovider.STORAGE"/>
 
         <receiver
             android:name=".provider.CredentialQueryReceiver"
             android:exported="true"
             android:enabled="true"
             tools:ignore="ExportedReceiver">
             <intent-filter>
                 <action android:name="org.openyolo.credential" />
                 <category android:name="com.google.bbq.QUERY" />
             </intent-filter>
         </receiver>
     </application>
 </manifest>
diff --git a/demoproviders/barbican/build.gradle b/demoproviders/barbican/build.gradle
index b658c07..5b56c32 100644
--- a/demoproviders/barbican/build.gradle
+++ b/demoproviders/barbican/build.gradle
@@ -22,18 +22,18 @@ android {
 dependencies {
     compile project(':spi')
     compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
     compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
     compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     compile "com.android.support:design:${rootProject.supportLibVersion}"
     compile "com.android.support:recyclerview-v7:${rootProject.supportLibVersion}"
     compile 'com.madgag.spongycastle:core:1.54.0.0'
-    compile 'com.google.guava:guava:20.0'
+    compile 'com.google.guava:guava:22.0-rc1-android'
 
     compile 'com.jakewharton:butterknife:8.5.1'
     compile 'com.github.bumptech.glide:glide:3.7.0'
     apt 'com.jakewharton:butterknife-compiler:8.5.1'
 
     apply from: "${rootDir}/config/testdeps.gradle", to:it
     testCompile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
-    testCompile 'com.google.guava:guava:20.0'
+    testCompile 'com.google.guava:guava:22.0-rc1-android'
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java
new file mode 100644
index 0000000..ab7199b
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CallerUtil.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.support.annotation.NonNull;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.openyolo.protocol.AuthenticationDomain;
+
+/**
+ * Extracts information on the caller of an activity.
+ */
+public final class CallerUtil {
+
+    /**
+     * Extracts the set of authentication domains for the caller of the provided activity.
+     */
+    @NonNull
+    public static Set<AuthenticationDomain> extractCallerAuthDomains(@NonNull Activity activity) {
+        ComponentName callingActivity = activity.getCallingActivity();
+        if (callingActivity == null) {
+            return Collections.emptySet();
+        }
+
+        String callingPackage = callingActivity.getPackageName();
+        return new HashSet<>(AuthenticationDomain.listForPackage(activity, callingPackage));
+    }
+
+    /**
+     * Determines the human-readable name of the caller of the provided activity.
+     */
+    public static String getCallingAppName(@NonNull Activity activity) {
+        try {
+            PackageManager pm = activity.getPackageManager();
+            ApplicationInfo info = pm.getApplicationInfo(activity.getCallingPackage(), 0);
+            return pm.getApplicationLabel(info).toString();
+        } catch (PackageManager.NameNotFoundException e) {
+            return "???";
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java
new file mode 100644
index 0000000..7ce7ca3
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/DeleteCredentialActivity.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.UiThread;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.WindowManager.LayoutParams;
+import android.widget.Button;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import java.io.IOException;
+import java.util.Set;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient.ConnectedCallback;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialDeleteRequest;
+import org.openyolo.protocol.CredentialDeleteResult;
+import org.openyolo.protocol.MalformedDataException;
+import org.openyolo.protocol.Protobufs;
+
+public class DeleteCredentialActivity extends AppCompatActivity implements ConnectedCallback {
+
+    private static final String LOG_TAG = "DeleteCrActivity";
+    private CredentialStorageClient mStorageClient;
+    private CredentialDeleteRequest mRequest;
+    private Set<AuthenticationDomain> mCallerAuthDomains;
+
+
+    @BindView(R.id.delete_prompt)
+    TextView mDeletePromptView;
+
+    @BindView(R.id.delete_yes_button)
+    Button mAcceptDeleteButton;
+
+    @BindView(R.id.delete_no_button)
+    Button mRefuseDeleteButton;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        try {
+            mRequest = CredentialDeleteRequest.fromRequestIntent(getIntent());
+        } catch (MalformedDataException ex) {
+            Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
+            setResultAndFinish(CredentialDeleteResult.BAD_REQUEST);
+            return;
+        }
+
+        mCallerAuthDomains = CallerUtil.extractCallerAuthDomains(this);
+
+        if (mCallerAuthDomains.isEmpty()) {
+            Log.w(LOG_TAG, "Unable to identify calling app");
+            setResultAndFinish(CredentialDeleteResult.BAD_REQUEST);
+            return;
+        }
+
+        // TODO: expand the caller auth domains to all equivalent domains
+
+        if (!mCallerAuthDomains.contains(mRequest.getCredential().getAuthenticationDomain())) {
+            setResultAndFinish(CredentialDeleteResult.BAD_REQUEST);
+            return;
+        }
+
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mStorageClient = client;
+
+        final Credential credentialToDelete = mRequest.getCredential();
+
+        if (!mStorageClient.isCreated()) {
+            Log.i(LOG_TAG, "Store is not yet initialized");
+            setResultAndFinish(CredentialDeleteResult.NO_MATCHING_CREDENTIAL);
+            return;
+        }
+
+        try {
+            Protobufs.Credential proto = credentialToDelete.toProtobuf();
+            if (!mStorageClient.hasCredential(proto)) {
+                setResultAndFinish(CredentialDeleteResult.NO_MATCHING_CREDENTIAL);
+                return;
+            }
+        } catch (IOException ex) {
+            setResultAndFinish(CredentialDeleteResult.UNKNOWN);
+        }
+
+        setContentView(R.layout.delete_layout);
+        ButterKnife.bind(this);
+
+        // monitor interactions outside of the dialog
+        getWindow().setFlags(
+                LayoutParams.FLAG_NOT_TOUCH_MODAL,
+                LayoutParams.FLAG_NOT_TOUCH_MODAL);
+        getWindow().setFlags(
+                        LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
+                        LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
+
+        String callingAppName = CallerUtil.getCallingAppName(this);
+        String savePromptTemplate = getString(R.string.delete_prompt_template);
+        mDeletePromptView.setText(String.format(
+                savePromptTemplate,
+                credentialToDelete.getIdentifier(),
+                callingAppName).trim());
+        mAcceptDeleteButton.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                try {
+                    mStorageClient.deleteCredential(credentialToDelete.toProtobuf());
+                    setResultAndFinish(CredentialDeleteResult.DELETED);
+                } catch (IOException e) {
+                    setResultAndFinish(CredentialDeleteResult.UNKNOWN);
+                }
+            }
+        });
+
+        mRefuseDeleteButton.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                // TODO: record the fact that the user refused to delete this credential, so
+                // that subsequent requests can be auto-refused.
+                setResultAndFinish(CredentialDeleteResult.USER_REFUSED);
+            }
+        });
+    }
+
+    @Override
+    public void onBackPressed() {
+        setResultAndFinish(CredentialDeleteResult.USER_CANCELED);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
+            setResultAndFinish(CredentialDeleteResult.USER_CANCELED);
+            return true;
+        }
+
+        return super.onTouchEvent(event);
+    }
+
+    @UiThread
+    private void setResultAndFinish(CredentialDeleteResult result) {
+        setResult(result.getResultCode(), result.toResultIntentData());
+        finish();
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
index 9bb9cce..8d1eba0 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -32,117 +32,116 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * Verifies the rights to save a credential, before proceeding to
  * {@link SaveCredentialConfirmationActivity}.
  */
 public class SaveCredentialActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
 
     private CredentialSaveRequest mRequest;
     private String mCallingPackage;
     private List<AuthenticationDomain> mAuthDomainsForApp;
     private CredentialStorageClient mStorageClient;
 
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         final byte[] encodedRequest =
                 getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_REQUEST);
 
         // Ensure the intent contains a save request
         if (null == encodedRequest) {
             Log.w(LOG_TAG, "No save request included in intent");
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         // Ensure the request can successfully be parsed from it's encoded form
         try {
             mRequest = CredentialSaveRequest.fromProtoBytes(encodedRequest);
         } catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to decode save request");
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         if (!verifyCaller()) {
             Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
                     + mRequest.getCredential().getAuthenticationDomain());
             finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(final CredentialStorageClient client) {
                 mStorageClient = client;
                 runOnUiThread(new AfterStorageConnect());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         if (mStorageClient != null) {
             mStorageClient.disconnect(this);
         }
     }
 
     @UiThread
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private boolean verifyCaller() {
         final ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         mCallingPackage = callingActivity.getPackageName();
         mAuthDomainsForApp = AuthenticationDomain.listForPackage(this, mCallingPackage);
 
         final AuthenticationDomain authDomain = mRequest.getCredential().getAuthenticationDomain();
         if (!mAuthDomainsForApp.contains(authDomain)) {
             Log.w(LOG_TAG, "App " + mCallingPackage
                     + " is not provably associated to authentication domain "
                     + authDomain
                     + " for the credential to be saved.");
             return false;
         }
 
-
         return true;
     }
 
     private final class AfterStorageConnect implements Runnable {
         @Override
         public void run() {
             try {
                 // Ensure authentication domain is not on never save list
                 if (mStorageClient.isOnNeverSaveList(mAuthDomainsForApp)) {
                     finishWithResult(CredentialSaveResult.PROVIDER_REFUSED);
                     return;
                 }
 
                 // Start confirm activity
                 Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
                         SaveCredentialActivity.this,
                         mCallingPackage,
                         mRequest.getCredential());
                 confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(confirmIntent);
                 finish();
             } catch (IOException ex) {
                 finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
index 4e49492..f0fb5de 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -18,4 +18,2 @@ import android.content.Context;
 import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
 import android.os.Bundle;
@@ -39,138 +37,132 @@ import org.openyolo.protocol.CredentialSaveResult;
 /**
  * Confirms with the user whether they want to save a credential provided by the
  * calling app. Verification of the app's right to save such a credential occurs
  * in {@link SaveCredentialActivity} before reaching this point.
  */
 public class SaveCredentialConfirmationActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
     private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
 
     @BindView(R.id.save_prompt)
     TextView mSavePromptView;
 
     private Credential mCredential;
     private String mCallingAppName;
 
     private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
     private final CountDownLatch mClientConnected = new CountDownLatch(1);
 
     /**
      * Creates an intent to confirm whether the user wishes to save the specified credential.
      */
     public static Intent createIntent(
             Context context,
             String callingPackage,
             Credential credential) {
         Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
         intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toProtobuf().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mCredential = Credential.fromProtoBytes(
                     getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
         } catch (IOException e) {
             Log.e(LOG_TAG, "Unable to decode credential", e);
             finishWithResult(CredentialSaveResult.UNSPECIFIED);
         }
 
-        try {
-            PackageManager pm = getPackageManager();
-            ApplicationInfo info = pm.getApplicationInfo(getCallingPackage(), 0);
-            mCallingAppName = pm.getApplicationLabel(info).toString();
-        } catch (PackageManager.NameNotFoundException e) {
-            e.printStackTrace();
-        }
+        mCallingAppName = CallerUtil.getCallingAppName(this);
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 mClient.set(client);
                 mClientConnected.countDown();
             }
         });
 
         setContentView(R.layout.save_layout);
         ButterKnife.bind(this);
 
         String savePromptTemplate = getString(R.string.save_prompt_template);
         mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
     }
 
     private void finishWithResult(CredentialSaveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         CredentialStorageClient client = mClient.get();
         if (client != null) {
             client.disconnect(this);
         }
     }
 
     @OnClick(R.id.save_button)
     void onSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
             finishWithResult(CredentialSaveResult.UNSPECIFIED);
             return;
         }
 
         if (client.isUnlocked()) {
             try {
                 client.upsertCredential(mCredential.toProtobuf());
                 finishWithResult(CredentialSaveResult.SAVED);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to write credential to storage");
                 finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         } else {
             Intent saveAfterUnlock = UnlockActivity.createIntent(
                     this,
                     true,
                     SaveAfterUnlockActivity.createIntent(this, mCredential.toProtobuf()));
             saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(saveAfterUnlock);
             finish();
         }
     }
 
     @OnClick(R.id.never_save_button)
     void onNeverSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             finishWithResult(CredentialSaveResult.USER_REFUSED);
             return;
         }
 
         try {
             client.addToNeverSaveList(mCredential.getAuthenticationDomain());
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to add app to never save list", e);
         }
 
         finishWithResult(CredentialSaveResult.USER_REFUSED);
     }
 
     private CredentialStorageClient getStorageClient() {
         try {
             mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
             return mClient.get();
         } catch (InterruptedException e) {
             Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
             return null;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
index a17c06e..518968e 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
@@ -28,3 +28,2 @@ import java.security.SecureRandom;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashSet;
@@ -34,3 +33,2 @@ import java.util.TreeSet;
 import org.openyolo.demoprovider.barbican.CredentialQualityScore;
-import org.openyolo.demoprovider.barbican.ProtoListUtil;
 import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
@@ -45,591 +43,556 @@ import org.spongycastle.crypto.io.CipherOutputStream;
 /**
  * An encrypted file-system based credential store. Uses bcrypt to derive an encryption key from
  * a password. Creates a directory for each authentication domain (using a hash of the domain)
  * under which the set of credentials for that domain is stored. This allows determining whether
  * a credential is available for a given authentication domain without the encryption key, which
  * is useful for answering OpenYOLO requests.
  */
 public final class CredentialStorage {
 
     private static final String LOG_TAG = "CredentialStorage";
 
     private static final int SALT_SIZE = 16;
     private static final int BCRYPT_COST = 10;
 
     private static final int AUTH_DOMAIN_HASH_SIZE = 32;
 
     private static final char[] HEX_CHARS =
             { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
     private static final byte[] KEY_VERIFICATION_BYTES =
             { 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0 };
     private static final int HALF_BYTE_WIDTH = 4;
     private static final int HALF_BYTE_MASK = 0xF;
 
     @NonNull
     private SecureRandom mRandom;
 
     @NonNull
     private File mStoreDir;
 
     private byte[] mSalt;
 
     @Nullable
     private byte[] mKey;
 
     /**
      * Initializes a credential store in the default location for the application.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(Context context) throws IOException {
         this(new SecureRandom(), new File(context.getFilesDir(), "store"));
     }
 
     /**
      * Initializes a credential store in the specified location.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(
             @NonNull SecureRandom random,
             @NonNull File storeDir)
             throws IOException {
         mRandom = random;
         mStoreDir = storeDir;
 
         if (mStoreDir.exists()) {
             CredentialMeta credentialMeta = readCredentialMeta();
             mSalt = credentialMeta.getSalt().toByteArray();
         }
     }
 
     /**
      * Determines whether a credential store exists in the initialized location.
      */
     public boolean isCreated() {
         return mStoreDir.exists();
     }
 
     /**
      * Determines whether the credential store is unlocked, meaning that the encryption key has
      * been derived from the password and is resident in memory.
      */
     public boolean isUnlocked() {
         return mKey != null;
     }
 
     /**
      * Locks the credential store, meaning that the derived encryption key is released from
      * memory if necessary.
      */
     public void lock() {
         // overwrite the key with random data, then release it for garbage collection
         mRandom.nextBytes(mKey);
         mKey = null;
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     @Nullable
     public List<String> retrieveNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         return meta.getNeverSaveList();
     }
 
     /**
      * Clears the "never save" list.
      * @throws IOException - in the case when the storage fails to be written
      */
     public void clearNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         writeCredentialMeta(meta.toBuilder().clearNeverSave().build());
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
         if (meta.getNeverSaveCount() < 1) {
             return false;
         }
 
         HashSet<String> authDomainsAsStrings = new HashSet<>();
         for (AuthenticationDomain authDomain : authDomains) {
             authDomainsAsStrings.add(authDomain.toString());
         }
 
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             if (authDomainsAsStrings.contains(neverSaveDomain)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Adds the specified authentication domain to the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             neverSaveDomains.add(neverSaveDomain);
         }
 
         neverSaveDomains.add(authDomain.toString());
 
         writeCredentialMeta(
                 meta.toBuilder()
                     .clearNeverSave()
                     .addAllNeverSave(neverSaveDomains)
                     .build());
     }
 
     /**
      * Removes the specified list of authentication domains from the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             neverSaveDomains.add(neverSaveDomain);
         }
 
         for (AuthenticationDomain authDomain : authDomains) {
             neverSaveDomains.remove(authDomain.toString());
         }
 
         writeCredentialMeta(
                 meta.toBuilder()
                     .clearNeverSave()
                     .addAllNeverSave(neverSaveDomains)
                     .build());
     }
 
     /**
      * Returns all account hints. The list of hints is automatically maintained as part of the
      * other credential save / delete operations.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public List<AccountHint> getHints() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         return meta.getHintsList();
     }
 
     /**
      * Determines whether any credentials are stored for the given authentication domain. This
      * does not require the credential store to be unlocked.
      */
     public boolean hasCredentialFor(@NonNull String authDomain) {
         return getAuthDomainDir(authDomain).exists();
     }
 
+    /**
+     * Determines whether the store contains a credential with the same authentication domain,
+     * authentication method and identifier as specified.
+     */
+    public boolean hasCredential(Credential credential) {
+        return getCredentialFile(
+                credential.getAuthDomain().getUri(),
+                credential.getAuthMethod().getUri(),
+                credential.getId()).exists();
+    }
+
     /**
      * Returns a list of all stored credentials. Requires that the credential store is unlocked.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listAllCredentials() throws IOException {
         ArrayList<Credential> allCredentials = new ArrayList<>();
         checkUnlocked();
         for (File authDomainDir : mStoreDir.listFiles()) {
             if (!authDomainDir.isDirectory()) {
                 continue;
             }
 
             List<Credential> credentials = readCredentials(authDomainDir);
             allCredentials.addAll(credentials);
         }
 
         return allCredentials;
     }
 
     /**
      * Returns a list of credentials for the specified authentication domain. Requires
      * that the credential store is unlocked. May be empty.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listCredentials(String authDomain) throws IOException {
         checkUnlocked();
         return readCredentials(authDomain);
     }
 
     /**
      * Writes (or overwrites) the provided credential to the store. Requires that the credential
      * store is unlocked. May be empty.
      * @throws IOException if the credential could not be written.
      */
     public void upsertCredential(Credential credential) throws IOException {
         checkUnlocked();
-        List<Credential> credentials = new ArrayList<>(
-                readCredentials(credential.getAuthDomain().getUri()));
-
-        // replace any existing equivalent
-        ListIterator<Credential> it = credentials.listIterator();
-        boolean existingFound = false;
-        while (it.hasNext() && !existingFound) {
-            Credential existing = it.next();
-            if (credential.getId().equals(existing.getId())
-                    && eq(credential.getAuthDomain(), existing.getAuthDomain())) {
-                existingFound = true;
-                it.set(credential);
-            }
-        }
 
-        if (!existingFound) {
-            it.add(credential);
+        initAuthDomainDir(credential.getAuthDomain().getUri());
+        File credentialFile = getCredentialFile(credential);
+        CipherOutputStream cipherOutputStream = IoUtil.encryptTo(credentialFile, mKey);
+        try {
+            credential.writeTo(cipherOutputStream);
+        } finally {
+            IoUtil.closeQuietly(cipherOutputStream, LOG_TAG);
         }
-
-        writeCredentials(credential.getAuthDomain().getUri(), credentials);
         upsertHint(credential);
     }
 
     /**
-     * Removes the specified credential (or one with the same authentication domain, identifier
-     * and "type") from the store. Requires that the store is unlocked.
+     * Removes the specified credential (or one with the same authentication domain,
+     * authentication method and identifier) from the store. Requires that the store is unlocked.
      * @throws IOException if the credential could not be deleted.
      */
     public void deleteCredential(Credential credential) throws IOException {
-        checkUnlocked();
-        List<Credential> credentials = new ArrayList<>(readCredentials(
-                credential.getAuthDomain().getUri()));
-
-        ListIterator<Credential> it = credentials.listIterator();
-        boolean existingFound = false;
-        while (it.hasNext() && !existingFound) {
-            Credential existing = it.next();
-            if (credentialsAreEquivalent(credential, existing)) {
-                existingFound = true;
-                it.remove();
-            }
-        }
-
-        if (existingFound) {
-            writeCredentials(credential.getAuthDomain().getUri(), credentials);
-        }
-    }
-
-    private boolean credentialsAreEquivalent(Credential c1, Credential c2) {
-        if (c1 == null) {
-            return c2 == null;
+        File credentialFile = getCredentialFile(credential);
+        if (!credentialFile.exists()) {
+            return;
         }
 
-        if (c2 == null) {
-            return false;
+        if (!credentialFile.delete()) {
+            throw new IOException("Failed to delete credential");
         }
-
-        return c1.getId().equals(c2.getId())
-                && c1.getAuthDomain().equals(c2.getAuthDomain())
-                && c1.getAuthMethod().equals(c2.getAuthMethod());
-    }
-
-    private boolean areEqual(Object o1, Object o2) {
-        return o1 == null ? o2 == null : o1.equals(o2);
     }
 
     /* **************************** store initialization ******************************************/
 
     /**
      * Creates a credential store at the initialized location, deriving an encryption key from
      * the specified password.
      * @throws IOException if the store could not be created.
      */
     public void create(String password) throws IOException {
         if (!mStoreDir.mkdirs()) {
             throw new IllegalStateException("unable to create credential store directory");
         }
 
         CredentialMeta meta = generateCredentialMeta();
         writeCredentialMeta(meta);
 
         mSalt = meta.getSalt().toByteArray();
         mKey = keyFromPassword(password, meta.getCost());
         generateKeyTestFile();
     }
 
     /**
      * Unlocks the credential store, deriving an encryption key from the specified password and
      * validates it.
      * @throws IOException if the store could not be unlocked.
      */
     public boolean unlock(String password) throws IOException {
         if (!isCreated()) {
             throw new IllegalStateException("Store has not been created");
         }
 
         CredentialMeta credentialMeta = readCredentialMeta();
         mSalt = credentialMeta.getSalt().toByteArray();
         mKey = keyFromPassword(password, credentialMeta.getCost());
         return verifyKey();
     }
 
     /* **************************** credential meta handling **************************************/
 
     private File getCredentialMetaFile() {
         return new File(mStoreDir, "meta");
     }
 
     private CredentialMeta generateCredentialMeta() {
         return CredentialMeta.newBuilder()
                 .setSalt(ByteString.copyFrom(generateRandomBytes(SALT_SIZE)))
                 .setCost(BCRYPT_COST)
                 .build();
     }
 
     private void writeCredentialMeta(CredentialMeta meta) throws IOException {
         FileOutputStream stream = null;
         try {
             stream = new FileOutputStream(getCredentialMetaFile());
             meta.writeTo(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private CredentialMeta readCredentialMeta() throws IOException {
         FileInputStream stream = null;
         try {
             stream = new FileInputStream(getCredentialMetaFile());
             return CredentialMeta.parseFrom(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private void upsertHint(Credential credential) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         // create a copy of the hints list for modification
         List<AccountHint> hints = new ArrayList<>(readCredentialMeta().getHintsList());
 
         ListIterator<AccountHint> hintIter = hints.listIterator();
         boolean found = false;
         while (!found && hintIter.hasNext()) {
             AccountHint existingHint = hintIter.next();
 
             if (existingHint.getIdentifier().equals(credential.getId())
                     && existingHint.getAuthMethod().equals(credential.getAuthMethod())
                     && CredentialQualityScore.getScore(existingHint)
                             <= CredentialQualityScore.getScore(credential)) {
                 hintIter.remove();
                 hintIter.add(convertCredentialToHint(credential));
                 found = true;
             }
         }
 
         if (!found) {
             hintIter.add(convertCredentialToHint(credential));
         }
 
         writeCredentialMeta(meta.toBuilder()
                 .clearHints()
                 .addAllHints(hints)
                 .build());
     }
 
     private AccountHint convertCredentialToHint(Credential credential) {
         return AccountHint.newBuilder()
                 .setIdentifier(credential.getId())
                 .setAuthMethod(credential.getAuthMethod().getUri())
                 .setName(credential.getDisplayName())
                 .setPictureUri(credential.getDisplayPictureUri())
                 .build();
     }
 
     /* **************************** key validation ************************************************/
 
     private File getKeyTestFile() {
         return new File(mStoreDir, "test");
     }
 
     private void generateKeyTestFile() throws IOException {
         CipherOutputStream stream = null;
         try {
             stream = IoUtil.encryptTo(getKeyTestFile(), mKey);
             stream.write(KEY_VERIFICATION_BYTES);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private boolean verifyKey() throws IOException {
         CipherInputStream stream = null;
         try {
             stream = IoUtil.decryptFrom(getKeyTestFile(), mKey);
             byte[] bytes = new byte[KEY_VERIFICATION_BYTES.length];
             int numRead = stream.read(bytes);
             return numRead == KEY_VERIFICATION_BYTES.length
                 && bytesEqual(KEY_VERIFICATION_BYTES, bytes);
         } catch (IOException ex) {
             Log.i(LOG_TAG, "Key verification failed");
             return false;
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* ************************** auth domain directory management ********************************/
 
     private File getAuthDomainDir(String authDomain) {
         return new File(mStoreDir, toBlakeHash(authDomain));
     }
 
     private File initAuthDomainDir(String authDomain) throws IOException {
-        File authorityDir = getAuthDomainDir(authDomain);
-        if (!authorityDir.exists()) {
-            if (!authorityDir.mkdirs()) {
+        File authDomainDir = getAuthDomainDir(authDomain);
+        if (!authDomainDir.exists()) {
+            if (!authDomainDir.mkdirs()) {
                 throw new IOException("failed to create authority dir");
             }
         }
 
-        return authorityDir;
+        return authDomainDir;
     }
 
     private void deleteAuthDomainDir(String authDomain) throws IOException {
-        File credsFile = getCredentialsFile(authDomain);
-        if (credsFile.exists()) {
-            if (!credsFile.delete()) {
-                throw new IOException("failed to delete credentials file");
-            }
+        File authDomainDir = getAuthDomainDir(authDomain);
+        if (!authDomainDir.exists()) {
+            return;
         }
 
-        File authorityDir = getAuthDomainDir(authDomain);
-        if (authorityDir.exists()) {
-            if (!authorityDir.delete()) {
-                throw new IOException("failed to delete authority directory");
-            }
+        boolean success = true;
+        for (File credentialFile : authDomainDir.listFiles()) {
+            success &= credentialFile.delete();
+        }
+
+        success &= authDomainDir.delete();
+        if (!success) {
+            throw new IOException("Failed to delete auth domain directory");
         }
     }
 
-    private File getCredentialsFile(String authDomain) {
-        return getCredentialsFile(getAuthDomainDir(authDomain));
+    private File getCredentialFile(String authDomain, String authMethod, String identifier) {
+        return new File(getAuthDomainDir(authDomain), toBlakeHash(authMethod + "|||" + identifier));
     }
 
-    private File getCredentialsFile(File authDomainDir) {
-        return new File(authDomainDir, "creds");
+    private File getCredentialFile(Credential credential) {
+        return getCredentialFile(
+                credential.getAuthDomain().getUri(),
+                credential.getAuthMethod().getUri(),
+                credential.getId());
     }
 
     /* **************************** credential manipulation ***************************************/
 
-    private void writeCredentials(String authDomain, List<Credential> credentials)
-            throws IOException {
-        if (credentials.size() == 0) {
-            deleteAuthDomainDir(authDomain);
-            return;
-        }
-
-        initAuthDomainDir(authDomain);
-        CipherOutputStream stream = null;
-        try {
-            stream = IoUtil.encryptTo(getCredentialsFile(authDomain), mKey);
-            ProtoListUtil.writeMessageListTo(stream, credentials);
-        } finally {
-            IoUtil.closeQuietly(stream, LOG_TAG);
-        }
-    }
-
     private List<Credential> readCredentials(String authDomain) throws IOException {
         return readCredentials(getAuthDomainDir(authDomain));
     }
 
     private List<Credential> readCredentials(File authDomain) throws IOException {
-        File credentialsFile = getCredentialsFile(authDomain);
-        if (!credentialsFile.exists()) {
-            return Collections.emptyList();
+        ArrayList<Credential> credentials = new ArrayList<>();
+        if (authDomain.exists()) {
+            for (File credentialFile : authDomain.listFiles()) {
+                credentials.add(readCredential(credentialFile));
+            }
         }
+        return credentials;
+    }
 
+    private Credential readCredential(File credentialFile) throws IOException {
         CipherInputStream stream = null;
         try {
-            stream = IoUtil.decryptFrom(credentialsFile, mKey);
-            return ProtoListUtil.readMessageList(stream, Credential.parser());
+            stream = IoUtil.decryptFrom(credentialFile, mKey);
+            return Credential.parseFrom(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* *********************************** utils **************************************************/
 
     private void checkUnlocked() {
         if (!isUnlocked()) {
             throw new IllegalStateException("credential store is locked");
         }
     }
 
     private byte[] keyFromPassword(String password, int cost) {
         return BCrypt.generate(toUtf8Bytes(password), mSalt, cost);
     }
 
     private static byte[] toUtf8Bytes(String str) {
         try {
             return str.getBytes("UTF-8");
         } catch (UnsupportedEncodingException e) {
             throw new IllegalStateException("UTF-8 character set not supported, against spec");
         }
     }
 
     private byte[] generateRandomBytes(int length) {
         byte[] bytes = new byte[length];
         mRandom.nextBytes(bytes);
         return bytes;
     }
 
     private boolean bytesEqual(byte[] b1, byte[] b2) {
         if (b1 == null) {
             return b2 == null;
         }
 
         if (b2 == null || b1.length != b2.length) {
             return false;
         }
 
         for (int i = 0; i < b1.length; i++) {
             if (b1[i] != b2[i]) {
                 return false;
             }
         }
 
         return true;
     }
 
     private String toBlakeHash(String message) {
         Blake2bDigest digest = new Blake2bDigest(
                 null, /* no key */
                 AUTH_DOMAIN_HASH_SIZE,
                 mSalt,
                 null); /* no personalization of the hashing function */
         byte[] messageBytes = toUtf8Bytes(message);
         digest.update(messageBytes, 0, messageBytes.length);
         byte[] result = new byte[AUTH_DOMAIN_HASH_SIZE];
         digest.doFinal(result, 0);
         return toHexString(result);
     }
 
     private String toHexString(byte[] bytes) {
         char[] result = new char[bytes.length * 2];
         for (int i = 0, j = 0; i < bytes.length; i++, j += 2) {
             byte nextByte = bytes[i];
 
             result[j] = HEX_CHARS[(nextByte >>> HALF_BYTE_WIDTH) & HALF_BYTE_MASK];
             result[j + 1] = HEX_CHARS[nextByte & HALF_BYTE_MASK];
         }
         return new String(result);
     }
 
     private boolean eq(Object o1, Object o2) {
         if (o1 == null) {
             return o2 == null;
         }
         return o2 != null && o1.equals(o2);
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
index 1b2ef9d..31d19d5 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
@@ -23,108 +23,115 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * Credential storage operations which are available via the service interface.
  */
 public interface CredentialStorageApi {
 
     /**
      * Determines whether a credential store exists in the initialized location.
      */
     boolean isCreated();
 
     /**
      * Creates a credential store at the initialized location, deriving an encryption key from
      * the specified password.
      * @throws IOException if the store could not be created.
      */
     void create(String password) throws IOException;
 
     /**
      * Determines whether the credential store is unlocked, meaning that the encryption key has
      * been derived from the password and is resident in memory.
      */
     boolean isUnlocked();
 
     /**
      * Unlocks the credential store, deriving an encryption key from the specified password and
      * validates it.
      * @throws IOException if the store could not be unlocked.
      */
     boolean unlock(String password) throws IOException;
 
     /**
      * Locks the credential store, meaning that the derived encryption key is released from
      * memory if necessary.
      */
     void lock();
 
     /**
      * Determines whether any of the provided authentication domains are on the "never save"
      * list.
      * @throws IOException if the credential store metadata could not be read.
      */
     boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException;
 
     /**
      * Adds the specified authentication domain to the "never save" list.
      * @throws IOException if the credential store metadata could not be modified.
      */
     void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException;
 
     /**
      * Removes the specified authentication domains from the "never save" list.
      * @throws IOException if the credential store metadata could not be modified.
      */
     void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException;
 
     /**
      * Returns the list of all account hints.
      * @throws IOException if the credential store metadata could not be modified.
      */
     List<AccountHint> getHints() throws IOException;
 
     /**
      * Returns a {@link List} of {@link AuthenticationDomain}s which are in the "never save" list.
      * @return a list of "never save" domains
      * @throws IOException - if the credential store metadata could not be read.
      */
     List<String> getNeverSaveList() throws IOException;
 
     /**
      * Clears the "never save" list.
      * @throws IOException - if the credential store metadata could not be read.
      */
     void clearNeverSaveList() throws IOException;
 
     /**
      * Determines whether any credentials are stored for the given authentication domain. This
      * does not require the credential store to be unlocked.
      * @throws IOException if the credential store could not be read.
      */
     boolean hasCredentialFor(String authDomain) throws IOException;
 
     /**
      * Returns a list of credentials for the specified authentication domain. Requires
      * that the credential store is unlocked. May be empty.
      * @throws IOException if the credentials could not be read.
      */
     List<Credential> listCredentials(List<AuthenticationDomain> authDomains) throws IOException;
 
     /**
      * Returns a list of all stored credentials. Requires that the credential store is unlocked.
      * @throws IOException if the credentials could not be read.
      */
     List<Credential> listAllCredentials() throws IOException;
 
     /**
      * Writes (or overwrites) the provided credential to the store. Requires that the credential
      * store is unlocked. May be empty.
      * @throws IOException if the credential could not be written.
      */
     void upsertCredential(Credential credential) throws IOException;
 
     /**
      * Removes the specified credential (or one with the same authentication domain, identifier
      * and "type") from the store. Requires that the store is unlocked.
      * @throws IOException if the credential could not be deleted.
      */
     void deleteCredential(Credential credential) throws IOException;
+
+    /**
+     * Determines whether the store contains a credential with the same authentication domain,
+     * authentication method and identifier as the credential specified.
+     * @throws IOException if the credential store could not be read.
+     */
+    boolean hasCredential(Credential credential) throws IOException;
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
index a76f008..6a4fb3e 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
@@ -31,164 +31,169 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * A client to the {@link CredentialStorageService}, allowing activities to access the
  * retained instance of the credential store.
  */
 public class CredentialStorageClient implements CredentialStorageApi {
 
     private static final String LOG_TAG = "StorageClient";
 
     private final CredentialStorageApi mApi;
     private final ServiceConnection mConnection;
 
     /**
      * Connects to the credential storage service, invoking the provided callback when connected.
      */
     public static void connect(Context context, ConnectedCallback callback) {
         CredentialStorageConnection connector = new CredentialStorageConnection(callback);
         Log.d(LOG_TAG, connector.mConnectionId + ": before startService");
         context.startService(new Intent(context, CredentialStorageService.class));
         Log.d(LOG_TAG, connector.mConnectionId + ": before bindService");
         context.bindService(
                 new Intent(context, CredentialStorageService.class),
                 connector,
                 Context.BIND_AUTO_CREATE);
         Log.d(LOG_TAG, connector.mConnectionId + ": after bindService");
     }
 
     CredentialStorageClient(CredentialStorageApi api, ServiceConnection connection) {
         mApi = api;
         mConnection = connection;
     }
 
     /**
      * Disconnects the service connection to the storage service.
      */
     public void disconnect(Context context) {
         context.unbindService(mConnection);
     }
 
     @Override
     public boolean isCreated() {
         return mApi.isCreated();
     }
 
     @Override
     public void create(String password) throws IOException {
         mApi.create(password);
     }
 
     @Override
     public boolean isUnlocked() {
         return mApi.isUnlocked();
     }
 
     @Override
     public boolean unlock(String password) throws IOException {
         return mApi.unlock(password);
     }
 
     @Override
     public void lock() {
         mApi.lock();
     }
 
     @Override
     public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         return mApi.isOnNeverSaveList(authDomains);
     }
 
     @Override
     public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
         mApi.addToNeverSaveList(authDomain);
     }
 
     @Override
     public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         mApi.removeFromNeverSaveList(authDomains);
     }
 
     @Override
     public List<String> getNeverSaveList() throws IOException {
         return mApi.getNeverSaveList();
     }
 
     @Override
     public void clearNeverSaveList() throws IOException {
         mApi.clearNeverSaveList();
     }
 
     @Override
     public List<AccountHint> getHints() throws IOException {
         return mApi.getHints();
     }
 
     @Override
     public boolean hasCredentialFor(String authDomain) throws IOException {
         return mApi.hasCredentialFor(authDomain);
     }
 
     @Override
     public List<Credential> listAllCredentials() throws IOException {
         return mApi.listAllCredentials();
     }
 
     @Override
     public void upsertCredential(Credential credential) throws IOException {
         mApi.upsertCredential(credential);
     }
 
     @Override
     public void deleteCredential(Credential credential) throws IOException {
         mApi.deleteCredential(credential);
     }
 
     @Override
     public List<Credential> listCredentials(List<AuthenticationDomain> authDomains)
             throws IOException {
         return mApi.listCredentials(authDomains);
     }
 
+    @Override
+    public boolean hasCredential(Credential credential) throws IOException {
+        return mApi.hasCredential(credential);
+    }
+
     /**
      * Callback interface for notifing callers when the client is connected.
      */
     public interface ConnectedCallback {
         /**
          * Invoked when the provided client is connected.
          */
         void onStorageConnected(CredentialStorageClient client);
     }
 
     private static final class CredentialStorageConnection implements ServiceConnection {
 
         private String mConnectionId;
         private ConnectedCallback mCallback;
         private long mStartTime;
 
         CredentialStorageConnection(ConnectedCallback callback) {
             mConnectionId = UUID.randomUUID().toString();
             mCallback = callback;
             mStartTime = System.nanoTime();
         }
 
         @Override
         public void onServiceConnected(ComponentName name, IBinder binder) {
             Log.d(LOG_TAG, mConnectionId + ": enter onServiceConnected");
             if (mCallback != null) {
                 CredentialStorageClient client = new CredentialStorageClient(
                         ((CredentialStorageService.LocalBinder)binder).getApi(),
                         this);
                 mCallback.onStorageConnected(client);
                 mCallback = null;
             }
 
             long timeTaken = TimeUnit.MILLISECONDS.convert(
                     System.nanoTime() - mStartTime,
                     TimeUnit.NANOSECONDS);
             Log.d(LOG_TAG, mConnectionId + ": Took " + timeTaken + "ms to connect");
         }
 
         @Override
         public void onServiceDisconnected(ComponentName name) {
             Log.d(LOG_TAG, mConnectionId + ": Disconnected from service");
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
index c8950f6..90c6e01 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
@@ -36,176 +36,180 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * A service which retains an instance of {@link CredentialStorage} beyond the lifecycle of the
  * activities that interact with it. This reduces the frequency at which the user would have
  * to enter their password to unlock the keystore.
  */
 public class CredentialStorageService extends Service implements CredentialStorageApi {
 
     private static final String LOG_TAG = "CredentialStorage";
 
     private static final int UNLOCKED_NOTIFICATION_ID = 1;
 
     private final IBinder mLocalBinder = new LocalBinder();
     private CredentialStorage mStorage;
 
     @Nullable
     @Override
     public IBinder onBind(Intent intent) {
         Log.d(LOG_TAG, "enter onBind");
         return mLocalBinder;
     }
 
     @Override
     public void onCreate() {
         super.onCreate();
         Log.d(LOG_TAG, "enter onCreate");
         try {
             mStorage = new CredentialStorage(this);
         } catch (IOException ex) {
             Log.wtf(LOG_TAG, "Failed to open credential storage", ex);
             return;
         }
         Log.d(LOG_TAG, "after create storage");
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
     }
 
     @Override
     public boolean isCreated() {
         return mStorage.isCreated();
     }
 
     @Override
     public void create(final String password) throws IOException {
         mStorage.create(password);
         becomeForeground();
     }
 
     @Override
     public boolean isUnlocked() {
         return mStorage.isUnlocked();
     }
 
     @Override
     public boolean unlock(String password) throws IOException {
         if (mStorage.unlock(password)) {
             // when unlocked, we become foreground in order to retain the unlock key for longer,
             // and also to notify the user of the associated security risk.
             becomeForeground();
             return true;
         }
 
         return false;
     }
 
     @Override
     public void lock() {
         if (!mStorage.isUnlocked()) {
             return;
         }
 
         mStorage.lock();
         stopForeground(true);
     }
 
     @Override
     public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         return mStorage.isOnNeverSaveList(authDomains);
     }
 
     @Override
     public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
         mStorage.addToNeverSaveList(authDomain);
     }
 
     @Override
     public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         mStorage.removeFromNeverSaveList(authDomains);
     }
 
     @Override
     public List<String> getNeverSaveList() throws IOException {
         return mStorage.retrieveNeverSaveList();
     }
 
     @Override
     public void clearNeverSaveList() throws IOException {
         mStorage.clearNeverSaveList();
     }
 
     @Override
     public List<AccountHint> getHints() throws IOException {
         return mStorage.getHints();
     }
 
     @Override
     public boolean hasCredentialFor(String authDomain) throws IOException {
         return mStorage.hasCredentialFor(authDomain);
     }
 
+    @Override
+    public boolean hasCredential(Credential credential) throws IOException {
+        return mStorage.hasCredential(credential);
+    }
+
     @Override
     public List<Credential> listCredentials(List<AuthenticationDomain> authDomains)
             throws IOException {
         checkUnlocked();
         ArrayList<Credential> matchingCredentials = new ArrayList<>();
         for (AuthenticationDomain domain : authDomains) {
             matchingCredentials.addAll(mStorage.listCredentials(domain.toString()));
         }
 
         return matchingCredentials;
     }
 
     @Override
     public List<Credential> listAllCredentials() throws IOException {
         checkUnlocked();
         return mStorage.listAllCredentials();
     }
 
     @Override
     public void upsertCredential(Credential credential) throws IOException {
         checkUnlocked();
         mStorage.upsertCredential(credential);
     }
 
     @Override
     public void deleteCredential(Credential credential) throws IOException {
-        checkUnlocked();
         mStorage.deleteCredential(credential);
     }
 
     private void becomeForeground() {
         Notification notification = new NotificationCompat.Builder(this)
                 .setSmallIcon(R.drawable.unlocked_notification_icon)
                 .setContentTitle(getString(R.string.unlocked_notification_title))
                 .setContentText(getString(R.string.unlocked_notification_text))
                 .setCategory(NotificationCompat.CATEGORY_SERVICE)
                 .setContentIntent(PendingIntent.getActivity(
                         this, 0, new Intent(this, CredentialListActivity.class), 0))
                 .addAction(
                         R.drawable.lock_notification_icon,
                         getString(R.string.unlocked_notification_lock_action),
                         PendingIntent.getActivity(
                                 this, 0, new Intent(this, LockActivity.class), 0
                 ))
                 .setLocalOnly(true)
                 .setAutoCancel(false)
                 .setOngoing(true)
                 .setOnlyAlertOnce(true)
                 .build();
         startForeground(UNLOCKED_NOTIFICATION_ID, notification);
     }
 
     private void checkUnlocked() {
         if (!mStorage.isUnlocked()) {
             throw new IllegalStateException("Storage is locked");
         }
     }
 
     class LocalBinder extends Binder {
         CredentialStorageApi getApi() {
             return CredentialStorageService.this;
         }
     }
 }
diff --git a/demoproviders/barbican/res/layout/delete_layout.xml b/demoproviders/barbican/res/layout/delete_layout.xml
new file mode 100644
index 0000000..a9ec020
--- /dev/null
+++ b/demoproviders/barbican/res/layout/delete_layout.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/colorPrimary"
+    android:orientation="vertical"
+    android:paddingTop="16dp"
+    android:paddingLeft="24dp"
+    android:paddingRight="24dp"
+    android:paddingBottom="8dp">
+
+  <ImageView
+      android:layout_width="48dp"
+      android:layout_height="48dp"
+      android:layout_gravity="center_horizontal"
+      android:contentDescription="@string/logo_contentDescription"
+      app:srcCompat="@drawable/app_icon"/>
+
+  <TextView
+      android:id="@+id/delete_prompt"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="20dp"
+      style="@style/TextAppearance.AppCompat.Subhead"/>
+
+  <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:gravity="end"
+      android:layout_marginTop="24dp"
+      android:orientation="horizontal">
+
+    <Button
+        android:id="@+id/delete_yes_button"
+        style="@style/Widget.AppCompat.Button.Borderless"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/delete_yes"/>
+
+    <Button
+        android:id="@+id/delete_no_button"
+        style="@style/Widget.AppCompat.Button.Colored"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginStart="8dp"
+        android:text="@string/delete_no"
+        android:textAppearance="@style/TextAppearance.AppCompat.Widget.Button"/>
+  </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/values/strings.xml b/demoproviders/barbican/res/values/strings.xml
index 99a53e4..163c726 100644
--- a/demoproviders/barbican/res/values/strings.xml
+++ b/demoproviders/barbican/res/values/strings.xml
@@ -1,38 +1,46 @@
 <resources xmlns:xliff="http://schemas.android.com/tools">
     <string name="action_create_done_contentDescription">Store credential</string>
     <string name="action_lock_contentDescription">Lock credential store</string>
     <string name="app_name_short">Barbican</string>
     <string name="app_spinner_label">App:</string>
     <string name="create_credential_activity_label">Store credential</string>
     <string name="create_failure">Failed to create the credential store :(</string>
     <string name="credential_storage_service_label">Barbican credential storage service</string>
     <string name="credential_authority_icon">App icon</string>
     <string name="credential_selection_prompt">Continue with:</string>
     <string name="hint_selection_prompt">Continue with:</string>
     <string name="credential_icon">Credential profile picture</string>
     <string name="id_hint">User name</string>
     <string name="invalid_password">Invalid password, try again</string>
     <string name="logo_contentDescription">Barbican logo</string>
     <string name="password_hint">Password</string>
     <string name="save_failed">Failed to save credential :(</string>
     <string name="unlock_prompt">Enter your password:</string>
     <string name="unlock_loading_prompt">Decrypting store…</string>
     <string name="unlocked_notification_title">Barbican is unlocked</string>
     <string name="unlocked_notification_text">Passwords are currently readable.</string>
     <string name="unlocked_notification_lock_action">Lock now</string>
     <string name="welcome_loading_prompt">Initializing storage…</string>
     <string name="welcome_title">Welcome!</string>
     <string name="welcome_prompt">Please choose a password with at least 6 characters:</string>
     <string name="never_save">Never</string>
     <string name="save_account">Save account</string>
     <string name="save_prompt_template">
         Would you like to save your account for
         <xliff:g example="Netflix" id="appName">%1$s</xliff:g>
         to Barbican?
     </string>
+    <string name="delete_prompt_template">
+        Would you like to delete the account
+        <xliff:g example="alice@example.com" id="accountId">%1$s</xliff:g>
+        for
+        <xliff:g example="Netflix" id="appName">%2$s</xliff:g>?
+    </string>
     <string name="action_wipe_contentDescription">Wipe associations for save</string>
     <string name="remove_unpaired_api_dialog_title">Remove this App from the \"Never Save\" list?</string>
     <string name="openyolo_simple_yes">Yes</string>
     <string name="openyolo_simple_no">No</string>
     <string name="ask_delete_credential">Delete credential?</string>
+    <string name="delete_yes">Yes</string>
+    <string name="delete_no">No thanks</string>
 </resources>
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index 18794ff..e78582d 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -27,2 +27,3 @@ import com.google.protobuf.InvalidProtocolBufferException;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
@@ -35,166 +36,166 @@ import org.valid4j.errors.RequireViolation;
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
  */
 public final class CredentialDeleteRequest {
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent.
      * @throws MalformedDataException if the protocol buffer is null or contains invalid data.
      */
     public static CredentialDeleteRequest fromProtobuf(
             @Nullable Protobufs.CredentialDeleteRequest proto)
             throws MalformedDataException {
         if (proto == null) {
             throw new MalformedDataException("credential delete proto is not defined");
         }
 
         try {
             return new Builder(proto).build();
         } catch (RequireViolation ex) {
             throw new MalformedDataException("credential deletion request contains invalid data");
         }
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent, in byte array
      * form.
      * @throws MalformedDataException if the protocol buffer is null or cannot be parsed from the
      *     byte array.
      */
     public static CredentialDeleteRequest fromProtobufBytes(
             @Nullable byte[] protobufBytes)
             throws MalformedDataException {
         if (protobufBytes == null) {
             throw new MalformedDataException("credential deletion request not defined");
         }
 
         try {
             return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
         } catch (InvalidProtocolBufferException ex) {
             throw new MalformedDataException("unable to parse credential deletion request", ex);
         }
     }
 
     /**
      * Extracts a credential deletion request from a request intent.
      * @throws MalformedDataException if the provided intent is null, is missing the byte array
      *     extra for the request, or the request contains invalid data.
      */
     public static CredentialDeleteRequest fromRequestIntent(
             @Nullable Intent requestIntent)
             throws MalformedDataException {
         return fromProtobuf(
                 IntentProtocolBufferExtractor.extract(
                         ProtocolConstants.EXTRA_DELETE_REQUEST,
                         Protobufs.CredentialDeleteRequest.parser(),
                         "deletion request missing or contains invalid data",
                         requestIntent));
     }
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be deleted.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties specified by the client as part of this
      * deletion request.
      */
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Converts the request to its protocol buffer equivalent.
      */
     public Protobufs.CredentialDeleteRequest toProtobuf() {
         return Protobufs.CredentialDeleteRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Creates instances of {@link CredentialDeleteRequest}.
      */
     public static final class Builder {
 
         @NonNull
         private Credential mCredential;
 
         @NonNull
-        private Map<String, ByteString> mAdditionalProps;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion request, based on the properties
          * contained in the provided protocol buffer.
          */
         public Builder(Protobufs.CredentialDeleteRequest proto) {
             setCredentialFromProto(proto.getCredential());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * credential object.
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be deleted. Must not be null.
          */
         public Builder setCredential(@NonNull Credential credential) {
             require(credential, notNullValue());
             mCredential = credential;
             return this;
         }
 
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credentialProto) {
             require(credentialProto, notNullValue());
             setCredential(Credential.fromProtobuf(credentialProto));
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(
                 @Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion request, from the specified properties.
          */
         public CredentialDeleteRequest build() {
             return new CredentialDeleteRequest(this);
         }
     }
 }

commit 25529d4619b1be05d8710ca2e4322e11397571f0
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue May 9 18:17:37 2017 -0700

    Improvements to the test app (#48)

diff --git a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
index e96240f..2267948 100644
--- a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
+++ b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
@@ -32,94 +32,108 @@ import org.valid4j.errors.RequireViolation;
 public final class AuthenticationMethodsInputView extends LinearLayout {
 
     private static final String TAG = "AuthMethodsInputView";
 
     @BindView(R.id.facebook_authentication_method_checkbox)
     CheckBox mFaceBookCheckBox;
 
     @BindView(R.id.google_authentication_method_checkbox)
     CheckBox mGoogleCheckBox;
 
     @BindView(R.id.email_authentication_method_checkbox)
     CheckBox mEmailCheckBox;
 
+    @BindView(R.id.phone_authentication_method_checkbox)
+    CheckBox mPhoneCheckBox;
+
+    @BindView(R.id.username_authentication_method_checkbox)
+    CheckBox mUsernameCheckBox;
+
     @BindView(R.id.custom_authentication_method_checkbox)
     CheckBox mCustomAuthenticationMethodCheckBox;
 
     @BindView(R.id.custom_authentication_method)
     EditText mCustomAuthenticationMethod;
 
     /**
      * Simple constructor to use when creating an authentication method selection view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public AuthenticationMethodsInputView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public AuthenticationMethodsInputView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public AuthenticationMethodsInputView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.authentication_method_input_layout, this);
 
         ButterKnife.bind(view);
     }
 
     /**
      * @return A set of authentication domains that are marked as enabled.
      */
     public Set<AuthenticationMethod> getEnabledAuthenticationMethods() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
 
         if (mFaceBookCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.FACEBOOK);
         }
 
         if (mGoogleCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.GOOGLE);
         }
 
         if (mEmailCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.EMAIL);
         }
 
+        if (mPhoneCheckBox.isChecked()) {
+            authenticationMethods.add(AuthenticationMethods.PHONE);
+        }
+
+        if (mUsernameCheckBox.isChecked()) {
+            authenticationMethods.add(AuthenticationMethods.USER_NAME);
+        }
+
         if (mCustomAuthenticationMethodCheckBox.isChecked()) {
             String customAuthMethodStr = mCustomAuthenticationMethod.getText().toString();
             try {
                 authenticationMethods.add(new AuthenticationMethod(customAuthMethodStr));
             } catch (RequireViolation ex) {
                 Log.w(TAG, "Authentication method " + customAuthMethodStr
                         + " is invalid, ignoring");
             }
         }
 
         return authenticationMethods;
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index f4a755a..e3fb97a 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -23,3 +23,2 @@ import android.view.View;
 import android.view.ViewGroup;
-import android.widget.EditText;
 import butterknife.BindView;
@@ -27,5 +26,5 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
+import java.util.Set;
 import org.openyolo.api.CredentialClient;
 import org.openyolo.protocol.AuthenticationMethod;
-import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Hint;
@@ -33,122 +32,106 @@ import org.openyolo.protocol.HintRetrieveRequest;
 import org.openyolo.protocol.HintRetrieveResult;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
-    @BindView(R.id.authentication_method_text_input)
-    EditText mAuthenticationMethodInput;
+    @BindView(R.id.authentication_methods_input)
+    AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         // CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         HintRetrieveResult result = mApi.getHintRetrieveResult(data);
         Hint hint = result.getHint();
         if (hint != null) {
             mCredentialView.setFieldsFromHint(hint);
             return;
         }
 
         int errorStringResId;
         switch (result.getResultCode()) {
             case HintRetrieveResult.CODE_BAD_REQUEST:
                 errorStringResId = R.string.hint_bad_request;
                 break;
             case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
                 errorStringResId = R.string.hint_none_available;
                 break;
             case HintRetrieveResult.CODE_USER_CANCELED:
                 errorStringResId = R.string.hint_user_canceled;
                 break;
             case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
                 errorStringResId = R.string.hint_manual_auth;
                 break;
             default:
                 errorStringResId = R.string.hint_unknown_response;
         }
         showSnackbar(errorStringResId);
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
-        String authMethodStr = mAuthenticationMethodInput.getText().toString();
-        AuthenticationMethod authMethod;
-        try {
-            authMethod = new AuthenticationMethod(authMethodStr);
-        } catch (RequireViolation ex) {
+        Set<AuthenticationMethod> authenticationMethods =
+                mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
+
+        if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
 
-        HintRetrieveRequest.Builder requestBuilder = new HintRetrieveRequest.Builder(authMethod);
+        HintRetrieveRequest.Builder requestBuilder =
+                new HintRetrieveRequest.Builder(authenticationMethods);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
-    @OnClick(R.id.openyolo_email_provider_button)
-    void onEmailAuthenticationMethod() {
-        mAuthenticationMethodInput.setText(AuthenticationMethods.EMAIL.toString());
-    }
-
-    @OnClick(R.id.google_provider_button)
-    void onGoogleAuthenticationMethod() {
-        mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
-    }
-
-    @OnClick(R.id.facebook_provider_button)
-    void onFacebookAuthenticationMethod() {
-        mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
-    }
-
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/res/layout/authentication_method_input_layout.xml b/testapp/res/layout/authentication_method_input_layout.xml
index 574a5ee..5661244 100644
--- a/testapp/res/layout/authentication_method_input_layout.xml
+++ b/testapp/res/layout/authentication_method_input_layout.xml
@@ -1,41 +1,51 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
 
   <android.support.v7.widget.AppCompatCheckBox
     android:id="@+id/facebook_authentication_method_checkbox"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/facebook_authentication_method_checkbox_text"/>
   <android.support.v7.widget.AppCompatCheckBox
     android:id="@+id/google_authentication_method_checkbox"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/google_authentication_method_checkbox_text"/>
   <android.support.v7.widget.AppCompatCheckBox
     android:id="@+id/email_authentication_method_checkbox"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/email_authentication_method_checkbox_text"/>
+  <android.support.v7.widget.AppCompatCheckBox
+      android:id="@+id/phone_authentication_method_checkbox"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/phone_authentication_method_checkbox_text"/>
+  <android.support.v7.widget.AppCompatCheckBox
+      android:id="@+id/username_authentication_method_checkbox"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/username_authentication_method_checkbox_text"/>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.v7.widget.AppCompatCheckBox
       android:id="@+id/custom_authentication_method_checkbox"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center_vertical"/>
 
     <android.support.design.widget.TextInputEditText
       android:id="@+id/custom_authentication_method"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="@string/custom_authentication_method_hint"
       android:inputType="textNoSuggestions|textVisiblePassword"/>
   </LinearLayout>
 </LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/hint_test_layout.xml b/testapp/res/layout/hint_test_layout.xml
index d805a5a..bb08077 100644
--- a/testapp/res/layout/hint_test_layout.xml
+++ b/testapp/res/layout/hint_test_layout.xml
@@ -1,87 +1,58 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/request"/>
 
-    <LinearLayout
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:layout_marginTop="16dp"
-      android:orientation="horizontal">
-
-      <android.support.design.widget.TextInputLayout
-        android:id="@+id/id_layout"
-        android:layout_width="0dp"
+    <TextView
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_weight="1">
-
-        <android.support.design.widget.TextInputEditText
-          android:id="@+id/authentication_method_text_input"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:hint="@string/authentication_method_field_hint"
-          android:inputType="textNoSuggestions|textVisiblePassword"/>
-      </android.support.design.widget.TextInputLayout>
-
-      <ImageButton
-        android:id="@+id/openyolo_email_provider_button"
-        style="@style/SideButton"
-        android:contentDescription="@string/open_yolo_email_button_content_description"
-        app:srcCompat="@drawable/account_box_24dp"/>
-
-      <ImageButton
-        android:id="@+id/google_provider_button"
-        style="@style/SideButton"
-        android:contentDescription="@string/google_provider_button_content_description"
-        app:srcCompat="@drawable/google_24dp"/>
-
-      <ImageButton
-        android:id="@+id/facebook_provider_button"
-        style="@style/SideButton"
-        android:contentDescription="@string/facebook_provider_button_content_description"
-        app:srcCompat="@drawable/facebook_24dp"/>
+        android:text="@string/authentication_method_section_title"/>
 
-    </LinearLayout>
+    <org.openyolo.testapp.AuthenticationMethodsInputView
+        android:id="@+id/authentication_methods_input"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+    </org.openyolo.testapp.AuthenticationMethodsInputView>
 
     <Button
       android:id="@+id/hint_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/hint_button_content_description"
       android:text="@string/hint_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/response"/>
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/hint_credential"
       android:layout_width="match_parent"
       android:layout_height="match_parent">
     </org.openyolo.testapp.CredentialView>
 
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 1232314..02c849a 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,85 +1,87 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
+    <string name="phone_authentication_method_checkbox_text">openyolo://phone</string>
+    <string name="username_authentication_method_checkbox_text">openyolo://username</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="save_result_unkown">Unknown save result</string>
     <string name="save_result_saved">Credential Saved</string>
     <string name="save_result_bad_request">Malformed save request</string>
     <string name="save_result_provider_refused">Provider refused save request</string>
     <string name="save_result_user_canceled">User canceled save request</string>
     <string name="save_result_user_refused">User refused save request</string>
 
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
     <string name="no_available_delete_providers">"No available providers can delete this credential</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
     <string name="delete_result_unknown_response">Unknown delete response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
 
 </resources>

commit bdf8f714f956f3a655cbe9419a8046f13560dbe1
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Tue May 9 12:49:26 2017 -0700

    Made gradle file permission script platform independent (#47)

diff --git a/config/protobuf.gradle b/config/protobuf.gradle
index 42998ca..57ae945 100644
--- a/config/protobuf.gradle
+++ b/config/protobuf.gradle
@@ -38,12 +38,7 @@ Dependency javaliteDep = project.dependencies.add(protoDepsConfig.name, [
 def makeExecutable = { file ->
-    Files.setPosixFilePermissions(
-            file.toPath(),
-            [
-                    PosixFilePermission.OWNER_EXECUTE,
-                    PosixFilePermission.GROUP_EXECUTE
-            ].toSet())
+    file.setExecutable(true /* isExecutable */, false /* forOwnerOnly */);
 }
 
 /**
  * Compiles the protocol buffers in the "proto" folder of the project, into the "java_gen" folder.
  */

commit b494d5679ec9daae478a7ef070ddd2d603e3c283
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon May 8 17:09:38 2017 -0700

    Update Barbican manifest entry for save activity to match spec 3

diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
index 04f95ef..82b33d4 100644
--- a/demoproviders/barbican/AndroidManifest.xml
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -1,146 +1,146 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="org.openyolo.demoprovider.barbican">
 
     <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name_short"
         android:supportsRtl="false"
         android:theme="@style/AppTheme"
         android:name=".Application">
 
         <activity
             android:name=".LaunchActivity"
             android:label="@string/app_name_short"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateHidden"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data
                     android:host="barbican.openyolo.org"
                     android:scheme="https" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".WelcomeActivity"
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".UnlockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".LockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="false" />
 
         <activity
             android:name=".CredentialListActivity"
             android:label="Stored Credentials"
             android:theme="@style/AppTheme"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity
             android:name=".CreateCredentialActivity"
             android:theme="@style/AppTheme"
             android:label="@string/create_credential_activity_label"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity android:name=".provider.RetrieveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.credential.retrieve"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
-                <action android:name="org.openyolo.save"/>
+                <action android:name="org.openyolo.credential.save"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".provider.HintPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="true">
             <intent-filter>
                 <action android:name="org.openyolo.hint"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialConfirmationActivity"
                   android:theme="@style/AppTheme.Dialog"
                   android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveAfterUnlockActivity"
                   android:theme="@style/AppTheme.NoUi"
                   android:excludeFromRecents="true" />
 
         <activity
             android:name=".provider.AutoSignInActivity"
             android:theme="@style/AutoSignInTheme"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".provider.CredentialPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".NeverSaveListActivity"
             android:theme="@style/AppTheme"/>
             android:exported="false" />
 
         <service
             android:name=".storage.CredentialStorageService"
             android:label="@string/credential_storage_service_label"
             android:enabled="true"
             android:exported="false"
             android:permission="org.openyolo.demoprovider.STORAGE"/>
 
         <receiver
             android:name=".provider.CredentialQueryReceiver"
             android:exported="true"
             android:enabled="true"
             tools:ignore="ExportedReceiver">
             <intent-filter>
                 <action android:name="org.openyolo.credential" />
                 <category android:name="com.google.bbq.QUERY" />
             </intent-filter>
         </receiver>
     </application>
 </manifest>

commit 73576f8e92934ae2ef89333d080b38428107996f
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Mon May 8 16:38:58 2017 -0700

    Updated Save flow to match the lastest Specification (#44)

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 2fac906..a55e78c 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -19,3 +19,2 @@ import static org.openyolo.protocol.ProtocolConstants.CREDENTIAL_DATA_TYPE;
 import static org.openyolo.protocol.ProtocolConstants.DELETE_CREDENTIAL_ACTION;
-import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_DELETE_REQUEST;
@@ -24,2 +23,4 @@ import static org.openyolo.protocol.ProtocolConstants.EXTRA_HINT_RESULT;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_RETRIEVE_RESULT;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_SAVE_REQUEST;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_SAVE_RESULT;
 import static org.openyolo.protocol.ProtocolConstants.HINT_CREDENTIAL_ACTION;
@@ -52,2 +53,4 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.CredentialSaveRequest;
+import org.openyolo.protocol.CredentialSaveResult;
 import org.openyolo.protocol.HintRetrieveRequest;
@@ -61,414 +64,442 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
-    public Intent getSaveIntent(Credential credentialToSave) {
-        List<ComponentName> saveProviders =
-                findProviders(SAVE_CREDENTIAL_ACTION);
+    public Intent getSaveIntent(final CredentialSaveRequest saveRequest) {
+        List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
-        byte[] encodedCredential = credentialToSave.toProtobuf().toByteArray();
+        byte[] encodedSaveRequest = saveRequest.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
-                    encodedCredential);
+                    encodedSaveRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
-                    encodedCredential));
+                    encodedSaveRequest));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     /**
      * Provides an intent to delete a credential. If no compatible credential providers exist
      * on the device, {@code null} will be returned. The intent should be started with a call
      * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>Upon completion of the request, the result data will be returned in the Intent passed
      * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
      * can be extracted by calling {@link #getDeleteResult(Intent)}.
      */
     @Nullable
     public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
         require(credentialToDelete, notNullValue());
         List<ComponentName> deleteProviders =
                 findProviders(DELETE_CREDENTIAL_ACTION);
 
         if (deleteProviders.isEmpty()) {
             return null;
         }
 
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(credentialToDelete).build();
 
         byte[] encodedRequest = request.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
         if (preferredDeleteActivity != null) {
             return createDeleteIntent(preferredDeleteActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers
         ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
         for (ComponentName providerActivity : deleteProviders) {
             deleteIntents.add(createDeleteIntent(
                     providerActivity,
                     encodedRequest));
         }
 
         return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
-            byte[] saveRequest) {
+            byte[] encodedSaveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
-        saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
+        saveIntent.putExtra(EXTRA_SAVE_REQUEST, encodedSaveRequest);
         return saveIntent;
     }
 
     private Intent createDeleteIntent(
             ComponentName providerActivity,
             byte[] deleteRequest) {
         Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
         deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
         return deleteIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @Nullable
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response");
             return createDefaultHintRetrieveResult();
         }
     }
 
+    /**
+     * Extracts the result of a credential save request from the intent data returned by a provider.
+     */
+    public CredentialSaveResult getCredentialSaveResult(Intent resultData) {
+        if (resultData == null) {
+            Log.i(LOG_TAG, "resultData is null, returning default response");
+            return createDefaultCredentialSaveResult();
+        }
+
+        final byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_SAVE_RESULT);
+        if (resultBytes == null) {
+            Log.i(LOG_TAG, "No save result found in result data, returning default response");
+            return createDefaultCredentialSaveResult();
+        }
+
+        try {
+            return CredentialSaveResult.fromProtobufBytes(resultBytes);
+        } catch (IOException ex) {
+            Log.e(LOG_TAG, "save result is malformed, returning default response");
+            return createDefaultCredentialSaveResult();
+        }
+    }
+
+    @NonNull
+    private static CredentialSaveResult createDefaultCredentialSaveResult() {
+        return new CredentialSaveResult.Builder(CredentialSaveResult.CODE_UNKNOWN)
+                .build();
+    }
+
     /**
      * Extracts the result of a credential deletion request from the intent data returned by
      * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
      * is returned.
      */
     @NonNull
     public CredentialDeleteResult getDeleteResult(Intent resultData) {
         try {
             return CredentialDeleteResult.fromResultIntentData(resultData);
         } catch (MalformedDataException ex) {
             Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
             return CredentialDeleteResult.UNKNOWN;
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @Nullable
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 2dd8bb9..4d8ad7a 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -41,2 +41,4 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialSaveRequest;
+import org.openyolo.protocol.CredentialSaveResult;
 import org.openyolo.protocol.HintRetrieveRequest;
@@ -46,306 +48,360 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
 
 /**
- * Battery of tests for CredentialClient
+ * Units tests for {@link CredentialClient}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
+    private static final byte[] INVALID_PROTO = new byte[] { 0, 1, 2, 3 };
+
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         credentialClient = new CredentialClient(mockContext);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
-        addUnknownProviders("com.example.superpassword", "com.example.locker");
+        addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
-        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(testCredential);
+        final Intent saveIntent = credentialClient.getSaveIntent(request);
+
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
+    @Test
+    public void getCredentialSaveResult_withNullIntent_returnsDefaultResult() {
+        final CredentialSaveResult result =
+                credentialClient.getCredentialSaveResult(null /* intent*/);
+
+        assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void getCredentialSaveResult_missingExtra_returnsDefaultResult() {
+        final Intent intent = new Intent();
+        final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
+
+        assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void getCredentialSaveResult_withInvalidProto_returnsDefaultResult() {
+        final Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_SAVE_RESULT, INVALID_PROTO);
+        final CredentialSaveResult result = credentialClient.getCredentialSaveResult(intent);
+
+        assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_UNKNOWN);
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void getCredentialSaveResult_validResult_returnsResult() {
+        final CredentialSaveResult result =
+                credentialClient.getCredentialSaveResult(
+                        CredentialSaveResult.SAVED.toResultDataIntent());
+
+        assertThat(result.getResultCode()).isEqualTo(CredentialSaveResult.CODE_SAVED);
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+
     @Test
     public void testGetCredentialRetrieveResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(
                         CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(
                 CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
 
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
index f8c3e88..04f95ef 100644
--- a/demoproviders/barbican/AndroidManifest.xml
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -1,153 +1,146 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="org.openyolo.demoprovider.barbican">
 
     <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name_short"
         android:supportsRtl="false"
         android:theme="@style/AppTheme"
         android:name=".Application">
 
         <activity
             android:name=".LaunchActivity"
             android:label="@string/app_name_short"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateHidden"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data
                     android:host="barbican.openyolo.org"
                     android:scheme="https" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".WelcomeActivity"
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".UnlockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".LockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="false" />
 
         <activity
             android:name=".CredentialListActivity"
             android:label="Stored Credentials"
             android:theme="@style/AppTheme"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity
             android:name=".CreateCredentialActivity"
             android:theme="@style/AppTheme"
             android:label="@string/create_credential_activity_label"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity android:name=".provider.RetrieveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.credential.retrieve"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.save"/>
                 <category android:name="org.openyolo" />
-                <!--
-                as this app only supports saving email based credentials, this is
-                declared using a data filter.
-                -->
-                <data
-                    android:scheme="openyolo"
-                    android:host="email" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".provider.HintPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="true">
             <intent-filter>
                 <action android:name="org.openyolo.hint"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialConfirmationActivity"
                   android:theme="@style/AppTheme.Dialog"
                   android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveAfterUnlockActivity"
                   android:theme="@style/AppTheme.NoUi"
                   android:excludeFromRecents="true" />
 
         <activity
             android:name=".provider.AutoSignInActivity"
             android:theme="@style/AutoSignInTheme"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".provider.CredentialPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".NeverSaveListActivity"
             android:theme="@style/AppTheme"/>
             android:exported="false" />
 
         <service
             android:name=".storage.CredentialStorageService"
             android:label="@string/credential_storage_service_label"
             android:enabled="true"
             android:exported="false"
             android:permission="org.openyolo.demoprovider.STORAGE"/>
 
         <receiver
             android:name=".provider.CredentialQueryReceiver"
             android:exported="true"
             android:enabled="true"
             tools:ignore="ExportedReceiver">
             <intent-filter>
                 <action android:name="org.openyolo.credential" />
                 <category android:name="com.google.bbq.QUERY" />
             </intent-filter>
         </receiver>
     </application>
 </manifest>
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
index 965ba95..a688ea2 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
@@ -24,2 +24,3 @@ import java.io.IOException;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.protocol.CredentialSaveResult;
 import org.openyolo.protocol.Protobufs.Credential;
@@ -28,61 +29,60 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * Writes a credential to the credential store after it is unlocked.
  */
 public class SaveAfterUnlockActivity extends AppCompatActivity {
 
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final String LOG_TAG = "SaveAfterUnlock";
 
     private Credential mCredential;
 
     /**
      * Creates an intent to save the provided credential after the store is unlocked.
      */
     public static Intent createIntent(Context context, Credential credentialProto) {
         Intent intent = new Intent(context, SaveAfterUnlockActivity.class);
         intent.putExtra(EXTRA_CREDENTIAL, credentialProto.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
             mCredential = Credential.parseFrom(credentialBytes);
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to decode credential to save");
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
-                final boolean success;
                 try {
                     client.upsertCredential(mCredential);
-                    runOnUiThread(new SendResultRunnable(RESULT_OK));
+                    runOnUiThread(new SendResultRunnable(CredentialSaveResult.SAVED));
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to store credential after save", e);
-                    runOnUiThread(new SendResultRunnable(RESULT_CANCELED));
+                    runOnUiThread(new SendResultRunnable(CredentialSaveResult.UNSPECIFIED));
                 }
 
                 client.disconnect(SaveAfterUnlockActivity.this);
             }
         });
     }
 
     private class SendResultRunnable implements Runnable {
-        private int mResultCode;
+        private final CredentialSaveResult mResult;
 
-        SendResultRunnable(int resultCode) {
-            mResultCode = resultCode;
+        SendResultRunnable(CredentialSaveResult result) {
+            mResult = result;
         }
 
         @Override
         public void run() {
-            setResult(mResultCode);
+            setResult(mResult.getResultCode(), mResult.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
index e687872..9bb9cce 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -27,3 +27,4 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialSaveRequest;
+import org.openyolo.protocol.CredentialSaveResult;
 import org.openyolo.protocol.ProtocolConstants;
@@ -31,110 +32,117 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * Verifies the rights to save a credential, before proceeding to
  * {@link SaveCredentialConfirmationActivity}.
  */
 public class SaveCredentialActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
 
-    private Credential mCredential;
+    private CredentialSaveRequest mRequest;
     private String mCallingPackage;
     private List<AuthenticationDomain> mAuthDomainsForApp;
-    private CredentialStorageClient mClient;
+    private CredentialStorageClient mStorageClient;
 
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        if (!getIntent().hasExtra(ProtocolConstants.EXTRA_CREDENTIAL)) {
-            Log.w(LOG_TAG, "No credential included in request");
-            finish(RESULT_CANCELED);
+        final byte[] encodedRequest =
+                getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_REQUEST);
+
+        // Ensure the intent contains a save request
+        if (null == encodedRequest) {
+            Log.w(LOG_TAG, "No save request included in intent");
+            finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
+        // Ensure the request can successfully be parsed from it's encoded form
         try {
-            mCredential = Credential.fromProtoBytes(
-                    getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_CREDENTIAL));
+            mRequest = CredentialSaveRequest.fromProtoBytes(encodedRequest);
         } catch (IOException ex) {
-            Log.w(LOG_TAG, "Failed to decode credential for save request");
-            finish(RESULT_CANCELED);
+            Log.w(LOG_TAG, "Failed to decode save request");
+            finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         if (!verifyCaller()) {
             Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
-                    + mCredential.getAuthenticationDomain());
-            finish(RESULT_CANCELED);
+                    + mRequest.getCredential().getAuthenticationDomain());
+            finishWithResult(CredentialSaveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(final CredentialStorageClient client) {
-                mClient = client;
+                mStorageClient = client;
                 runOnUiThread(new AfterStorageConnect());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
-        if (mClient != null) {
-            mClient.disconnect(this);
+        if (mStorageClient != null) {
+            mStorageClient.disconnect(this);
         }
     }
 
     @UiThread
-    private void finish(int resultCode) {
-        setResult(resultCode);
+    private void finishWithResult(CredentialSaveResult result) {
+        setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private boolean verifyCaller() {
-        ComponentName callingActivity = getCallingActivity();
+        final ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         mCallingPackage = callingActivity.getPackageName();
         mAuthDomainsForApp = AuthenticationDomain.listForPackage(this, mCallingPackage);
 
-        if (!mAuthDomainsForApp.contains(mCredential.getAuthenticationDomain())) {
+        final AuthenticationDomain authDomain = mRequest.getCredential().getAuthenticationDomain();
+        if (!mAuthDomainsForApp.contains(authDomain)) {
             Log.w(LOG_TAG, "App " + mCallingPackage
                     + " is not provably associated to authentication domain "
-                    + mCredential.getAuthenticationDomain()
+                    + authDomain
                     + " for the credential to be saved.");
             return false;
         }
 
 
         return true;
     }
 
     private final class AfterStorageConnect implements Runnable {
         @Override
         public void run() {
             try {
-                if (mClient.isOnNeverSaveList(mAuthDomainsForApp)) {
-                    finish(RESULT_CANCELED);
-                } else {
-                    // start confirm activity
-                    Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
-                            SaveCredentialActivity.this,
-                            mCallingPackage,
-                            mCredential);
-                    confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
-                    startActivity(confirmIntent);
-                    finish();
+                // Ensure authentication domain is not on never save list
+                if (mStorageClient.isOnNeverSaveList(mAuthDomainsForApp)) {
+                    finishWithResult(CredentialSaveResult.PROVIDER_REFUSED);
+                    return;
                 }
+
+                // Start confirm activity
+                Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
+                        SaveCredentialActivity.this,
+                        mCallingPackage,
+                        mRequest.getCredential());
+                confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+                startActivity(confirmIntent);
+                finish();
             } catch (IOException ex) {
-                finish(RESULT_CANCELED);
+                finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
index 174f5b4..4e49492 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -36,140 +36,141 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialSaveResult;
 
 /**
  * Confirms with the user whether they want to save a credential provided by the
  * calling app. Verification of the app's right to save such a credential occurs
  * in {@link SaveCredentialActivity} before reaching this point.
  */
 public class SaveCredentialConfirmationActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
     private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
 
     @BindView(R.id.save_prompt)
     TextView mSavePromptView;
 
     private Credential mCredential;
     private String mCallingAppName;
 
     private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
     private final CountDownLatch mClientConnected = new CountDownLatch(1);
 
     /**
      * Creates an intent to confirm whether the user wishes to save the specified credential.
      */
     public static Intent createIntent(
             Context context,
             String callingPackage,
             Credential credential) {
         Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
         intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toProtobuf().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mCredential = Credential.fromProtoBytes(
                     getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
         } catch (IOException e) {
             Log.e(LOG_TAG, "Unable to decode credential", e);
-            finish(RESULT_CANCELED);
+            finishWithResult(CredentialSaveResult.UNSPECIFIED);
         }
 
         try {
             PackageManager pm = getPackageManager();
             ApplicationInfo info = pm.getApplicationInfo(getCallingPackage(), 0);
             mCallingAppName = pm.getApplicationLabel(info).toString();
         } catch (PackageManager.NameNotFoundException e) {
             e.printStackTrace();
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 mClient.set(client);
                 mClientConnected.countDown();
             }
         });
 
         setContentView(R.layout.save_layout);
         ButterKnife.bind(this);
 
         String savePromptTemplate = getString(R.string.save_prompt_template);
         mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
     }
 
-    private void finish(int resultCode) {
-        setResult(resultCode);
+    private void finishWithResult(CredentialSaveResult result) {
+        setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         CredentialStorageClient client = mClient.get();
         if (client != null) {
             client.disconnect(this);
         }
     }
 
     @OnClick(R.id.save_button)
     void onSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
-            finish(RESULT_CANCELED);
+            finishWithResult(CredentialSaveResult.UNSPECIFIED);
             return;
         }
 
         if (client.isUnlocked()) {
             try {
                 client.upsertCredential(mCredential.toProtobuf());
-                finish(RESULT_OK);
+                finishWithResult(CredentialSaveResult.SAVED);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to write credential to storage");
-                finish(RESULT_CANCELED);
+                finishWithResult(CredentialSaveResult.UNSPECIFIED);
             }
         } else {
             Intent saveAfterUnlock = UnlockActivity.createIntent(
                     this,
                     true,
                     SaveAfterUnlockActivity.createIntent(this, mCredential.toProtobuf()));
             saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(saveAfterUnlock);
             finish();
         }
     }
 
     @OnClick(R.id.never_save_button)
     void onNeverSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
-            finish(RESULT_CANCELED);
+            finishWithResult(CredentialSaveResult.USER_REFUSED);
             return;
         }
 
         try {
             client.addToNeverSaveList(mCredential.getAuthenticationDomain());
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to add app to never save list", e);
         }
 
-        finish(RESULT_CANCELED);
+        finishWithResult(CredentialSaveResult.USER_REFUSED);
     }
 
     private CredentialStorageClient getStorageClient() {
         try {
             mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
             return mClient.get();
         } catch (InterruptedException e) {
             Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
             return null;
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index c999ab2..69644ae 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -46,290 +46,290 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class CredentialRetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
      */
     @NonNull
     public static CredentialRetrieveRequest forAuthenticationMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
-     * Creats a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
+     * Creates a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobuf(
             @NonNull Protobufs.CredentialRetrieveRequest proto) {
         return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
      * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
      * @throws IOException if the request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromProtobufBytes(
             @NonNull byte[] protoBytes)
             throws IOException {
         return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
     }
 
     /**
      * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
      * a request from the client to the provider activity.
      *
      * @throws IOException if the intent does not contain a retrieve request, or the contained
      *     request could not be parsed and validated.
      */
     @NonNull
     public static CredentialRetrieveRequest fromRequestIntent(
             @NonNull Intent requestIntent)
             throws IOException {
         if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
             throw new IOException("credential retrieve request missing in intent data");
         }
 
         return fromProtobufBytes(
                 requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
     }
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
     private CredentialRetrieveRequest(
             @NonNull Set<AuthenticationMethod> authMethods,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mAdditionalProps = additionalParams;
     }
 
     /**
      * The set of authentication methods that the requestor supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         if (mAdditionalProps.containsKey(key)) {
             return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         return mAdditionalProps.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
      * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
         public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
             validate(requestProto, notNullValue(), IllegalArgumentException.class);
 
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
          * @see CredentialRetrieveRequest#getAdditionalPropertyAsString(String)
          */
         public Builder addAdditionalProperty(
                 @NonNull String name,
                 @NonNull String value) {
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalProperty(String name, byte[] value) {
             validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public CredentialRetrieveRequest build() {
             return new CredentialRetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
     private static final class RetrieveRequestCreator
             implements Creator<CredentialRetrieveRequest> {
 
         @Override
         public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new CredentialRetrieveRequest.Builder(
                         Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public CredentialRetrieveRequest[] newArray(int size) {
             return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index e8cfba0..97bd8d6 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -32,245 +32,245 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the user selected a hint, that has been returned as part of this response.
      */
     public static final int CODE_CREDENTIAL_SELECTED =
             Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
      * Indicates that no credentials are available that meet the requirements of the credential
      * request.
      */
     public static final int CODE_NO_CREDENTIALS_AVAILABLE =
             Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they wish to proceed with authentication, but by manually entering their details.
      */
     public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
      * Indicates that the user canceled the selection of a credential in a manner that indicates
      * they do not wish to authenticate at this time.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Pre-built result that indicates the request was malformed. Carries no
      * credential or additional params.
      */
     public static final CredentialRetrieveResult BAD_REQUEST =
             new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built result that indicates that no credentials are available. Carries no credential or
      * additional params.
      */
     public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
             new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
 
     /**
      * Pre-built result that indicates the user wishes to manually authenticate.
      */
     public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
             new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
 
     /**
      * Pre-built result that indicates that the user does not want to authenticate at this time.
      */
     public static final CredentialRetrieveResult USER_CANCELED =
             new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
-     * Creates a credential retrieve request from its protocol buffer byte equivalent.
+     * Creates a credential retrieve result from its protocol buffer byte equivalent.
      * @throws IOException if the request could not be parsed or validated.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws IOException {
         return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
     }
 
     /**
-     * Creates a credential retrieve request from its protocol buffer equivalent.
+     * Creates a credential retrieve result from its protocol buffer equivalent.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto) {
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(
             int resultCode,
             Credential credential,
             Map<String, ByteString> additionalProps) {
         mResultCode = resultCode;
         mCredential = credential;
         mAdditionalProps = additionalProps;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          */
         public Builder(Protobufs.CredentialRetrieveResult proto) {
             setResultCode(proto.getResultCodeValue());
             setCredentialFromProto(proto.getCredential());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         public Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
             mCredential = credential != null ? Credential.fromProtobuf(credential) : null;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             require(additionalProperties, notNullValue());
             require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProperties.values(), everyItem(notNullValue()));
 
             mAdditionalProps =
                     CollectionConverter.convertMapValues(
                             additionalProperties,
                             ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProperties) {
             require(additionalProperties, notNullValue());
             require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProperties.values(), everyItem(notNullValue()));
 
             mAdditionalProps = additionalProperties;
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(mResultCode, mCredential, mAdditionalProps);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
new file mode 100644
index 0000000..bf01e19
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveRequest.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.CredentialConverter;
+
+/**
+ * A request to save a given {@link Credential credential}. To make the request the client
+ * encodes it in its associated protocol buffer byte array form in an activity intent
+ * via the {@link ProtocolConstants#EXTRA_SAVE_REQUEST} extra.
+ *
+ * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
+ *     OpenYOLO specification: Saving Credentials</a>
+ */
+public final class CredentialSaveRequest implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link CredentialSaveRequest} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<CredentialSaveRequest> CREATOR = new CredentialSaveRequestCreator();
+
+    @NonNull
+    private final Credential mCredential;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProperties;
+
+    /**
+     * Creates a credential save request from its protocol buffer byte array form.
+     * @throws IOException if the given save request could not be decoded.
+     *
+     * @see #toProtocolBuffer()
+     */
+    public static CredentialSaveRequest fromProtoBytes(byte[] credentialSaveRequestBytes)
+            throws IOException {
+        if (credentialSaveRequestBytes == null) {
+            throw new IOException("Unable to decode credential save request from null array");
+        }
+
+        Protobufs.CredentialSaveRequest request =
+                Protobufs.CredentialSaveRequest.parseFrom(credentialSaveRequestBytes);
+
+        return new CredentialSaveRequest.Builder(request).build();
+    }
+
+    /**
+     * Creates a credential save request from its protocol buffer form.
+     *
+     * @see #toProtocolBuffer()
+     */
+    public static CredentialSaveRequest fromProtobuf(Protobufs.CredentialSaveRequest request) {
+        return new CredentialSaveRequest.Builder(request).build();
+    }
+
+    /**
+     * Creates a {@link CredentialSaveRequest} from the given {@link Credential}.
+     */
+    public static CredentialSaveRequest fromCredential(Credential credential) {
+        return new Builder(credential).build();
+    }
+
+    private CredentialSaveRequest(Builder builder) {
+        mCredential = builder.mCredential;
+        mAdditionalProperties = Collections.unmodifiableMap(builder.mAdditionalProps);
+    }
+
+    /**
+     * The credential to be saved.
+     */
+    @NonNull
+    public Credential getCredential() {
+        return mCredential;
+    }
+
+    /**
+     * The map of additional, non-standard properties included with this request.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+            mAdditionalProperties,
+            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        byte[] protoBytes = toProtocolBuffer().toByteArray();
+        dest.writeInt(protoBytes.length);
+        dest.writeByteArray(protoBytes);
+    }
+
+    /**
+     * Converts the request into a protocol buffer, for storage or transmission.
+     */
+    public Protobufs.CredentialSaveRequest toProtocolBuffer() {
+        return Protobufs.CredentialSaveRequest.newBuilder()
+                .setClientVersion(ClientVersionUtil.getClientVersion())
+                .setCredential(mCredential.toProtobuf())
+                .putAllAdditionalProps(mAdditionalProperties)
+                .build();
+    }
+
+    /**
+     * Creates {@link CredentialSaveRequest} instances.
+     */
+    public static final class Builder {
+
+        private Credential mCredential;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Recreates a save request from its protocol buffer form.
+         *
+         * @see CredentialSaveRequest#toProtocolBuffer()
+         */
+        public Builder(@NonNull Protobufs.CredentialSaveRequest request) {
+            require(request, notNullValue());
+
+            setCredential(CredentialConverter.PROTO_TO_CREDENTIAL.convert(request.getCredential()));
+            setAdditionalProperties(
+                    CollectionConverter.convertMapValues(
+                            request.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        }
+
+        /**
+         * Starts the process of defining a save request, specifying the credential to be saved.
+         *
+         * @see Credential
+         */
+        public Builder(@NonNull Credential credential) {
+            setCredential(credential);
+        }
+
+        /**
+         * Specifies the credential to be saved. The provided credential must be non-null.
+         *
+         * @see Credential
+         */
+        public Builder setCredential(@NonNull Credential credential) {
+            require(credential, notNullValue());
+
+            mCredential = credential;
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to carry with the credential
+         * save request. A null map is treated as an empty map.
+         */
+        @NonNull
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalParams) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalParams);
+            return this;
+        }
+
+        /**
+         * Finalizes the creation of the credential save request.
+         */
+        public CredentialSaveRequest build() {
+            return new CredentialSaveRequest(this);
+        }
+    }
+
+    private static final class CredentialSaveRequestCreator
+            implements Creator<CredentialSaveRequest> {
+        @Override
+        public CredentialSaveRequest createFromParcel(Parcel source) {
+            int length = source.readInt();
+            byte[] encodedRequest = new byte[length];
+            source.readByteArray(encodedRequest);
+
+            try {
+                return CredentialSaveRequest.fromProtoBytes(encodedRequest);
+            } catch (IOException ex) {
+                throw new IllegalStateException("Unable to read proto from parcel", ex);
+            }
+        }
+
+        @Override
+        public CredentialSaveRequest[] newArray(int size) {
+            return new CredentialSaveRequest[0];
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/CredentialSaveResult.java b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
new file mode 100644
index 0000000..afd9cb2
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/CredentialSaveResult.java
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * Result data which is sent in response to a credential save request. Contains a result code,
+ * indicating whether the request was successful or not, and an optional set of additional,
+ * non-standard result properties.
+ *
+ * @see <a href="https://spec.openyolo.org/openyolo-android-spec.html#saving-credentials">
+ *     OpenYOLO specification: Saving Credentials</a>
+ */
+public final class CredentialSaveResult {
+
+    /**
+     * Indicates that the provider returned a response that could not be interpreted.
+     */
+    public static final int CODE_UNKNOWN =
+            Protobufs.CredentialSaveResult.ResultCode.UNSPECIFIED_VALUE;
+
+    /**
+     * Indicates that the credential request sent to the provider was malformed.
+     */
+    public static final int CODE_BAD_REQUEST =
+            Protobufs.CredentialSaveResult.ResultCode.BAD_REQUEST_VALUE;
+
+    /**
+     * Indicates that the credential sent to the provider was saved.
+     */
+    public static final int CODE_SAVED =
+            Protobufs.CredentialSaveResult.ResultCode.SAVED_VALUE;
+
+    /**
+     * Indicates the provider refused to save the credential, due to some policy restriction. For
+     * example, a provider may refuse to update an existing credential if it is stored in a shared
+     * keychain. The client SHOULD NOT request to save this credential again.
+     */
+    public static final int CODE_PROVIDER_REFUSED =
+            Protobufs.CredentialSaveResult.ResultCode.PROVIDER_REFUSED_VALUE;
+
+    /**
+     * Indicates that the user dismissed the request to save the credential, by either pressing the
+     * back button, clicking outside the area of a modal dialog, or some other "soft" cancellation
+     * that is not an explicit refusal to delete the credential. The client MAY request to save this
+     * credential again at a later time.
+     */
+    public static final int CODE_USER_CANCELED =
+            Protobufs.CredentialSaveResult.ResultCode.USER_CANCELED_VALUE;
+
+    /**
+     * Indicates the user refused the request to save this credential. The client SHOULD NOT request
+     * to save this credential again.
+     */
+    public static final int CODE_USER_REFUSED =
+            Protobufs.CredentialSaveResult.ResultCode.USER_REFUSED_VALUE;
+
+    /**
+     * Pre-built save result for an unspecified outcome. Carries no additional properties.
+     */
+    public static final CredentialSaveResult UNSPECIFIED =
+            new CredentialSaveResult.Builder(CODE_UNKNOWN).build();
+
+    /**
+     * Pre-built save result that indicates the credential was saved. Carries no additional
+     * properties.
+     */
+    public static final CredentialSaveResult SAVED =
+            new CredentialSaveResult.Builder(CODE_SAVED).build();
+
+    /**
+     * Pre-built save result that indicates the request was malformed. Carries no additional
+     * properties.
+     */
+    public static final CredentialSaveResult BAD_REQUEST =
+            new CredentialSaveResult.Builder(CODE_BAD_REQUEST).build();
+
+    /**
+     * Pre-built save result that indicates the request was refused by the user. Carries no
+     * additional properties.
+     */
+    public static final CredentialSaveResult USER_REFUSED =
+            new CredentialSaveResult.Builder(CODE_USER_REFUSED).build();
+
+    /**
+     * Pre-built save result that indicates the request was refused by the provider. Carries no
+     * additional properties.
+     */
+    public static final CredentialSaveResult PROVIDER_REFUSED =
+            new CredentialSaveResult.Builder(CODE_PROVIDER_REFUSED).build();
+
+    private final int mResultCode;
+
+    @NonNull
+    private Map<String, ByteString> mAdditionalProperties;
+
+    /**
+     * Creates a credential save result from its protocol buffer byte equivalent.
+     * @throws IOException if the result could not be parsed or validated.
+     */
+    public static CredentialSaveResult fromProtobufBytes(byte[] protobufBytes)
+            throws IOException {
+        return fromProtobuf(Protobufs.CredentialSaveResult.parseFrom(protobufBytes));
+    }
+
+    /**
+     * Creates a credential save result from its protocol buffer equivalent.
+     */
+    public static CredentialSaveResult fromProtobuf(Protobufs.CredentialSaveResult proto) {
+        return new CredentialSaveResult.Builder(proto).build();
+    }
+
+    /**
+     * Creates a protocol buffer representation of the credential save result, for transmission
+     * or storage.
+     */
+    public Protobufs.CredentialSaveResult toProtobuf() {
+        Protobufs.CredentialSaveResult.Builder builder =
+                Protobufs.CredentialSaveResult.newBuilder()
+                        .setResultCodeValue(mResultCode)
+                        .putAllAdditionalProps(mAdditionalProperties);
+
+        return builder.build();
+    }
+
+    /**
+     * Creates an {@link Intent} containing this credential save result, that a provider should
+     * return as its activity result.
+     */
+    public Intent toResultDataIntent() {
+        Intent intent = new Intent();
+        intent.putExtra(
+                ProtocolConstants.EXTRA_SAVE_RESULT,
+                toProtobuf().toByteArray());
+        return intent;
+    }
+
+    private CredentialSaveResult(Builder builder) {
+        mResultCode = builder.mResultCode;
+        mAdditionalProperties = builder.mAdditionalProps;
+    }
+
+    /**
+     * The result code for the credential save operation.
+     */
+    @NonNull
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    /**
+     * The additional, non-standard properties returned by the credential provider, if available.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProperties,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Creates {@link CredentialSaveResult} instances.
+     */
+    public static final class Builder {
+        private int mResultCode = CODE_UNKNOWN;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Starts the process of describing a credential retrieve result given the mandatory status
+         * code.
+         */
+        public Builder(Protobufs.CredentialSaveResult proto) {
+            require(proto, notNullValue());
+
+            setResultCode(proto.getResultCodeValue());
+            setAdditionalProperties(
+                    CollectionConverter.convertMapValues(
+                            proto.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+        }
+
+        /**
+         * Seeds a credential save result from its protocol buffer equivalent.
+         */
+        public Builder(int resultCode) {
+            setResultCode(resultCode);
+        }
+
+        /**
+         * Specifies the result code. It is recommended to use one of the standard values, though
+         * any value may be used.
+         */
+        public Builder setResultCode(int resultCode) {
+            mResultCode = resultCode;
+
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to carry with the credential
+         * deletion request. A null map is treated as an empty map.
+         */
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+
+            return this;
+        }
+
+        /**
+         * Finalizes the creation of the credential save result.
+         */
+        public CredentialSaveResult build() {
+            return new CredentialSaveResult(this);
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
index b5497d4..adb893e 100644
--- a/protocol/java/org/openyolo/protocol/ProtocolConstants.java
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -17,74 +17,79 @@ package org.openyolo.protocol;
 /**
  * Defines key constants that are used to identify data carried in intents.
  */
 public final class ProtocolConstants {
 
     /**
      * The data type used for credential queries using the BBQ protocol.
      */
     public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
 
-    /**
-     * The extra value key used to store the credential in a retrieve intent response.
-     */
-    public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
-
     /**
      * The extra value key used to carry a credential retrieve request.
      */
     public static final String EXTRA_RETRIEVE_REQUEST = "org.openyolo.credential.retrieve.request";
 
     /**
      * The extra value key used to carry a credential retrieve result.
      */
     public static final String EXTRA_RETRIEVE_RESULT = "org.openyolo.credential.retrieve.result";
 
     /**
      * The extra key value used to carry a hint request.
      */
     public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
 
     /**
      * The extra key value used to carry a hint result.
      */
     public static final String EXTRA_HINT_RESULT = "org.openyolo.hint.result";
 
+    /**
+     * The extra key value used to carry a credential save request.
+     */
+    public static final String EXTRA_SAVE_REQUEST = "org.openyolo.credential.save.request";
+
+    /**
+     * The extra key value used to carry a credential save result.
+     */
+    public static final String EXTRA_SAVE_RESULT = "org.openyolo.credential.save.result";
+
     /**
      * The category used for all OpenYOLO-related intents.
      */
     public static final String OPENYOLO_CATEGORY = "org.openyolo";
 
     /**
      * The action used for credential retrieval request intents.
      */
     public static final String RETRIEVE_CREDENTIAL_ACTION = "org.openyolo.credential.retrieve";
 
     /**
      * The action used for hint intents.
      */
     public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
 
     /**
      * The action used for save intents.
      */
-    public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
+    public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.credential.save";
 
     /**
      * The action used for delete intents.
      */
     public static final String DELETE_CREDENTIAL_ACTION = "org.openyolo.credential.delete";
 
     /**
      * The extra key value used to carry a credential deletion request.
      */
     public static final String EXTRA_DELETE_REQUEST = "org.openyolo.credential.delete.request";
 
     /**
      * The extra key value used to carry a credential deletion result.
      */
     public static final String EXTRA_DELETE_RESULT = "org.openyolo.credential.delete.result";
 
     private ProtocolConstants() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
new file mode 100644
index 0000000..51debb3
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveRequestTest.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.os.Parcel;
+import java.io.IOException;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.TextFixtures.ValidProperties;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/** Unit tests for {@link CredentialSaveRequest} */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class CredentialSaveRequestTest {
+
+    private static final class ValidClientVersion {
+        public static final int MAJOR = 1;
+        public static final int MINOR = 2;
+        public static final int PATCH = 3;
+        public static final String VENDOR = "com.customVendor";
+
+        public static final Protobufs.ClientVersion INSTANCE = Protobufs.ClientVersion.newBuilder()
+                .setMajor(MAJOR)
+                .setMinor(MINOR)
+                .setPatch(PATCH)
+                .setVendor(VENDOR)
+                .build();
+    }
+
+    private static final class ValidRequest {
+        public static final Credential CREDENTIAL = ValidCredential.INSTANCE;
+        public static final Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+
+        public static final CredentialSaveRequest INSTANCE =
+                new CredentialSaveRequest.Builder(CREDENTIAL)
+                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+                        .build();
+
+        public static void assertEqualTo(CredentialSaveRequest request) {
+            ValidCredential.assertEqualTo(request.getCredential());
+            ValidProperties.assertEqualTo(request.getAdditionalProperties());
+        }
+
+        public static void assertEqualTo(Protobufs.CredentialSaveRequest request) {
+            ValidCredential.assertEqualTo(request.getCredential());
+            assertThat(request.getClientVersion()).isEqualTo(ValidClientVersion.INSTANCE);
+
+            final Map<String, byte[]> additionalProperties =
+                    CollectionConverter.convertMapValues(
+                            request.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+
+            ValidProperties.assertEqualTo(additionalProperties);
+        }
+    }
+
+    private static final class ValidCredential {
+        public final static String ID = "Credential ID";
+        public final static String AUTHENTICATION_DOMAIN_STRING = "https://.google.com";
+        public final static AuthenticationMethod AUTHENTICATION_METHOD =
+                AuthenticationMethods.FACEBOOK;
+        public final static AuthenticationDomain AUTHENTICATION_DOMAIN =
+                new AuthenticationDomain(AUTHENTICATION_DOMAIN_STRING);
+
+        public final static Credential INSTANCE =
+                new Credential.Builder(ID, AUTHENTICATION_METHOD, AUTHENTICATION_DOMAIN).build();
+
+        public static void assertEqualTo(Credential credential) {
+            assertThat(credential.getIdentifier()).isEqualTo(ID);
+        }
+
+        public static void assertEqualTo(Protobufs.Credential credential) {
+            assertThat(credential.getId()).isEqualTo(ID);
+        }
+    }
+
+    @Before
+    public void setup() {
+        ClientVersionUtil.setClientVersion(ValidClientVersion.INSTANCE);
+    }
+
+    @Test(expected = IOException.class)
+    public void fromProtoBytes_withNull_throwsIOException() throws Exception {
+        CredentialSaveRequest.fromProtoBytes(null /* bytes */);
+    }
+
+    @Test()
+    public void fromProtoBytes_withValidRequestBytes_returnsEquivalentRequest() throws Exception {
+        final byte[] encodedRequest = ValidRequest.INSTANCE.toProtocolBuffer().toByteArray();
+
+        final CredentialSaveRequest request = CredentialSaveRequest.fromProtoBytes(encodedRequest);
+
+        ValidRequest.assertEqualTo(request);
+    }
+
+    @Test
+    public void forCredential_withValidCredential_returnsRequestForCredential() {
+        final CredentialSaveRequest request =
+                CredentialSaveRequest.fromCredential(ValidCredential.INSTANCE);
+
+        assertThat(request.getCredential()).isSameAs(ValidCredential.INSTANCE);
+        assertThat(request.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void parcelAndUnparcel_withValidCredential_isEqual() {
+        Parcel parcel = Parcel.obtain();
+        ValidRequest.INSTANCE.writeToParcel(parcel, 0);
+        parcel.setDataPosition(0);
+        final CredentialSaveRequest request =
+                CredentialSaveRequest.CREATOR.createFromParcel(parcel);
+
+        ValidRequest.assertEqualTo(request);
+    }
+
+    @Test
+    public void toProtocolBuffer_withValidCredential_containsClientVersion() {
+        final Protobufs.CredentialSaveRequest protoRequest =
+                ValidRequest.INSTANCE.toProtocolBuffer();
+
+        ValidRequest.assertEqualTo(protoRequest);
+    }
+
+    @Test
+    public void builder_withValidCredential_resultIsEqual() {
+        final CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidCredential.INSTANCE).build();
+
+        assertThat(request.getCredential()).isSameAs(ValidCredential.INSTANCE);
+        assertThat(request.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void builder_withNullCredential_throwsRequiresViolation() {
+        new CredentialSaveRequest.Builder((Credential) null);
+    }
+
+    @Test
+    public void builder_withValidProto_resultIsEqual() {
+        final CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidRequest.INSTANCE.toProtocolBuffer()).build();
+
+        assertThat(request.getCredential().getIdentifier()).isEqualTo(ValidCredential.ID);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void builder_withNullProto_throwsRequiresViolation() {
+        new CredentialSaveRequest.Builder((Protobufs.CredentialSaveRequest) null);
+    }
+
+    public void builder_setAdditionalPropertiesWithNull_returnsEmptyMap() {
+        CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
+                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
+                        .setAdditionalProperties(null)
+                        .build();
+
+        assertThat(request.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void builder_setAdditionalProperties_isSuccessful() {
+        final CredentialSaveRequest request =
+                new CredentialSaveRequest.Builder(ValidRequest.CREDENTIAL)
+                        .setAdditionalProperties(ValidRequest.ADDITIONAL_PROPERTIES)
+                        .build();
+
+        ValidProperties.assertEqualTo(request.getAdditionalProperties());
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
new file mode 100644
index 0000000..1c0dd27
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/CredentialSaveResultTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.content.Intent;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.TextFixtures.ValidProperties;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/** Unit tests for {@link CredentialSaveResult} */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public final class CredentialSaveResultTest {
+
+    private static final class ValidResult {
+        public static int RESULT_CODE = CredentialSaveResult.CODE_SAVED;
+        public static Map<String, byte[]> ADDITIONAL_PROPERTIES = ValidProperties.MAP_INSTANCE;
+
+        public static final CredentialSaveResult INSTANCE =
+                new CredentialSaveResult.Builder(RESULT_CODE)
+                        .setAdditionalProperties(ADDITIONAL_PROPERTIES)
+                        .build();
+
+        public static void assertEqualTo(CredentialSaveResult result) {
+            assertThat(result.getResultCode()).isEqualTo(RESULT_CODE);
+            ValidProperties.assertEqualTo(result.getAdditionalProperties());
+        }
+
+        public static void assertEqualTo(Protobufs.CredentialSaveResult resultProto) {
+            assertThat(resultProto.getResultCodeValue()).isEqualTo(RESULT_CODE);
+
+            final Map<String, byte[]> additionalProperties =
+                    CollectionConverter.convertMapValues(
+                            resultProto.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+
+            ValidProperties.assertEqualTo(additionalProperties);
+        }
+    }
+
+    @Test
+    public void fromProtobufBytes_withValidProto_returnsEquivalentResult() throws Exception {
+        final CredentialSaveResult result =
+                CredentialSaveResult.fromProtobufBytes(
+                        ValidResult.INSTANCE.toProtobuf().toByteArray());
+
+        ValidResult.assertEqualTo(result);
+    }
+
+    @Test
+    public void fromProtobuf_withValidProto_returnsEquivalentResult() throws Exception {
+        final CredentialSaveResult result =
+                CredentialSaveResult.fromProtobuf(ValidResult.INSTANCE.toProtobuf());
+
+        ValidResult.assertEqualTo(result);
+    }
+
+    @Test
+    public void toProtobuf_withValidResult_returnsEquivalentResult() throws Exception {
+        ValidResult.assertEqualTo(ValidResult.INSTANCE.toProtobuf());
+    }
+
+    @Test
+    public void toResultDataIntent_withValidResult_returnsValidIntent() throws Exception {
+        final Intent resultIntent = ValidResult.INSTANCE.toResultDataIntent();
+
+        final byte[] encodedResult =
+                resultIntent.getByteArrayExtra(ProtocolConstants.EXTRA_SAVE_RESULT);
+        ValidResult.assertEqualTo(CredentialSaveResult.fromProtobufBytes(encodedResult));
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void builder_withNullProto_throwsRequiresViolation() {
+        new CredentialSaveResult.Builder(null);
+    }
+
+    @Test
+    public void builder_setAdditionalProperties_isSuccessful() {
+        final CredentialSaveResult result =
+                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
+                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
+                        .build();
+
+        ValidResult.assertEqualTo(result);
+    }
+
+    @Test
+    public void builder_setAdditionalPropertiesWithNull_isEmptyMap() {
+        CredentialSaveResult result =
+                new CredentialSaveResult.Builder(ValidResult.RESULT_CODE)
+                        .setAdditionalProperties(ValidResult.ADDITIONAL_PROPERTIES)
+                        .setAdditionalProperties(null)
+                        .build();
+
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/TextFixtures.java b/protocol/javatests/org/openyolo/protocol/TextFixtures.java
new file mode 100644
index 0000000..563c0a0
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/TextFixtures.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** Collection of shared test constants */
+public final class TextFixtures {
+    public static final class ValidProperties {
+        public static final String PROPERTY_A_NAME = "Property A";
+        public static final byte[] PROPERTY_A_VALUE = new byte [] { 0, 1 };
+
+        public static final String PROPERTY_B_NAME = "Property B";
+        public static final byte[] PROPERTY_B_VALUE = new byte [] { 2, 2 };
+
+        public static final Map<String, byte[]> MAP_INSTANCE;
+
+        static {
+            MAP_INSTANCE = new HashMap<>();
+            MAP_INSTANCE.put(PROPERTY_A_NAME, PROPERTY_A_VALUE);
+            MAP_INSTANCE.put(PROPERTY_B_NAME, PROPERTY_B_VALUE);
+        }
+
+        public static void assertEqualTo(Map<String, byte[]> map) {
+            assertThat(map).hasSize(2);
+            assertThat(map.get(PROPERTY_A_NAME)).isEqualTo(PROPERTY_A_VALUE);
+            assertThat(map.get(PROPERTY_B_NAME)).isEqualTo(PROPERTY_B_VALUE);
+        }
+    }
+}
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index a7e4833..fd3508f 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -16,5 +16,2 @@ package org.openyolo.testapp;
 
-import static android.app.Activity.RESULT_CANCELED;
-import static android.app.Activity.RESULT_OK;
-
 import android.content.Intent;
@@ -31,73 +28,93 @@ import org.openyolo.api.CredentialClient;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialSaveRequest;
+import org.openyolo.protocol.CredentialSaveResult;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
 public final class SaveTestPageFragment extends TestPageFragment {
 
     private static final int RC_SAVE = 0;
 
     @BindView(R.id.save_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Save";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.save_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.save_button)
     void onSave() {
-        Credential credential = mCredentialView.makeCredentialFromFields();
-        Intent saveIntent = mApi.getSaveIntent(credential);
+        final Credential credential = mCredentialView.makeCredentialFromFields();
+        final CredentialSaveRequest request = CredentialSaveRequest.fromCredential(credential);
+        final Intent saveIntent = mApi.getSaveIntent(request);
+
         if (saveIntent == null) {
             showSnackbar(R.string.no_available_save_providers);
             return;
         }
 
         startActivityForResult(saveIntent, RC_SAVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_SAVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
-        if (resultCode == RESULT_OK) {
-            showSnackbar(R.string.credential_saved);
-            return;
-        } else if (resultCode == RESULT_CANCELED) {
-            showSnackbar(R.string.credential_save_canceled);
-        } else {
-            showSnackbar(R.string.unknown_response);
+        CredentialSaveResult result = mApi.getCredentialSaveResult(data);
+
+        int resultMessageId;
+        switch (result.getResultCode()) {
+            case CredentialSaveResult.CODE_SAVED:
+                resultMessageId = R.string.save_result_saved;
+                break;
+            case CredentialSaveResult.CODE_BAD_REQUEST:
+                resultMessageId = R.string.save_result_bad_request;
+                break;
+            case CredentialSaveResult.CODE_PROVIDER_REFUSED:
+                resultMessageId = R.string.save_result_provider_refused;
+                break;
+            case CredentialSaveResult.CODE_USER_CANCELED:
+                resultMessageId = R.string.save_result_user_canceled;
+                break;
+            case CredentialSaveResult.CODE_USER_REFUSED:
+                resultMessageId = R.string.save_result_user_refused;
+                break;
+            default:
+                resultMessageId = R.string.save_result_unkown;
         }
+
+        showSnackbar(resultMessageId);
     }
 }
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 3929276..1232314 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,80 +1,85 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
-    <string name="credential_saved">Credential saved</string>
-    <string name="credential_save_canceled">Credential save canceled</string>
+    <string name="save_result_unkown">Unknown save result</string>
+    <string name="save_result_saved">Credential Saved</string>
+    <string name="save_result_bad_request">Malformed save request</string>
+    <string name="save_result_provider_refused">Provider refused save request</string>
+    <string name="save_result_user_canceled">User canceled save request</string>
+    <string name="save_result_user_refused">User refused save request</string>
+
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Delete Test -->
     <string name="delete_button_label">Delete Credential</string>
     <string name="delete_button_content_description">Delete a credential</string>
     <string name="no_available_delete_providers">"No available providers can delete this credential</string>
     <string name="delete_result_deleted">Credential deleted</string>
     <string name="delete_result_no_matching_credential">No matching credential to delete</string>
     <string name="delete_result_provider_refused">Provider refused deletion</string>
     <string name="delete_result_user_canceled">User canceled deletion</string>
     <string name="delete_result_user_refused">User refused deletion</string>
     <string name="delete_result_bad_request">Bad delete request</string>
     <string name="delete_result_unknown_response">Unknown delete response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
     <string name="invalid_credential_data">Credential data is invalid</string>
 
 </resources>

commit bed4a435c3282bbd431fa59d7920f1bc6c219ff4
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Fri May 5 18:52:26 2017 -0700

    Delete testing page

diff --git a/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
new file mode 100644
index 0000000..6420c01
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/DeleteTestPageFragment.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.StringRes;
+import android.support.design.widget.Snackbar;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialDeleteResult;
+
+/**
+ * Fragment which contains a method of testing the OpenYolo credential deletion flow.
+ */
+public class DeleteTestPageFragment extends TestPageFragment  {
+
+    private static final int RC_DELETE = 100;
+
+    @BindView(R.id.credential_to_delete)
+    CredentialView mCredentialView;
+
+    private CredentialClient mApi;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mApi = CredentialClient.getApplicationBoundInstance(getActivity());
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.delete_test_layout, container, false);
+
+        ButterKnife.bind(this, view);
+        mCredentialView.setEnableInputGeneration(true);
+
+        return view;
+    }
+
+    @OnClick(R.id.delete_button)
+    void onDelete() {
+        Credential credential = mCredentialView.makeCredentialFromFields();
+        if (credential == null) {
+            showSnackbar(R.string.invalid_credential_data);
+            return;
+        }
+
+        Intent deleteIntent = mApi.getDeleteIntent(credential);
+        if (deleteIntent == null) {
+            showSnackbar(R.string.no_available_delete_providers);
+            return;
+        }
+
+        startActivityForResult(deleteIntent, RC_DELETE);
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (requestCode != RC_DELETE) {
+            showSnackbar(R.string.unknown_response);
+            return;
+        }
+
+        CredentialDeleteResult deleteResult = mApi.getDeleteResult(data);
+
+        @StringRes
+        int resultMessageId;
+        switch (deleteResult.getResultCode()) {
+            case CredentialDeleteResult.CODE_DELETED:
+                resultMessageId = R.string.delete_result_deleted;
+                break;
+            case CredentialDeleteResult.CODE_NO_MATCHING_CREDENTIAL:
+                resultMessageId = R.string.delete_result_no_matching_credential;
+                break;
+            case CredentialDeleteResult.CODE_PROVIDER_REFUSED:
+                resultMessageId = R.string.delete_result_provider_refused;
+                break;
+            case CredentialDeleteResult.CODE_USER_CANCELED:
+                resultMessageId = R.string.delete_result_user_canceled;
+                break;
+            case CredentialDeleteResult.CODE_USER_REFUSED:
+                resultMessageId = R.string.delete_result_user_refused;
+                break;
+            case CredentialDeleteResult.CODE_BAD_REQUEST:
+                resultMessageId = R.string.delete_result_bad_request;
+                break;
+            default:
+                resultMessageId = R.string.delete_result_unknown_response;
+        }
+
+        showSnackbar(resultMessageId);
+    }
+
+    @Override
+    public String getPageTitle() {
+        return "Delete";
+    }
+
+    private void showSnackbar(@StringRes int messageId) {
+        Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
+    }
+}
diff --git a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
index 0b77c6e..2d74043 100644
--- a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
+++ b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
@@ -28,52 +28,53 @@ import java.util.List;
 /**
  * The main OpenYolo test activity.
  */
 public final class OpenYoloTestActivity extends AppCompatActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.main_layout);
 
         setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
 
         final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
         DemoPagerAdapter demoPagerAdapter = new DemoPagerAdapter(getSupportFragmentManager());
         demoPagerAdapter.addPage(new RetrieveTestPageFragment());
         demoPagerAdapter.addPage(new SaveTestPageFragment());
         demoPagerAdapter.addPage(new HintTestPageFragment());
+        demoPagerAdapter.addPage(new DeleteTestPageFragment());
 
         viewPager.setAdapter(demoPagerAdapter);
         TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
         tabLayout.setupWithViewPager(viewPager);
     }
 
     private static class DemoPagerAdapter extends FragmentPagerAdapter {
 
         private final List<TestPageFragment> mPages = new ArrayList<>();
 
         DemoPagerAdapter(FragmentManager fragmentManager) {
             super(fragmentManager);
         }
 
         @Override
         public int getCount() {
             return mPages.size();
         }
 
         public void addPage(TestPageFragment pageFragment) {
             mPages.add(pageFragment);
         }
 
         @Override
         public Fragment getItem(int position) {
             return mPages.get(position);
         }
 
         @Override
         public CharSequence getPageTitle(int position) {
             return mPages.get(position).getPageTitle();
         }
     }
 }
diff --git a/testapp/res/layout/delete_test_layout.xml b/testapp/res/layout/delete_test_layout.xml
new file mode 100644
index 0000000..7f7e29d
--- /dev/null
+++ b/testapp/res/layout/delete_test_layout.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.NestedScrollView
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent"
+  app:layout_behavior="@string/appbar_scrolling_view_behavior"
+  style="@style/DemoContent">
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <TextView
+      style="@style/Headline"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/request"/>
+
+    <org.openyolo.testapp.CredentialView
+      android:id="@+id/credential_to_delete"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent">
+    </org.openyolo.testapp.CredentialView>
+
+    <Button
+      android:id="@+id/delete_button"
+      style="@style/Widget.AppCompat.Button.Colored"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="16dp"
+      android:layout_marginLeft="8dp"
+      android:layout_marginRight="8dp"
+      android:layout_gravity="center_horizontal"
+      android:contentDescription="@string/delete_button_content_description"
+      android:text="@string/delete_button_label"
+      android:theme="@style/GreenButtonThemeOverlay"/>
+
+  </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 4e5a6a5..3929276 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,67 +1,80 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
 
     <string name="retrieve_unknown_response">Unknown retrieve response</string>
     <string name="retrieve_bad_request">Bad credential request</string>
     <string name="retrieve_no_credentials">No credentials available</string>
     <string name="retrieve_user_canceled">User canceled retrieve request</string>
     <string name="retrieve_manual_auth">User requests manual auth</string>
 
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
+    <!-- Delete Test -->
+    <string name="delete_button_label">Delete Credential</string>
+    <string name="delete_button_content_description">Delete a credential</string>
+    <string name="no_available_delete_providers">"No available providers can delete this credential</string>
+    <string name="delete_result_deleted">Credential deleted</string>
+    <string name="delete_result_no_matching_credential">No matching credential to delete</string>
+    <string name="delete_result_provider_refused">Provider refused deletion</string>
+    <string name="delete_result_user_canceled">User canceled deletion</string>
+    <string name="delete_result_user_refused">User refused deletion</string>
+    <string name="delete_result_bad_request">Bad delete request</string>
+    <string name="delete_result_unknown_response">Unknown delete response</string>
+
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
+    <string name="invalid_credential_data">Credential data is invalid</string>
 
 </resources>

commit f8808565a1f2dcb85c7726d9959b539259b7f3d4
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Fri May 5 17:50:25 2017 -0700

    Add client API methods for delete, catchable validation for providers

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index ccc078f..2fac906 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -16,4 +16,7 @@ package org.openyolo.api;
 
+import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.openyolo.protocol.ProtocolConstants.CREDENTIAL_DATA_TYPE;
+import static org.openyolo.protocol.ProtocolConstants.DELETE_CREDENTIAL_ACTION;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_DELETE_REQUEST;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_HINT_REQUEST;
@@ -24,2 +27,3 @@ import static org.openyolo.protocol.ProtocolConstants.OPENYOLO_CATEGORY;
 import static org.openyolo.protocol.ProtocolConstants.SAVE_CREDENTIAL_ACTION;
+import static org.valid4j.Assertive.require;
 
@@ -44,2 +48,4 @@ import org.openyolo.api.ui.ProviderPickerActivity;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialDeleteRequest;
+import org.openyolo.protocol.CredentialDeleteResult;
 import org.openyolo.protocol.CredentialRetrieveRequest;
@@ -48,2 +54,3 @@ import org.openyolo.protocol.HintRetrieveRequest;
 import org.openyolo.protocol.HintRetrieveResult;
+import org.openyolo.protocol.MalformedDataException;
 import org.openyolo.protocol.Protobufs;
@@ -54,350 +61,414 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
                 findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedCredential = credentialToSave.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedCredential);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedCredential));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
+    /**
+     * Provides an intent to delete a credential. If no compatible credential providers exist
+     * on the device, {@code null} will be returned. The intent should be started with a call
+     * to {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
+     *
+     * <p>Upon completion of the request, the result data will be returned in the Intent passed
+     * to {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}, and
+     * can be extracted by calling {@link #getDeleteResult(Intent)}.
+     */
+    @Nullable
+    public Intent getDeleteIntent(@NonNull Credential credentialToDelete) {
+        require(credentialToDelete, notNullValue());
+        List<ComponentName> deleteProviders =
+                findProviders(DELETE_CREDENTIAL_ACTION);
+
+        if (deleteProviders.isEmpty()) {
+            return null;
+        }
+
+        CredentialDeleteRequest request =
+                new CredentialDeleteRequest.Builder(credentialToDelete).build();
+
+        byte[] encodedRequest = request.toProtobuf().toByteArray();
+
+        // if there is a preferred provider, directly invoke it.
+        ComponentName preferredDeleteActivity = getPreferredProvider(deleteProviders);
+        if (preferredDeleteActivity != null) {
+            return createDeleteIntent(preferredDeleteActivity, encodedRequest);
+        }
+
+        // otherwise, display a picker for all the providers
+        ArrayList<Intent> deleteIntents = new ArrayList<>(deleteProviders.size());
+        for (ComponentName providerActivity : deleteProviders) {
+            deleteIntents.add(createDeleteIntent(
+                    providerActivity,
+                    encodedRequest));
+        }
+
+        return ProviderPickerActivity.createDeleteIntent(mApplicationContext, deleteIntents);
+    }
+
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] saveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
         return saveIntent;
     }
 
+    private Intent createDeleteIntent(
+            ComponentName providerActivity,
+            byte[] deleteRequest) {
+        Intent deleteIntent = createIntent(providerActivity, DELETE_CREDENTIAL_ACTION);
+        deleteIntent.putExtra(EXTRA_DELETE_REQUEST, deleteRequest);
+        return deleteIntent;
+    }
+
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @Nullable
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response");
             return createDefaultHintRetrieveResult();
         }
     }
 
+    /**
+     * Extracts the result of a credential deletion request from the intent data returned by
+     * a provider. If the result is missing or malformed, {@link CredentialDeleteResult#UNKNOWN}
+     * is returned.
+     */
+    @NonNull
+    public CredentialDeleteResult getDeleteResult(Intent resultData) {
+        try {
+            return CredentialDeleteResult.fromResultIntentData(resultData);
+        } catch (MalformedDataException ex) {
+            Log.w(LOG_TAG, "delete result is missing or malformed, returning default response", ex);
+            return CredentialDeleteResult.UNKNOWN;
+        }
+    }
+
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @Nullable
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
index f3d3c7d..5957aef 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -50,166 +50,176 @@ import org.openyolo.api.R;
 /**
  * Activity which presents the list of providers that claim to have a credential available.
  * The user can select one of these options, which fires the associated intent for that provider,
  * or cancel the whole operation.
  */
 public class ProviderPickerActivity extends AppCompatActivity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES = "titleRes";
     private static final String LOG_TAG = "ProviderPicker";
 
     private CredentialClient mClient;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.picker_layout);
 
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         Resources res = getResources();
         @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = res.getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
 
         TextView titleView = (TextView) findViewById(R.id.picker_title);
         @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
         if (titleRes != 0) {
             //robotium has an issue recovering resources in the shadow classes.
             titleView.setText(titleRes);
         }
 
         ListView providerView = (ListView) findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
             retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES, titleRes);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.retrieve_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.save_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
         return createIntent(context, hintIntents, R.string.hint_picker_prompt);
     }
 
+    /**
+     * Creates an intent for display a list of providers to which a credential deletion request
+     * should be sent.
+     */
+    public static Intent createDeleteIntent(
+            @NonNull Context context,
+            @NonNull ArrayList<Intent> deleteIntents) {
+        return createIntent(context, deleteIntents, R.string.delete_picker_prompt);
+    }
+
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getApplicationBoundInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
             TextView providerUnsafe =
                     (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
 
         @SuppressWarnings("deprecation")
         private int getColor(@ColorRes int colorRes) {
             if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                 return getResources().getColor(colorRes, null);
             } else {
                 return getResources().getColor(colorRes);
             }
         }
     }
 }
diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
index 422c222..f8f6470 100644
--- a/api/res/values/strings.xml
+++ b/api/res/values/strings.xml
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <string name="retrieve_picker_prompt">Use account from:</string>
     <string name="provider_icon_contentDescription">Provider icon</string>
     <string name="possibly_unsafe">Possibly unsafe</string>
     <string name="save_picker_prompt">Save your account with:</string>
     <string name="hint_picker_prompt">Use account details stored in:</string>
+    <string name="delete_picker_prompt">Delete credential from:</string>
 </resources>
\ No newline at end of file
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
index e41d142..18794ff 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -25,3 +25,3 @@ import android.support.annotation.Nullable;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
+import com.google.protobuf.InvalidProtocolBufferException;
 import java.util.Collections;
@@ -31,143 +31,170 @@ import org.openyolo.protocol.internal.ClientVersionUtil;
 import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
+import org.valid4j.errors.RequireViolation;
 
 /**
  * A request to delete a credential, to be sent to a credential provider on the device.
  */
 public final class CredentialDeleteRequest {
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent.
+     * @throws MalformedDataException if the protocol buffer is null or contains invalid data.
      */
-    public static CredentialDeleteRequest fromProtobuf(Protobufs.CredentialDeleteRequest proto) {
-        return new Builder(proto).build();
+    public static CredentialDeleteRequest fromProtobuf(
+            @Nullable Protobufs.CredentialDeleteRequest proto)
+            throws MalformedDataException {
+        if (proto == null) {
+            throw new MalformedDataException("credential delete proto is not defined");
+        }
+
+        try {
+            return new Builder(proto).build();
+        } catch (RequireViolation ex) {
+            throw new MalformedDataException("credential deletion request contains invalid data");
+        }
     }
 
     /**
      * Creates a credential deletion request from its protocol buffer equivalent, in byte array
      * form.
-     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     * @throws MalformedDataException if the protocol buffer is null or cannot be parsed from the
+     *     byte array.
      */
     public static CredentialDeleteRequest fromProtobufBytes(
-            byte[] protobufBytes)
-            throws IOException {
-        return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
+            @Nullable byte[] protobufBytes)
+            throws MalformedDataException {
+        if (protobufBytes == null) {
+            throw new MalformedDataException("credential deletion request not defined");
+        }
+
+        try {
+            return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
+        } catch (InvalidProtocolBufferException ex) {
+            throw new MalformedDataException("unable to parse credential deletion request", ex);
+        }
     }
 
     /**
      * Extracts a credential deletion request from a request intent.
-     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     * @throws MalformedDataException if the provided intent is null, is missing the byte array
+     *     extra for the request, or the request contains invalid data.
      */
     public static CredentialDeleteRequest fromRequestIntent(
-            Intent requestIntent)
-            throws IOException {
-        byte[] protoBytes = requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_REQUEST);
-        return fromProtobufBytes(protoBytes);
+            @Nullable Intent requestIntent)
+            throws MalformedDataException {
+        return fromProtobuf(
+                IntentProtocolBufferExtractor.extract(
+                        ProtocolConstants.EXTRA_DELETE_REQUEST,
+                        Protobufs.CredentialDeleteRequest.parser(),
+                        "deletion request missing or contains invalid data",
+                        requestIntent));
     }
 
     @NonNull
     private final Credential mCredential;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteRequest(Builder builder) {
         mCredential = builder.mCredential;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The credential to be deleted.
      */
     @NonNull
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties specified by the client as part of this
      * deletion request.
      */
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Converts the request to its protocol buffer equivalent.
      */
     public Protobufs.CredentialDeleteRequest toProtobuf() {
         return Protobufs.CredentialDeleteRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .setCredential(mCredential.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Creates instances of {@link CredentialDeleteRequest}.
      */
     public static final class Builder {
 
         @NonNull
         private Credential mCredential;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps;
 
         /**
          * Starts the process of describing a credential deletion request, based on the properties
          * contained in the provided protocol buffer.
          */
         public Builder(Protobufs.CredentialDeleteRequest proto) {
             setCredentialFromProto(proto.getCredential());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * credential object.
          */
         public Builder(@NonNull Credential credential) {
             setCredential(credential);
         }
 
         /**
          * Specifies the credential to be deleted. Must not be null.
          */
         public Builder setCredential(@NonNull Credential credential) {
             require(credential, notNullValue());
             mCredential = credential;
             return this;
         }
 
         private Builder setCredentialFromProto(@Nullable Protobufs.Credential credentialProto) {
             require(credentialProto, notNullValue());
             setCredential(Credential.fromProtobuf(credentialProto));
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion request. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(
                 @Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = validateAdditionalProperties(additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion request, from the specified properties.
          */
         public CredentialDeleteRequest build() {
             return new CredentialDeleteRequest(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
index e0cca2f..588b191 100644
--- a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -20,3 +20,3 @@ import android.support.annotation.Nullable;
 import com.google.protobuf.ByteString;
-import java.io.IOException;
+import com.google.protobuf.InvalidProtocolBufferException;
 import java.util.Collections;
@@ -27,227 +27,262 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.IntentProtocolBufferExtractor;
+import org.valid4j.errors.RequireViolation;
 
 /**
  * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
  * indicates the outcome of the request.
  */
 public final class CredentialDeleteResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int CODE_UNKNOWN =
             Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the deletion request sent to the provider was malformed.
      */
     public static final int CODE_BAD_REQUEST =
             Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
      * Indicates that the credential was deleted.
      */
     public static final int CODE_DELETED =
             Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
 
     /**
      * Indicates that the credential provider did not have a credential to delete that matched
      * the provided credential.
      */
     public static final int CODE_NO_MATCHING_CREDENTIAL =
             Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
 
     /**
      * Indicates that the provider refused to delete the provided credential, due to some policy
      * restriction it is enforcing.
      */
     public static final int CODE_PROVIDER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
 
     /**
      * Indicates that the user dismissed the request to delete the credential, by either pressing
      * the back button, clicking outside the area of a modal dialog, or some other "soft"
      * cancellation that is not an explicit refusal to delete the credential.
      */
     public static final int CODE_USER_CANCELED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
 
     /**
      * Indicates that The user explicitly refused to delete the credential, by selecting a
      * "do not delete" (or similarly phrased) option in the presented UI.
      */
     public static final int CODE_USER_REFUSED =
             Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
 
+    /**
+     * Pre-built deletion result for a bad request. Carries no additional properties.
+     */
+    public static final CredentialDeleteResult UNKNOWN =
+            new CredentialDeleteResult.Builder(CODE_UNKNOWN).build();
+
     /**
      * Pre-built deletion result for a bad request. Carries no additional properties.
      */
     public static final CredentialDeleteResult BAD_REQUEST =
             new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
 
     /**
      * Pre-built deletion result for a successful deletion. Carries no additional properties.
      */
     public static final CredentialDeleteResult DELETED =
             new CredentialDeleteResult.Builder(CODE_DELETED).build();
 
     /**
      * Pre-built deletion result for when no matching credential exists to delete.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
             new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
 
     /**
      * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
      * no additional properties.
      */
     public static final CredentialDeleteResult PROVIDER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
 
     /**
      * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_CANCELED =
             new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
      * additional properties.
      */
     public static final CredentialDeleteResult USER_REFUSED =
             new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
 
+    private static final String UNABLE_TO_EXTRACT_RESULT =
+            "Unable to extract or parse the credential deletion result";
+
     /**
      * Creates a credential delete result from its protocol buffer equivalent.
+     * @throws MalformedDataException if the protocol buffer contains invalid data.
      */
-    public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto) {
-        return new CredentialDeleteResult.Builder(proto).build();
+    public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto)
+            throws MalformedDataException {
+        try {
+            return new CredentialDeleteResult.Builder(proto).build();
+        } catch (RequireViolation ex) {
+            throw new MalformedDataException(
+                    "credential deletion result contains invalid data", ex);
+        }
     }
 
     /**
      * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
-     * @throws IOException if the protocol buffer could not be parsed from the byte array.
+     * @throws MalformedDataException if the protocol buffer could not be parsed from the byte
+     *     array, or contains invalid data.
      */
-    public static CredentialDeleteResult fromProtobufBytes(byte[] protoBytes) throws IOException {
-        return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
+    public static CredentialDeleteResult fromProtobufBytes(@Nullable byte[] protoBytes)
+            throws MalformedDataException {
+        if (protoBytes == null) {
+            throw new MalformedDataException("credential deletion result bytes cannot be null");
+        }
+
+        try {
+            return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
+        } catch (InvalidProtocolBufferException ex) {
+            throw new MalformedDataException("credential deletion result could not be parsed",  ex);
+        }
     }
 
     /**
      * Extracts a credential deletion result from the result intent data a provider returns
      * on completion of their deletion activity.
-     * @throws IOException if the protocol buffer could not be parsed from the intent.
+     * @throws MalformedDataException if the protocol buffer could not be parsed from the intent.
      */
-    public static CredentialDeleteResult fromResultIntentData(Intent intent) throws IOException {
-        return fromProtobufBytes(intent.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_RESULT));
+    public static CredentialDeleteResult fromResultIntentData(
+            @Nullable Intent intent)
+            throws MalformedDataException {
+        return fromProtobuf(
+                IntentProtocolBufferExtractor.extract(
+                        ProtocolConstants.EXTRA_DELETE_RESULT,
+                        Protobufs.CredentialDeleteResult.parser(),
+                        UNABLE_TO_EXTRACT_RESULT,
+                        intent));
     }
 
     private final int mResultCode;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private CredentialDeleteResult(Builder builder) {
         mResultCode = builder.mResultCode;
         mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
     }
 
     /**
      * The result code for the credential deletion operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider as part of the
      * credential deletion result, if available.
      */
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates the protocol buffer equivalent to this credential deletion result.
      */
     public Protobufs.CredentialDeleteResult toProtobuf() {
         return Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCodeValue(mResultCode)
                 .putAllAdditionalProps(mAdditionalProps)
                 .build();
     }
 
     /**
      * Extracts a deletion result from the intent returned to the requester by the provider.
      */
     public Intent toResultIntentData() {
         Intent resultData = new Intent();
         resultData.putExtra(
                 ProtocolConstants.EXTRA_DELETE_RESULT,
                 toProtobuf().toByteArray());
         return resultData;
     }
 
     /**
      * Creates instances of {@link CredentialDeleteResult}.
      */
     public static final class Builder {
 
         private int mResultCode;
 
         @NonNull
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential deletion result, based on the properties
          * contained in the provided protocol buffer.
          */
         public Builder(Protobufs.CredentialDeleteResult proto) {
             setResultCode(proto.getResultCodeValue());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Starts the process of describing a credential deletion request, specifying the mandatory
          * result code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Specifies the result code for the deletion operation.
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to carry with the credential
          * deletion result. A null map is treated as an empty map.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
                     additionalProperties);
             return this;
         }
 
         private Builder setAdditionalPropertiesFromProto(
                 Map<String, ByteString> additionalProperties) {
             mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
                     additionalProperties);
             return this;
         }
 
         /**
          * Creates the credential deletion result, from the specified properties.
          */
         public CredentialDeleteResult build() {
             return new CredentialDeleteResult(this);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/MalformedDataException.java b/protocol/java/org/openyolo/protocol/MalformedDataException.java
new file mode 100644
index 0000000..aec9c14
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/MalformedDataException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+/**
+ * Indicates that an OpenYOLO message is missing or could not parsed.
+ */
+public class MalformedDataException extends OpenYoloException {
+
+    /**
+     * Describes the exception with a human-readable string, for debugging.
+     */
+    public MalformedDataException(String message) {
+        super(message);
+    }
+
+    /**
+     * Specifies the root cause of the exception, and a higher-level description for debugging.
+     */
+    public MalformedDataException(String message, Throwable rootCause) {
+        super(message, rootCause);
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/OpenYoloException.java b/protocol/java/org/openyolo/protocol/OpenYoloException.java
new file mode 100644
index 0000000..4878603
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/OpenYoloException.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+/**
+ * Parent exception type for all recoverable openyolo failures.
+ */
+public class OpenYoloException extends Exception {
+
+    /**
+     * Describes the exception with a human-readable string, for debugging.
+     */
+    public OpenYoloException(String message) {
+        super(message);
+    }
+
+    /**
+     * Specifies the root cause of the exception.
+     */
+    public OpenYoloException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Specifies the root cause of the exception, and a higher-level description for debugging.
+     */
+    public OpenYoloException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
index d20c52a..b5497d4 100644
--- a/protocol/java/org/openyolo/protocol/ProtocolConstants.java
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -17,69 +17,74 @@ package org.openyolo.protocol;
 /**
  * Defines key constants that are used to identify data carried in intents.
  */
 public final class ProtocolConstants {
 
     /**
      * The data type used for credential queries using the BBQ protocol.
      */
     public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
 
     /**
      * The extra value key used to store the credential in a retrieve intent response.
      */
     public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
 
     /**
      * The extra value key used to carry a credential retrieve request.
      */
     public static final String EXTRA_RETRIEVE_REQUEST = "org.openyolo.credential.retrieve.request";
 
     /**
      * The extra value key used to carry a credential retrieve result.
      */
     public static final String EXTRA_RETRIEVE_RESULT = "org.openyolo.credential.retrieve.result";
 
     /**
      * The extra key value used to carry a hint request.
      */
     public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
 
     /**
      * The extra key value used to carry a hint result.
      */
     public static final String EXTRA_HINT_RESULT = "org.openyolo.hint.result";
 
     /**
      * The category used for all OpenYOLO-related intents.
      */
     public static final String OPENYOLO_CATEGORY = "org.openyolo";
 
     /**
      * The action used for credential retrieval request intents.
      */
     public static final String RETRIEVE_CREDENTIAL_ACTION = "org.openyolo.credential.retrieve";
 
     /**
      * The action used for hint intents.
      */
     public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
 
     /**
      * The action used for save intents.
      */
     public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
 
+    /**
+     * The action used for delete intents.
+     */
+    public static final String DELETE_CREDENTIAL_ACTION = "org.openyolo.credential.delete";
+
     /**
      * The extra key value used to carry a credential deletion request.
      */
     public static final String EXTRA_DELETE_REQUEST = "org.openyolo.credential.delete.request";
 
     /**
      * The extra key value used to carry a credential deletion result.
      */
     public static final String EXTRA_DELETE_RESULT = "org.openyolo.credential.delete.result";
 
     private ProtocolConstants() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/IntentProtocolBufferExtractor.java b/protocol/java/org/openyolo/protocol/internal/IntentProtocolBufferExtractor.java
new file mode 100644
index 0000000..49477fb
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/IntentProtocolBufferExtractor.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.MessageLite;
+import com.google.protobuf.Parser;
+import java.io.IOException;
+import org.openyolo.protocol.MalformedDataException;
+
+/**
+ * Extracts protocol buffer messages byte array extras in Intents.
+ */
+public final class IntentProtocolBufferExtractor {
+
+    /**
+     * Attempts to extract a protocol buffer from the specified extra.
+     * @throws MalformedDataException if the intent is null, the extra is missing or not a byte
+     *     array, or the protocol buffer could not be parsed.
+     */
+    @NonNull
+    public static <T extends MessageLite> T extract(
+            @NonNull String extraName,
+            @NonNull Parser<T> protoParser,
+            @NonNull String failureDescription,
+            @Nullable Intent intent)
+            throws MalformedDataException {
+
+        if (intent == null) {
+            throw new MalformedDataException(failureDescription);
+        }
+
+        byte[] protoBytes = intent.getByteArrayExtra(extraName);
+        if (protoBytes == null) {
+            throw new MalformedDataException(failureDescription);
+        }
+
+        try {
+            return protoParser.parseFrom(protoBytes);
+        } catch (IOException ex) {
+            throw new MalformedDataException(failureDescription, ex);
+        }
+    }
+
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
index c1b4bcf..c9059cb 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
@@ -33,86 +33,152 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link CredentialDeleteRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteRequestTest {
 
+    // invalid as empty string keys are not permitted
+    private static final Protobufs.CredentialDeleteRequest INVALID_PROTO =
+            Protobufs.CredentialDeleteRequest.newBuilder()
+                    .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
+                    .build();
+
+    private static final byte[] INVALID_PROTO_BYTES =
+            new byte[] { 1, 2, 3, 4, 5 };
+
     private static final Credential CREDENTIAL =
             new Credential.Builder(
                     "alice@example.com",
                     AuthenticationMethods.EMAIL,
                     new AuthenticationDomain("https://example.com"))
             .build();
 
     @Test
     public void build() {
         CredentialDeleteRequest request =
                 new CredentialDeleteRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPS)
                         .build();
 
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void build_nullCredential_throwsException() {
         new CredentialDeleteRequest.Builder((Credential) null).build();
     }
 
     @Test
-    public void fromProtobuf() {
+    public void fromProtobuf() throws Exception {
         Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
                 .setCredential(CREDENTIAL.toProtobuf())
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromProtobuf(proto);
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobuf_nullProto_throwsException() throws Exception {
+        CredentialDeleteRequest.fromProtobuf(null);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobuf_invalidProto_throwsException() throws Exception {
+        CredentialDeleteRequest.fromProtobuf(INVALID_PROTO);
+    }
+
     @Test
     public void fromProtobufBytes() throws Exception {
         Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
                 .setCredential(CREDENTIAL.toProtobuf())
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         CredentialDeleteRequest request =
                 CredentialDeleteRequest.fromProtobufBytes(proto.toByteArray());
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
 
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_nullArray_throwsException() throws Exception {
+        CredentialDeleteRequest.fromProtobufBytes(null);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
+        CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO_BYTES);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
+        CredentialDeleteRequest.fromProtobufBytes(INVALID_PROTO.toByteArray());
+    }
+
     @Test
     public void toProtobuf() {
         Protobufs.CredentialDeleteRequest proto =
                 new CredentialDeleteRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPS)
                         .build()
                 .toProtobuf();
 
         assertThat(proto.hasCredential());
         checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
     }
 
     @Test
-    public void fromRequestIntent() throws IOException {
+    public void fromRequestIntent() throws Exception {
         byte[] protoBytes =
                 new CredentialDeleteRequest.Builder(CREDENTIAL)
                         .setAdditionalProperties(ADDITIONAL_PROPS)
                         .build()
                         .toProtobuf()
                         .toByteArray();
 
         Intent requestIntent = new Intent();
         requestIntent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, protoBytes);
 
         CredentialDeleteRequest request = CredentialDeleteRequest.fromRequestIntent(requestIntent);
 
         assertThat(request.getCredential()).isNotNull();
         checkAdditionalProps(request.getAdditionalProps());
     }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromRequestIntent_nullIntent_throwsException() throws Exception {
+        CredentialDeleteRequest.fromRequestIntent(null);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromRequestIntent_missingExtra_throwsException() throws Exception {
+        Intent intent = new Intent();
+        CredentialDeleteRequest.fromRequestIntent(intent);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromRequestIntent_wrongExtraType_throwsException() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, "notAByteArray");
+        CredentialDeleteRequest.fromRequestIntent(intent);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromRequestIntent_invalidProtoBytes_throwsException() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO_BYTES);
+        CredentialDeleteRequest.fromRequestIntent(intent);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromRequestIntent_invalidProto_throwsException() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, INVALID_PROTO.toByteArray());
+        CredentialDeleteRequest.fromRequestIntent(intent);
+    }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
index 0e00d6c..1aedad6 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
@@ -34,90 +34,152 @@ import org.robolectric.annotation.Config;
 /**
  * Tests for {@link CredentialDeleteResult}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialDeleteResultTest {
 
+    // invalid as empty string keys are not permitted
+    private static final Protobufs.CredentialDeleteResult INVALID_PROTO =
+            Protobufs.CredentialDeleteResult.newBuilder()
+                    .putAdditionalProps("", ByteString.copyFrom(new byte[0]))
+                    .build();
+
+    private static final byte[] INVALID_PROTO_BYTES =
+            new byte[] { 1, 2, 3, 4, 5 };
+
     @Test
     public void build() {
         CredentialDeleteResult result = new CredentialDeleteResult.Builder(
                 CredentialDeleteResult.CODE_DELETED)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toProtobuf() {
         Protobufs.CredentialDeleteResult result = new CredentialDeleteResult.Builder(
                 CredentialDeleteResult.CODE_DELETED)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build()
                 .toProtobuf();
 
         assertThat(result.getResultCodeValue()).isEqualTo(
                 Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE);
         checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
     }
 
     @Test
     public void toResultIntentData() throws InvalidProtocolBufferException {
         Intent resultData = new CredentialDeleteResult.Builder(
                 CredentialDeleteResult.CODE_DELETED)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build()
                 .toResultIntentData();
 
         assertThat(resultData.hasExtra(ProtocolConstants.EXTRA_DELETE_RESULT)).isTrue();
 
         byte[] resultBytes = resultData.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_RESULT);
         Protobufs.CredentialDeleteResult result =
                 Protobufs.CredentialDeleteResult.parseFrom(resultBytes);
 
         assertThat(result.getResultCodeValue()).isEqualTo(ResultCode.DELETED_VALUE);
         checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
     }
 
     @Test
-    public void fromResultIntentData() throws IOException {
+    public void fromResultIntentData() throws Exception {
         byte[] resultBytes = Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCode(ResultCode.USER_REFUSED)
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build()
                 .toByteArray();
 
         Intent resultData = new Intent();
         resultData.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, resultBytes);
 
         CredentialDeleteResult result = CredentialDeleteResult.fromResultIntentData(resultData);
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_USER_REFUSED);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
+    @Test(expected=MalformedDataException.class)
+    public void fromResultIntentData_nullIntent_throwsException() throws Exception {
+        CredentialDeleteResult.fromResultIntentData(null);
+    }
+
+    @Test(expected=MalformedDataException.class)
+    public void fromResultIntentData_missingExtra_throwsException() throws Exception {
+        CredentialDeleteResult.fromResultIntentData(new Intent());
+    }
+
+    @Test(expected=MalformedDataException.class)
+    public void fromResultIntentData_wrongExtraType_throwsException() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, "notAByteArray");
+        CredentialDeleteResult.fromResultIntentData(intent);
+    }
+
+    @Test(expected=MalformedDataException.class)
+    public void fromResultIntentData_invalidProtoBytes_throwsException() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO_BYTES);
+        CredentialDeleteResult.fromResultIntentData(intent);
+    }
+
+    @Test(expected=MalformedDataException.class)
+    public void fromResultIntentData_invalidProto_throwsException() throws Exception {
+        Intent intent = new Intent();
+        intent.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, INVALID_PROTO.toByteArray());
+
+        CredentialDeleteResult.fromResultIntentData(intent);
+    }
+
     @Test
-    public void fromProtobuf() {
+    public void fromProtobuf() throws Exception {
         Protobufs.CredentialDeleteResult proto = Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCode(ResultCode.BAD_REQUEST)
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
         checkAdditionalProps(result.getAdditionalProperties());
     }
 
+    @Test(expected=MalformedDataException.class)
+    public void fromProtobuf_invalidProtoData_throwsException() throws Exception {
+        CredentialDeleteResult.fromProtobuf(INVALID_PROTO);
+    }
+
     @Test
-    public void fromProtobufBytes() throws IOException {
+    public void fromProtobufBytes() throws Exception {
         byte[] protoBytes = Protobufs.CredentialDeleteResult.newBuilder()
                 .setResultCode(ResultCode.BAD_REQUEST)
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build()
                 .toByteArray();
 
         CredentialDeleteResult result = CredentialDeleteResult.fromProtobufBytes(protoBytes);
         assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
         checkAdditionalProps(result.getAdditionalProperties());
     }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_nullArray_throwsException() throws Exception {
+        CredentialDeleteResult.fromProtobufBytes(null);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_invalidProtoBytes_throwsException() throws Exception {
+        CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO_BYTES);
+    }
+
+    @Test(expected = MalformedDataException.class)
+    public void fromProtobufBytes_invalidProto_throwsException() throws Exception {
+        CredentialDeleteResult.fromProtobufBytes(INVALID_PROTO.toByteArray());
+    }
 }

commit 923fdaca30c6dac3eee5cf5c090d8b706629c579
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu May 4 18:22:58 2017 -0700

    Implement delete request and result validating wrappers

diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
new file mode 100644
index 0000000..e41d142
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteRequest.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAdditionalProperties;
+import static org.openyolo.protocol.internal.AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto;
+import static org.valid4j.Assertive.require;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * A request to delete a credential, to be sent to a credential provider on the device.
+ */
+public final class CredentialDeleteRequest {
+
+    /**
+     * Creates a credential deletion request from its protocol buffer equivalent.
+     */
+    public static CredentialDeleteRequest fromProtobuf(Protobufs.CredentialDeleteRequest proto) {
+        return new Builder(proto).build();
+    }
+
+    /**
+     * Creates a credential deletion request from its protocol buffer equivalent, in byte array
+     * form.
+     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     */
+    public static CredentialDeleteRequest fromProtobufBytes(
+            byte[] protobufBytes)
+            throws IOException {
+        return fromProtobuf(Protobufs.CredentialDeleteRequest.parseFrom(protobufBytes));
+    }
+
+    /**
+     * Extracts a credential deletion request from a request intent.
+     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     */
+    public static CredentialDeleteRequest fromRequestIntent(
+            Intent requestIntent)
+            throws IOException {
+        byte[] protoBytes = requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_REQUEST);
+        return fromProtobufBytes(protoBytes);
+    }
+
+    @NonNull
+    private final Credential mCredential;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProps;
+
+    private CredentialDeleteRequest(Builder builder) {
+        mCredential = builder.mCredential;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
+    }
+
+    /**
+     * The credential to be deleted.
+     */
+    @NonNull
+    public Credential getCredential() {
+        return mCredential;
+    }
+
+    /**
+     * The additional, non-standard properties specified by the client as part of this
+     * deletion request.
+     */
+    public Map<String, byte[]> getAdditionalProps() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Converts the request to its protocol buffer equivalent.
+     */
+    public Protobufs.CredentialDeleteRequest toProtobuf() {
+        return Protobufs.CredentialDeleteRequest.newBuilder()
+                .setClientVersion(ClientVersionUtil.getClientVersion())
+                .setCredential(mCredential.toProtobuf())
+                .putAllAdditionalProps(mAdditionalProps)
+                .build();
+    }
+
+    /**
+     * Creates instances of {@link CredentialDeleteRequest}.
+     */
+    public static final class Builder {
+
+        @NonNull
+        private Credential mCredential;
+
+        @NonNull
+        private Map<String, ByteString> mAdditionalProps;
+
+        /**
+         * Starts the process of describing a credential deletion request, based on the properties
+         * contained in the provided protocol buffer.
+         */
+        public Builder(Protobufs.CredentialDeleteRequest proto) {
+            setCredentialFromProto(proto.getCredential());
+            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        }
+
+        /**
+         * Starts the process of describing a credential deletion request, specifying the mandatory
+         * credential object.
+         */
+        public Builder(@NonNull Credential credential) {
+            setCredential(credential);
+        }
+
+        /**
+         * Specifies the credential to be deleted. Must not be null.
+         */
+        public Builder setCredential(@NonNull Credential credential) {
+            require(credential, notNullValue());
+            mCredential = credential;
+            return this;
+        }
+
+        private Builder setCredentialFromProto(@Nullable Protobufs.Credential credentialProto) {
+            require(credentialProto, notNullValue());
+            setCredential(Credential.fromProtobuf(credentialProto));
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to carry with the credential
+         * deletion request. A null map is treated as an empty map.
+         */
+        public Builder setAdditionalProperties(
+                @Nullable Map<String, byte[]> additionalProperties) {
+            mAdditionalProps = validateAdditionalProperties(additionalProperties);
+            return this;
+        }
+
+        private Builder setAdditionalPropertiesFromProto(
+                Map<String, ByteString> additionalProperties) {
+            mAdditionalProps = validateAdditionalPropertiesFromProto(additionalProperties);
+            return this;
+        }
+
+        /**
+         * Creates the credential deletion request, from the specified properties.
+         */
+        public CredentialDeleteRequest build() {
+            return new CredentialDeleteRequest(this);
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
new file mode 100644
index 0000000..e0cca2f
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/CredentialDeleteResult.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * A response to a {@link CredentialDeleteRequest credential deletion request}. The status code
+ * indicates the outcome of the request.
+ */
+public final class CredentialDeleteResult {
+
+    /**
+     * Indicates that the provider returned a response that could not be interpreted.
+     */
+    public static final int CODE_UNKNOWN =
+            Protobufs.CredentialDeleteResult.ResultCode.UNSPECIFIED_VALUE;
+
+    /**
+     * Indicates that the deletion request sent to the provider was malformed.
+     */
+    public static final int CODE_BAD_REQUEST =
+            Protobufs.CredentialDeleteResult.ResultCode.BAD_REQUEST_VALUE;
+
+    /**
+     * Indicates that the credential was deleted.
+     */
+    public static final int CODE_DELETED =
+            Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE;
+
+    /**
+     * Indicates that the credential provider did not have a credential to delete that matched
+     * the provided credential.
+     */
+    public static final int CODE_NO_MATCHING_CREDENTIAL =
+            Protobufs.CredentialDeleteResult.ResultCode.NO_MATCHING_CREDENTIAL_VALUE;
+
+    /**
+     * Indicates that the provider refused to delete the provided credential, due to some policy
+     * restriction it is enforcing.
+     */
+    public static final int CODE_PROVIDER_REFUSED =
+            Protobufs.CredentialDeleteResult.ResultCode.PROVIDER_REFUSED_VALUE;
+
+    /**
+     * Indicates that the user dismissed the request to delete the credential, by either pressing
+     * the back button, clicking outside the area of a modal dialog, or some other "soft"
+     * cancellation that is not an explicit refusal to delete the credential.
+     */
+    public static final int CODE_USER_CANCELED =
+            Protobufs.CredentialDeleteResult.ResultCode.USER_CANCELED_VALUE;
+
+    /**
+     * Indicates that The user explicitly refused to delete the credential, by selecting a
+     * "do not delete" (or similarly phrased) option in the presented UI.
+     */
+    public static final int CODE_USER_REFUSED =
+            Protobufs.CredentialDeleteResult.ResultCode.USER_REFUSED_VALUE;
+
+    /**
+     * Pre-built deletion result for a bad request. Carries no additional properties.
+     */
+    public static final CredentialDeleteResult BAD_REQUEST =
+            new CredentialDeleteResult.Builder(CODE_BAD_REQUEST).build();
+
+    /**
+     * Pre-built deletion result for a successful deletion. Carries no additional properties.
+     */
+    public static final CredentialDeleteResult DELETED =
+            new CredentialDeleteResult.Builder(CODE_DELETED).build();
+
+    /**
+     * Pre-built deletion result for when no matching credential exists to delete.  Carries no
+     * additional properties.
+     */
+    public static final CredentialDeleteResult NO_MATCHING_CREDENTIAL =
+            new CredentialDeleteResult.Builder(CODE_NO_MATCHING_CREDENTIAL).build();
+
+    /**
+     * Pre-built deletion result for when the provider refuses to delete the credential.  Carries
+     * no additional properties.
+     */
+    public static final CredentialDeleteResult PROVIDER_REFUSED =
+            new CredentialDeleteResult.Builder(CODE_PROVIDER_REFUSED).build();
+
+    /**
+     * Pre-built deletion result for when the user cancels the deletion operation.  Carries no
+     * additional properties.
+     */
+    public static final CredentialDeleteResult USER_CANCELED =
+            new CredentialDeleteResult.Builder(CODE_USER_CANCELED).build();
+
+    /**
+     * Pre-built deletion result for when the user refuses to delete the credential.  Carries no
+     * additional properties.
+     */
+    public static final CredentialDeleteResult USER_REFUSED =
+            new CredentialDeleteResult.Builder(CODE_USER_REFUSED).build();
+
+    /**
+     * Creates a credential delete result from its protocol buffer equivalent.
+     */
+    public static CredentialDeleteResult fromProtobuf(Protobufs.CredentialDeleteResult proto) {
+        return new CredentialDeleteResult.Builder(proto).build();
+    }
+
+    /**
+     * Creates a credential delete result from its protocol buffer equivalent, in byte array form.
+     * @throws IOException if the protocol buffer could not be parsed from the byte array.
+     */
+    public static CredentialDeleteResult fromProtobufBytes(byte[] protoBytes) throws IOException {
+        return fromProtobuf(Protobufs.CredentialDeleteResult.parseFrom(protoBytes));
+    }
+
+    /**
+     * Extracts a credential deletion result from the result intent data a provider returns
+     * on completion of their deletion activity.
+     * @throws IOException if the protocol buffer could not be parsed from the intent.
+     */
+    public static CredentialDeleteResult fromResultIntentData(Intent intent) throws IOException {
+        return fromProtobufBytes(intent.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_RESULT));
+    }
+
+    private final int mResultCode;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProps;
+
+    private CredentialDeleteResult(Builder builder) {
+        mResultCode = builder.mResultCode;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
+    }
+
+    /**
+     * The result code for the credential deletion operation.
+     */
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    /**
+     * The additional, non-standard properties returned by the credential provider as part of the
+     * credential deletion result, if available.
+     */
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Creates the protocol buffer equivalent to this credential deletion result.
+     */
+    public Protobufs.CredentialDeleteResult toProtobuf() {
+        return Protobufs.CredentialDeleteResult.newBuilder()
+                .setResultCodeValue(mResultCode)
+                .putAllAdditionalProps(mAdditionalProps)
+                .build();
+    }
+
+    /**
+     * Extracts a deletion result from the intent returned to the requester by the provider.
+     */
+    public Intent toResultIntentData() {
+        Intent resultData = new Intent();
+        resultData.putExtra(
+                ProtocolConstants.EXTRA_DELETE_RESULT,
+                toProtobuf().toByteArray());
+        return resultData;
+    }
+
+    /**
+     * Creates instances of {@link CredentialDeleteResult}.
+     */
+    public static final class Builder {
+
+        private int mResultCode;
+
+        @NonNull
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Starts the process of describing a credential deletion result, based on the properties
+         * contained in the provided protocol buffer.
+         */
+        public Builder(Protobufs.CredentialDeleteResult proto) {
+            setResultCode(proto.getResultCodeValue());
+            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        }
+
+        /**
+         * Starts the process of describing a credential deletion request, specifying the mandatory
+         * result code.
+         */
+        public Builder(int resultCode) {
+            setResultCode(resultCode);
+        }
+
+        /**
+         * Specifies the result code for the deletion operation.
+         */
+        public Builder setResultCode(int resultCode) {
+            mResultCode = resultCode;
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to carry with the credential
+         * deletion result. A null map is treated as an empty map.
+         */
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProperties) {
+            mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalProperties(
+                    additionalProperties);
+            return this;
+        }
+
+        private Builder setAdditionalPropertiesFromProto(
+                Map<String, ByteString> additionalProperties) {
+            mAdditionalProps = AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(
+                    additionalProperties);
+            return this;
+        }
+
+        /**
+         * Creates the credential deletion result, from the specified properties.
+         */
+        public CredentialDeleteResult build() {
+            return new CredentialDeleteResult(this);
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
index ffd408f..d20c52a 100644
--- a/protocol/java/org/openyolo/protocol/ProtocolConstants.java
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -17,60 +17,69 @@ package org.openyolo.protocol;
 /**
  * Defines key constants that are used to identify data carried in intents.
  */
 public final class ProtocolConstants {
 
     /**
      * The data type used for credential queries using the BBQ protocol.
      */
     public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
 
     /**
      * The extra value key used to store the credential in a retrieve intent response.
      */
     public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
 
     /**
      * The extra value key used to carry a credential retrieve request.
      */
     public static final String EXTRA_RETRIEVE_REQUEST = "org.openyolo.credential.retrieve.request";
 
     /**
      * The extra value key used to carry a credential retrieve result.
      */
     public static final String EXTRA_RETRIEVE_RESULT = "org.openyolo.credential.retrieve.result";
 
     /**
      * The extra key value used to carry a hint request.
      */
     public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
 
     /**
      * The extra key value used to carry a hint result.
      */
     public static final String EXTRA_HINT_RESULT = "org.openyolo.hint.result";
 
     /**
      * The category used for all OpenYOLO-related intents.
      */
     public static final String OPENYOLO_CATEGORY = "org.openyolo";
 
     /**
      * The action used for credential retrieval request intents.
      */
     public static final String RETRIEVE_CREDENTIAL_ACTION = "org.openyolo.credential.retrieve";
 
     /**
      * The action used for hint intents.
      */
     public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
 
     /**
      * The action used for save intents.
      */
     public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
 
+    /**
+     * The extra key value used to carry a credential deletion request.
+     */
+    public static final String EXTRA_DELETE_REQUEST = "org.openyolo.credential.delete.request";
+
+    /**
+     * The extra key value used to carry a credential deletion result.
+     */
+    public static final String EXTRA_DELETE_RESULT = "org.openyolo.credential.delete.result";
 
     private ProtocolConstants() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
new file mode 100644
index 0000000..c1b4bcf
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteRequestTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROPS;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_VALUE;
+import static org.openyolo.protocol.TestConstants.checkAdditionalProps;
+import static org.openyolo.protocol.TestConstants.checkAdditionalPropsFromProto;
+
+import android.content.Intent;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Tests for {@link CredentialDeleteRequest}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class CredentialDeleteRequestTest {
+
+    private static final Credential CREDENTIAL =
+            new Credential.Builder(
+                    "alice@example.com",
+                    AuthenticationMethods.EMAIL,
+                    new AuthenticationDomain("https://example.com"))
+            .build();
+
+    @Test
+    public void build() {
+        CredentialDeleteRequest request =
+                new CredentialDeleteRequest.Builder(CREDENTIAL)
+                        .setAdditionalProperties(ADDITIONAL_PROPS)
+                        .build();
+
+        assertThat(request.getCredential()).isNotNull();
+        checkAdditionalProps(request.getAdditionalProps());
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void build_nullCredential_throwsException() {
+        new CredentialDeleteRequest.Builder((Credential) null).build();
+    }
+
+    @Test
+    public void fromProtobuf() {
+        Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
+                .setCredential(CREDENTIAL.toProtobuf())
+                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .build();
+
+        CredentialDeleteRequest request = CredentialDeleteRequest.fromProtobuf(proto);
+        assertThat(request.getCredential()).isNotNull();
+        checkAdditionalProps(request.getAdditionalProps());
+    }
+
+    @Test
+    public void fromProtobufBytes() throws Exception {
+        Protobufs.CredentialDeleteRequest proto = Protobufs.CredentialDeleteRequest.newBuilder()
+                .setCredential(CREDENTIAL.toProtobuf())
+                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .build();
+
+        CredentialDeleteRequest request =
+                CredentialDeleteRequest.fromProtobufBytes(proto.toByteArray());
+        assertThat(request.getCredential()).isNotNull();
+        checkAdditionalProps(request.getAdditionalProps());
+    }
+
+    @Test
+    public void toProtobuf() {
+        Protobufs.CredentialDeleteRequest proto =
+                new CredentialDeleteRequest.Builder(CREDENTIAL)
+                        .setAdditionalProperties(ADDITIONAL_PROPS)
+                        .build()
+                .toProtobuf();
+
+        assertThat(proto.hasCredential());
+        checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
+    }
+
+    @Test
+    public void fromRequestIntent() throws IOException {
+        byte[] protoBytes =
+                new CredentialDeleteRequest.Builder(CREDENTIAL)
+                        .setAdditionalProperties(ADDITIONAL_PROPS)
+                        .build()
+                        .toProtobuf()
+                        .toByteArray();
+
+        Intent requestIntent = new Intent();
+        requestIntent.putExtra(ProtocolConstants.EXTRA_DELETE_REQUEST, protoBytes);
+
+        CredentialDeleteRequest request = CredentialDeleteRequest.fromRequestIntent(requestIntent);
+
+        assertThat(request.getCredential()).isNotNull();
+        checkAdditionalProps(request.getAdditionalProps());
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
new file mode 100644
index 0000000..0e00d6c
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/CredentialDeleteResultTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROPS;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_VALUE;
+import static org.openyolo.protocol.TestConstants.checkAdditionalProps;
+import static org.openyolo.protocol.TestConstants.checkAdditionalPropsFromProto;
+
+import android.content.Intent;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.InvalidProtocolBufferException;
+import java.io.IOException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.Protobufs.CredentialDeleteResult.ResultCode;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Tests for {@link CredentialDeleteResult}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class CredentialDeleteResultTest {
+
+    @Test
+    public void build() {
+        CredentialDeleteResult result = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build();
+
+        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_DELETED);
+        checkAdditionalProps(result.getAdditionalProperties());
+    }
+
+    @Test
+    public void toProtobuf() {
+        Protobufs.CredentialDeleteResult result = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build()
+                .toProtobuf();
+
+        assertThat(result.getResultCodeValue()).isEqualTo(
+                Protobufs.CredentialDeleteResult.ResultCode.DELETED_VALUE);
+        checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
+    }
+
+    @Test
+    public void toResultIntentData() throws InvalidProtocolBufferException {
+        Intent resultData = new CredentialDeleteResult.Builder(
+                CredentialDeleteResult.CODE_DELETED)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build()
+                .toResultIntentData();
+
+        assertThat(resultData.hasExtra(ProtocolConstants.EXTRA_DELETE_RESULT)).isTrue();
+
+        byte[] resultBytes = resultData.getByteArrayExtra(ProtocolConstants.EXTRA_DELETE_RESULT);
+        Protobufs.CredentialDeleteResult result =
+                Protobufs.CredentialDeleteResult.parseFrom(resultBytes);
+
+        assertThat(result.getResultCodeValue()).isEqualTo(ResultCode.DELETED_VALUE);
+        checkAdditionalPropsFromProto(result.getAdditionalPropsMap());
+    }
+
+    @Test
+    public void fromResultIntentData() throws IOException {
+        byte[] resultBytes = Protobufs.CredentialDeleteResult.newBuilder()
+                .setResultCode(ResultCode.USER_REFUSED)
+                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .build()
+                .toByteArray();
+
+        Intent resultData = new Intent();
+        resultData.putExtra(ProtocolConstants.EXTRA_DELETE_RESULT, resultBytes);
+
+        CredentialDeleteResult result = CredentialDeleteResult.fromResultIntentData(resultData);
+        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_USER_REFUSED);
+        checkAdditionalProps(result.getAdditionalProperties());
+    }
+
+    @Test
+    public void fromProtobuf() {
+        Protobufs.CredentialDeleteResult proto = Protobufs.CredentialDeleteResult.newBuilder()
+                .setResultCode(ResultCode.BAD_REQUEST)
+                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .build();
+
+        CredentialDeleteResult result = CredentialDeleteResult.fromProtobuf(proto);
+        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
+        checkAdditionalProps(result.getAdditionalProperties());
+    }
+
+    @Test
+    public void fromProtobufBytes() throws IOException {
+        byte[] protoBytes = Protobufs.CredentialDeleteResult.newBuilder()
+                .setResultCode(ResultCode.BAD_REQUEST)
+                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .build()
+                .toByteArray();
+
+        CredentialDeleteResult result = CredentialDeleteResult.fromProtobufBytes(protoBytes);
+        assertThat(result.getResultCode()).isEqualTo(CredentialDeleteResult.CODE_BAD_REQUEST);
+        checkAdditionalProps(result.getAdditionalProperties());
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
index 5c02793..9c797ce 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
@@ -17,2 +17,7 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_KEY;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_PROPS;
+import static org.openyolo.protocol.TestConstants.ADDITIONAL_VALUE;
+import static org.openyolo.protocol.TestConstants.checkAdditionalProps;
+import static org.openyolo.protocol.TestConstants.checkAdditionalPropsFromProto;
 
@@ -31,110 +36,93 @@ import org.robolectric.annotation.Config;
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRetrieveResultTest {
 
     private static final String ALICE_ID = "alice@example.com";
-    private static final String ADDITIONAL_KEY = "extra";
-    private static final byte[] ADDITIONAL_VALUE = "value".getBytes();
-    private static final Map<String, byte[]> ADDITIONAL_PROPS;
-
     private static final Hint HINT =
             new Hint.Builder(
                     ALICE_ID,
                     AuthenticationMethods.EMAIL)
                     .build();
 
-    static {
-        HashMap<String, byte[]> additionalProps = new HashMap<>();
-        additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
-        ADDITIONAL_PROPS = Collections.unmodifiableMap(additionalProps);
-    }
-
     @Test
     public void build() {
 
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .build();
 
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isSameAs(HINT);
         assertThat(result.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void buildSetHint_nullValue() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setHint(null)
                 .build();
 
         assertThat(result.getHint()).isNull();
     }
 
     @Test
     public void buildSetAdditionalProperties() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         assertThat(result.getAdditionalProperties()).hasSize(1);
-        assertThat(result.getAdditionalProperties()).containsKey(ADDITIONAL_KEY);
-        assertThat(result.getAdditionalProperties().get(ADDITIONAL_KEY))
-                .isEqualTo(ADDITIONAL_VALUE);
+        checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toProtobuf() {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         Protobufs.HintRetrieveResult proto = result.toProtobuf();
         assertThat(proto.getResultCodeValue()).isEqualTo(ResultCode.HINT_SELECTED_VALUE);
         assertThat(proto.hasHint());
-        assertThat(proto.containsAdditionalProps(ADDITIONAL_KEY));
-        assertThat(proto.getAdditionalPropsOrThrow(ADDITIONAL_KEY).toByteArray())
-                .isEqualTo(ADDITIONAL_VALUE);
+        checkAdditionalPropsFromProto(proto.getAdditionalPropsMap());
     }
 
     @Test
     public void fromProtobuf() {
         Protobufs.HintRetrieveResult proto = Protobufs.HintRetrieveResult.newBuilder()
                 .setResultCode(ResultCode.HINT_SELECTED)
                 .setHint(Protobufs.Hint.newBuilder()
                         .setId(ALICE_ID)
                         .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf()))
                 .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
                 .build();
 
         HintRetrieveResult result = HintRetrieveResult.fromProtobuf(proto);
         assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(result.getHint()).isNotNull();
-        assertThat(result.getAdditionalProperties()).hasSize(1);
-        assertThat(result.getAdditionalProperties()).containsKey(ADDITIONAL_KEY);
-        assertThat(result.getAdditionalProperties().get(ADDITIONAL_KEY))
-                .isEqualTo(ADDITIONAL_VALUE);
+        checkAdditionalProps(result.getAdditionalProperties());
     }
 
     @Test
     public void toResultIntentData() throws IOException {
         HintRetrieveResult result = new HintRetrieveResult.Builder(
                 HintRetrieveResult.CODE_HINT_SELECTED)
                 .setHint(HINT)
                 .setAdditionalProperties(ADDITIONAL_PROPS)
                 .build();
 
         Intent intent = result.toResultDataIntent();
         assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
         byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
 
         HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
         assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
         assertThat(readResult.getHint()).isNotNull();
-        assertThat(readResult.getAdditionalProperties()).hasSize(1);
+        checkAdditionalProps(readResult.getAdditionalProperties());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/TestConstants.java b/protocol/javatests/org/openyolo/protocol/TestConstants.java
new file mode 100644
index 0000000..32dadb5
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/TestConstants.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import com.google.protobuf.ByteString;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * Useful constants and associated verification methods for tests.
+ */
+public final class TestConstants {
+
+    public static final String ADDITIONAL_KEY = "extra";
+    public static final byte[] ADDITIONAL_VALUE = "value".getBytes();
+    public static final Map<String, byte[]> ADDITIONAL_PROPS;
+
+    static {
+        Map<String, byte[]> additionalProps = new HashMap<>();
+        additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
+        ADDITIONAL_PROPS = additionalProps;
+    }
+
+    public static void checkAdditionalProps(Map<String, byte[]> additionalProps) {
+        assertThat(additionalProps).isNotNull();
+        assertThat(additionalProps).hasSize(1);
+        assertThat(additionalProps).containsKey(ADDITIONAL_KEY);
+        assertThat(additionalProps.get(ADDITIONAL_KEY)).isEqualTo(ADDITIONAL_VALUE);
+    }
+
+    public static void checkAdditionalPropsFromProto(Map<String, ByteString> additionalProps) {
+        checkAdditionalProps(CollectionConverter.convertMapValues(
+                additionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
+    }
+}

commit 15f3cea9c9af20c6e1a4ac26fb188fde61dbc071
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu May 4 15:24:21 2017 -0700

    Full sync with the draft 3 protocol buffer definitions
    
    This required some immediate fixes to the credential retrieve request / result
    wrappers to sync with the new response codes.

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index e5b8b21..ccc078f 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -54,350 +54,350 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
                 findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedCredential = credentialToSave.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedCredential);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedCredential));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] saveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
         return saveIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @Nullable
     public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
             return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response");
             return createDefaultHintRetrieveResult();
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
-        return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.RESULT_UNKNOWN)
+        return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.CODE_UNKNOWN)
                 .build();
     }
 
     @Nullable
     private static HintRetrieveResult createDefaultHintRetrieveResult() {
         return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 99395fe..2dd8bb9 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -48,302 +48,304 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         credentialClient = new CredentialClient(mockContext);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders("com.example.superpassword", "com.example.locker");
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void testGetCredentialRetrieveResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
-                new CredentialRetrieveResult.Builder(CredentialRetrieveResult.RESULT_SUCCESS)
+                new CredentialRetrieveResult.Builder(
+                        CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
-        assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.RESULT_SUCCESS);
+        assertThat(result.getResultCode()).isEqualTo(
+                CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
 
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
-        assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.RESULT_UNKNOWN);
+        assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.CODE_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/bbq/proto/bbq.proto b/bbq/proto/bbq.proto
index bda2086..63855df 100644
--- a/bbq/proto/bbq.proto
+++ b/bbq/proto/bbq.proto
@@ -24,19 +24,19 @@ option java_outer_classname = "Protobufs";
 message BroadcastQuery {
-    // required - The BBQ client version.
-    ClientVersion clientVersion = 1;
+    // The BBQ client version.
+    ClientVersion client_version = 1;
 
-    // required - the type of data to be discovered
-    string dataType = 2;
+    // required
+    string data_type = 2;
 
-    // required - the package name of the requesting app
-    string requestingApp = 3;
+    // required
+    string requesting_app = 3;
 
-    // required - a 64-bit random number for this request.
-    sfixed64 requestId = 4;
+    // required
+    sfixed64 request_id = 4;
 
     // required
-    sfixed64 responseId = 5;
+    sfixed64 response_id = 5;
 
-    bytes queryMessage = 6;
-    map<string, bytes> additionalProps = 7;
+    bytes query_message = 6;
+    map<string, bytes> additional_props = 7;
 }
@@ -44,9 +44,10 @@ message BroadcastQuery {
 message BroadcastQueryResponse {
     // required
-    sfixed64 requestId = 1;
+    sfixed64 request_id = 1;
+
     // required
-    sfixed64 responseId = 2;
-    bytes responseMessage = 3;
+    sfixed64 response_id = 2;
 
-    map<string, bytes> additionalProps = 4;
+    bytes response_message = 3;
+    map<string, bytes> additional_props = 4;
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
index ae6fe63..e513d16 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
@@ -34,97 +34,97 @@ import org.openyolo.protocol.Protobufs;
 /**
  * Displays a brief, "snackbar"-like notification to the user indicating that a credential
  * is being returned to a requesting app.
  */
 public class AutoSignInActivity extends AppCompatActivity {
 
     private static final long DISPLAY_TIME_MS = 2000;
 
     private static final String EXTRA_CREDENTIAL = "credential";
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.credential_primary)
     TextView mCredentialPrimary;
 
     @BindView(R.id.credential_secondary)
     TextView mCredentialSecondary;
 
     /**
      * Creates an intent to display this activity with the specified credential.
      */
     public static Intent createIntent(Context context, Credential credential) {
         return createIntent(context, credential.toProtobuf());
     }
 
     /**
      * Creates an intent to display this activity with the specified credential, in protobuf form.
      */
     public static Intent createIntent(Context context, Protobufs.Credential credential) {
         Intent intent = new Intent(context, AutoSignInActivity.class);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.auto_sign_in_layout);
         positionWindow();
         ButterKnife.bind(this);
 
         Credential credential = getCredential();
         if (credential.getDisplayName() != null) {
             mCredentialPrimary.setText(credential.getDisplayName());
             mCredentialSecondary.setText(credential.getIdentifier());
         } else {
             mCredentialPrimary.setText(credential.getIdentifier());
             mCredentialSecondary.setVisibility(View.GONE);
         }
 
         mRootView.postDelayed(new ReturnCredentialTask(), DISPLAY_TIME_MS);
     }
 
     /**
      * Ensures the activity's window fills the full "visible" section of the screen, excluding
      * the status bar. This is a workaround for a size bug when using
      * {@code windowMinWidthMajor / windowMinWidthMinor} that can leave the windows a few pixels
      * off the correct size.
      */
     private void positionWindow() {
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = getResources().getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
     }
 
     private Credential getCredential() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
             return Credential.fromProtoBytes(credentialBytes);
         } catch (IOException e) {
             throw new IllegalStateException("Unable to decode credential");
         }
     }
 
     private class ReturnCredentialTask implements Runnable {
         @Override
         public void run() {
             CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
-                    CredentialRetrieveResult.RESULT_SUCCESS)
+                    CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                     .setCredential(getCredential())
                     .build();
             setResult(result.getResultCode(), result.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index a8e83d7..c81f051 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -43,111 +43,108 @@ import org.openyolo.protocol.internal.CredentialConverter;
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(
             Context context,
             List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
         ByteString data = ProtoListUtil.writeMessageList(
                 CollectionConverter.toList(
                         credentials,
                         CredentialConverter.CREDENTIAL_TO_PROTO));
 
         intent.putExtra(EXTRA_CREDENTIALS, data.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
-            setResultAndFinish(
-                    new CredentialRetrieveResult.Builder(
-                            CredentialRetrieveResult.RESULT_REJECTED_BY_USER)
-                            .build());
+            setResultAndFinish(CredentialRetrieveResult.USER_CANCELED);
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Protobufs.Credential> credentialProtos = ProtoListUtil
                     .readMessageList(credentialBytes, Protobufs.Credential.parser());
 
             return CollectionConverter.toList(
                     credentialProtos,
                     CredentialConverter.PROTO_TO_CREDENTIAL);
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter
             extends RecyclerView.Adapter<AccountViewHolder>
             implements ClickHandler<Credential> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new AccountViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(AccountViewHolder holder, int position) {
             holder.bind(mCredentials.get(position), this);
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
 
         @Override
         public void onClick(Credential clicked) {
             CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
-                    CredentialRetrieveResult.RESULT_SUCCESS)
+                    CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                     .setCredential(clicked)
                     .build();
             setResultAndFinish(result);
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index c4a2fee..42deb33 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -35,108 +35,108 @@ import org.openyolo.protocol.internal.CredentialConverter;
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
 public class RetrieveCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "RetrieveCredential";
     private CredentialStorageClient mClient;
     private CredentialRetrieveRequest mRequest;
 
     /**
      * Creates the intent to handle releasing a credential to the calling app.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         // the format of this intent needs to be compatible with a "direct invocation" intent,
         // based on the spec (Section 4.3.1).
         Intent intent = new Intent(context, RetrieveCredentialActivity.class);
         intent.setAction(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
         intent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_REQUEST,
                 request.toProtocolBuffer().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
-            setResultAndFinish(CredentialRetrieveResult.REJECTED_BY_PROVIDER);
+            setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
             mRequest = CredentialRetrieveRequest.fromRequestIntent(getIntent());
         } catch (IOException e) {
-            setResultAndFinish(CredentialRetrieveResult.REJECTED_BY_PROVIDER);
+            setResultAndFinish(CredentialRetrieveResult.BAD_REQUEST);
         }
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
         if (!client.isUnlocked()) {
             Intent retrieveAfterUnlockIntent =
                     RetrieveCredentialActivity.createIntent(this, mRequest);
             retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
             Intent unlockIntent =
                     UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
             unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(unlockIntent);
             finish();
         } else {
             // TODO: we actually need the full set of requested domains from the original request,
             // not just those based on the package name.
 
             List<AuthenticationDomain> authDomains =
                     AuthenticationDomain.listForPackage(this, getCallingPackage());
 
             List<Credential> credentials;
             try {
                 credentials = CollectionConverter.toList(
                         client.listCredentials(authDomains),
                         CredentialConverter.PROTO_TO_CREDENTIAL);
             } catch (IOException ex) {
                 Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
                 finish();
                 return;
             }
 
             if (credentials.size() == 1) {
                 Intent autoSignInIntent =
                         AutoSignInActivity.createIntent(this, credentials.get(0));
                 autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(autoSignInIntent);
             } else {
                 Intent pickerIntent =
                         CredentialPickerActivity.createIntent(this, credentials);
                 pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(pickerIntent);
             }
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
index bf0b1ae..375a408 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -32,72 +32,72 @@ import org.openyolo.protocol.CredentialRetrieveResult;
 /**
  * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
  */
 public class RetrieveActivity extends AppCompatActivity {
 
     private static final int PIN_SIZE = 6;
 
     private static final String LOG_TAG = "TrapdoorRetrieve";
 
     private AuthenticationDomain mDomain;
 
     /**
      * Creates an Intent to start this activity.
      */
     public static Intent createIntent(Context context) {
         return new Intent(context, RetrieveActivity.class);
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
             setResult(RESULT_CANCELED);
             finish();
             return;
         }
 
         mDomain = new TreeSet<>(
                 AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
         Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
 
         setContentView(R.layout.dialog_layout);
         ((PinEntryView)findViewById(R.id.pin_entry_field))
                 .addTextChangedListener(new PinChangedWatcher());
     }
 
     private class PinChangedWatcher implements TextWatcher {
         @Override
         public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
 
         @Override
         public void onTextChanged(CharSequence seq, int start, int before, int count) {}
 
         @Override
         public void afterTextChanged(Editable pin) {
             if (pin.length() != PIN_SIZE) {
                 return;
             }
             String userName = UserDataStore.getUserName(RetrieveActivity.this);
             String password = PasswordGenerator.generatePassword(
                     userName,
                     pin.toString(),
                     mDomain.toString());
 
             Credential credential = new Credential.Builder(
                     UserDataStore.getUserName(RetrieveActivity.this),
                     AuthenticationMethods.EMAIL,
                     mDomain)
                     .setPassword(password)
                     .build();
 
             CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
-                    CredentialRetrieveResult.RESULT_SUCCESS)
+                    CredentialRetrieveResult.CODE_CREDENTIAL_SELECTED)
                     .setCredential(credential)
                     .build();
             setResult(result.getResultCode(), result.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 305bc7b..e8cfba0 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -32,221 +32,245 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
-    public static final int RESULT_UNKNOWN =
+    public static final int CODE_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
-     * Indicates that the credential request completed without any issues.
+     * Indicates that the credential request sent to the provider was malformed.
      */
-    public static final int RESULT_SUCCESS =
-            Protobufs.CredentialRetrieveResult.ResultCode.SUCCESS_VALUE;
+    public static final int CODE_BAD_REQUEST =
+            Protobufs.CredentialRetrieveResult.ResultCode.BAD_REQUEST_VALUE;
 
     /**
-     * Indicates that the credential request was denied by the provider.
+     * Indicates that the user selected a hint, that has been returned as part of this response.
      */
-    public static final int RESULT_REJECTED_BY_PROVIDER =
-            Protobufs.CredentialRetrieveResult.ResultCode.REJECTED_BY_PROVIDER_VALUE;
+    public static final int CODE_CREDENTIAL_SELECTED =
+            Protobufs.CredentialRetrieveResult.ResultCode.CREDENTIAL_SELECTED_VALUE;
 
     /**
-     * Indicates that the credential request was denied by the user.
+     * Indicates that no credentials are available that meet the requirements of the credential
+     * request.
      */
-    public static final int RESULT_REJECTED_BY_USER =
-            Protobufs.CredentialRetrieveResult.ResultCode.REJECTED_BY_USER_VALUE;
+    public static final int CODE_NO_CREDENTIALS_AVAILABLE =
+            Protobufs.CredentialRetrieveResult.ResultCode.NO_CREDENTIALS_AVAILABLE_VALUE;
 
     /**
-     * Indicates that the credential request was rejected by the provider.
+     * Indicates that the user canceled the selection of a credential in a manner that indicates
+     * they wish to proceed with authentication, but by manually entering their details.
      */
-    public static final CredentialRetrieveResult REJECTED_BY_PROVIDER =
-            new CredentialRetrieveResult.Builder(RESULT_REJECTED_BY_PROVIDER).build();
+    public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
+            Protobufs.CredentialRetrieveResult.ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
 
     /**
-     * Indicates that the credential request was rejected by the user.
+     * Indicates that the user canceled the selection of a credential in a manner that indicates
+     * they do not wish to authenticate at this time.
      */
-    public static final CredentialRetrieveResult REJECTED_BY_USER =
-            new CredentialRetrieveResult.Builder(RESULT_REJECTED_BY_USER).build();
+    public static final int CODE_USER_CANCELED =
+            Protobufs.CredentialRetrieveResult.ResultCode.USER_CANCELED_VALUE;
+
+    /**
+     * Pre-built result that indicates the request was malformed. Carries no
+     * credential or additional params.
+     */
+    public static final CredentialRetrieveResult BAD_REQUEST =
+            new CredentialRetrieveResult.Builder(CODE_BAD_REQUEST).build();
+
+    /**
+     * Pre-built result that indicates that no credentials are available. Carries no credential or
+     * additional params.
+     */
+    public static final CredentialRetrieveResult NO_CREDENTIALS_AVAILABLE =
+            new CredentialRetrieveResult.Builder(CODE_NO_CREDENTIALS_AVAILABLE).build();
+
+    /**
+     * Pre-built result that indicates the user wishes to manually authenticate.
+     */
+    public static final CredentialRetrieveResult USER_REQUESTS_MANUAL_AUTH =
+            new CredentialRetrieveResult.Builder(CODE_USER_REQUESTS_MANUAL_AUTH).build();
+
+    /**
+     * Pre-built result that indicates that the user does not want to authenticate at this time.
+     */
+    public static final CredentialRetrieveResult USER_CANCELED =
+            new CredentialRetrieveResult.Builder(CODE_USER_CANCELED).build();
 
     /**
      * Creates a credential retrieve request from its protocol buffer byte equivalent.
      * @throws IOException if the request could not be parsed or validated.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws IOException {
         return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
     }
 
     /**
      * Creates a credential retrieve request from its protocol buffer equivalent.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto) {
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(
             int resultCode,
             Credential credential,
             Map<String, ByteString> additionalProps) {
         mResultCode = resultCode;
         mCredential = credential;
         mAdditionalProps = additionalProps;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          */
         public Builder(Protobufs.CredentialRetrieveResult proto) {
             setResultCode(proto.getResultCodeValue());
             setCredentialFromProto(proto.getCredential());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
-         *
-         * @see CredentialRetrieveResult#RESULT_SUCCESS
-         * @see CredentialRetrieveResult#RESULT_REJECTED_BY_PROVIDER
-         * @see CredentialRetrieveResult#RESULT_REJECTED_BY_USER
-         * @see CredentialRetrieveResult#RESULT_UNKNOWN
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         public Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
             mCredential = credential != null ? Credential.fromProtobuf(credential) : null;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             require(additionalProperties, notNullValue());
             require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProperties.values(), everyItem(notNullValue()));
 
             mAdditionalProps =
                     CollectionConverter.convertMapValues(
                             additionalProperties,
                             ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProperties) {
             require(additionalProperties, notNullValue());
             require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProperties.values(), everyItem(notNullValue()));
 
             mAdditionalProps = additionalProperties;
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(mResultCode, mCredential, mAdditionalProps);
         }
     }
 }
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index dbc5d93..8fc23b6 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -24,9 +24,10 @@ option java_outer_classname = "Protobufs";
 message CredentialRetrieveRequest {
-    ClientVersion clientVersion = 1;
+    ClientVersion client_version = 1;
 
     // at least one authMethod required
-    repeated AuthenticationMethod authMethods = 2;
+    repeated AuthenticationMethod auth_methods = 2;
 
-    map<string, TokenRequestInfo> supportedTokenProviders = 3;
-    map<string, bytes> additionalProps = 4;
+    map<string, TokenRequestInfo> supported_token_providers = 3;
+    bool require_user_mediation = 4;
+    map<string, bytes> additional_props = 5;
 }
@@ -43,14 +44,16 @@ message CredentialRetrieveBbqResponseList {
 message CredentialRetrieveResult {
     enum ResultCode {
         UNSPECIFIED = 0;
-        SUCCESS = 1;
-        REJECTED_BY_PROVIDER = 2;
-        REJECTED_BY_USER = 3;
+        BAD_REQUEST = 1;
+        CREDENTIAL_SELECTED = 2;
+        NO_CREDENTIALS_AVAILABLE = 3;
+        USER_REQUESTS_MANUAL_AUTH = 4;
+        USER_CANCELED = 5;
     }
 
     // required
-    ResultCode resultCode = 1;
+    ResultCode result_code = 1;
 
     Credential credential = 2;
-    map<string, bytes> additionalProps = 3;
+    map<string, bytes> additional_props = 3;
 }
@@ -58,10 +61,10 @@ message CredentialRetrieveResult {
 message HintRetrieveRequest {
-    ClientVersion clientVersion = 1;
+    ClientVersion client_version = 1;
 
     // at least one authMethod required
-    repeated AuthenticationMethod authMethods = 2;
+    repeated AuthenticationMethod auth_methods = 2;
 
-    PasswordSpecification passwordSpec = 3;
-    map<string, TokenRequestInfo> supportedTokenProviders = 4;
-    map<string, bytes> additionalProps = 5;
+    PasswordSpecification password_spec = 3;
+    map<string, TokenRequestInfo> supported_token_providers = 4;
+    map<string, bytes> additional_props = 5;
 }
@@ -69,16 +72,68 @@ message HintRetrieveRequest {
 message HintRetrieveResult {
     enum ResultCode {
         UNSPECIFIED = 0;
         BAD_REQUEST = 1;
         HINT_SELECTED = 2;
         NO_HINTS_AVAILABLE = 3;
         USER_REQUESTS_MANUAL_AUTH = 4;
         USER_CANCELED = 5;
     }
 
     // required
-    ResultCode resultCode = 1;
+    ResultCode result_code = 1;
 
     Hint hint = 2;
-    map<string, bytes> additionalProps = 3;
+    map<string, bytes> additional_props = 3;
+}
+
+message CredentialSaveRequest {
+    ClientVersion client_version = 1;
+
+    // required
+    Credential credential = 2;
+
+    map<string, bytes> additional_props = 3;
+}
+
+message CredentialSaveResult {
+
+    enum ResultCode {
+        UNSPECIFIED = 0;
+        BAD_REQUEST = 1;
+        SAVED = 2;
+        PROVIDER_REFUSED = 3;
+        USER_CANCELED = 4;
+        USER_REFUSED = 5;
+    }
+
+    // required
+    ResultCode result_code = 1;
+
+    map<string, bytes> additional_props = 2;
+}
+
+message CredentialDeleteRequest {
+    ClientVersion client_version = 1;
+
+    // required
+    Credential credential = 2;
+
+    map<string, bytes> additional_props = 3;
+}
+
+message CredentialDeleteResult {
+    enum ResultCode {
+        UNSPECIFIED = 0;
+        BAD_REQUEST = 1;
+        DELETED = 2;
+        NO_MATCHING_CREDENTIAL = 3;
+        PROVIDER_REFUSED = 4;
+        USER_CANCELED = 5;
+        USER_REFUSED = 6;
+    }
+
+    // required
+    ResultCode result_code = 1;
+
+    map<string, bytes> additional_props = 2;
 }
@@ -86,16 +141,16 @@ message HintRetrieveResult {
 message Credential {
     // required
     string id = 1;
 
     // required
-    AuthenticationDomain authDomain = 2;
+    AuthenticationDomain auth_domain = 2;
 
     // required
-    AuthenticationMethod authMethod = 3;
+    AuthenticationMethod auth_method = 3;
 
-    string displayName = 4;
-    string displayPictureUri = 5;
+    string display_name = 4;
+    string display_picture_uri = 5;
     string password = 6;
-    string idToken = 7;
-    map<string, bytes> additionalProps = 8;
+    string id_token = 7;
+    map<string, bytes> additional_props = 8;
 }
@@ -103,13 +158,13 @@ message Credential {
 message Hint {
     // required
     string id = 1;
 
     // required
-    AuthenticationMethod authMethod = 2;
+    AuthenticationMethod auth_method = 3;
 
-    string displayName = 3;
-    string displayPictureUri = 4;
-    string generatedPassword = 5;
-    string idToken = 6;
-    map<string, bytes> additionalProps = 7;
+    string display_name = 4;
+    string display_picture_uri = 5;
+    string generated_password = 6;
+    string id_token = 7;
+    map<string, bytes> additional_props = 8;
 }
@@ -127,12 +182,12 @@ message AuthenticationDomain {
 message PasswordSpecification {
     // required
     string allowed = 1;
 
     // required
-    uint32 minSize = 2;
+    uint32 min_size = 2;
 
     // required
-    uint32 maxSize = 3;
+    uint32 max_size = 3;
 
-    repeated RequiredCharSet requiredSets = 4;
+    repeated RequiredCharSet required_sets = 4;
 }
@@ -148,5 +203,5 @@ message RequiredCharSet {
 message TokenRequestInfo {
-    string clientId = 1;
+    string client_id = 1;
     string nonce = 2;
-    map<string, bytes> additionalProps = 3;
+    map<string, bytes> additional_props = 3;
 }
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index 12e61aa..efbf34a 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -37,120 +37,130 @@ import org.openyolo.protocol.RetrieveBbqResponse;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
         if (result.getCredential() != null) {
             mCredentialView.setFieldsFromCredential(result.getCredential());
             return;
         }
 
-
-        int retrieveResultCode = result.getResultCode();
-        if (retrieveResultCode == CredentialRetrieveResult.RESULT_REJECTED_BY_USER) {
-            showSnackbar(R.string.credential_retrieve_user_rejected);
-        } else if (retrieveResultCode == CredentialRetrieveResult.RESULT_REJECTED_BY_PROVIDER) {
-            showSnackbar(R.string.credential_retrieve_provider_rejected);
-        } else {
-            showSnackbar(R.string.unknown_response);
+        int resultMessageId;
+        switch (result.getResultCode()) {
+            case CredentialRetrieveResult.CODE_NO_CREDENTIALS_AVAILABLE:
+                resultMessageId = R.string.retrieve_no_credentials;
+                break;
+            case CredentialRetrieveResult.CODE_BAD_REQUEST:
+                resultMessageId = R.string.retrieve_bad_request;
+                break;
+            case CredentialRetrieveResult.CODE_USER_CANCELED:
+                resultMessageId = R.string.retrieve_user_canceled;
+                break;
+            case CredentialRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
+                resultMessageId = R.string.retrieve_manual_auth;
+                break;
+            default:
+                resultMessageId = R.string.retrieve_unknown_response;
         }
+
+        showSnackbar(resultMessageId);
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         CredentialRetrieveRequest request =
                 CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveBbqResponse> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveBbqResponse result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveBbqResponse result = mResult.get();
             if (result.getRetrieveIntent() == null) {
-                showSnackbar(R.string.no_credentials);
+                showSnackbar(R.string.retrieve_no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 9ffab9a..4e5a6a5 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,61 +1,67 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
-    <string name="no_credentials">No credentials available</string>
-    <string name="credential_retrieve_user_rejected">Credential retrieve canceled by user</string>
-    <string name="credential_retrieve_provider_rejected">Credential retrieve rejected by provider</string>
+
+    <string name="retrieve_unknown_response">Unknown retrieve response</string>
+    <string name="retrieve_bad_request">Bad credential request</string>
+    <string name="retrieve_no_credentials">No credentials available</string>
+    <string name="retrieve_user_canceled">User canceled retrieve request</string>
+    <string name="retrieve_manual_auth">User requests manual auth</string>
+
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
+
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_bad_request">Bad hint request</string>
     <string name="hint_none_available">No hints available</string>
     <string name="hint_user_canceled">User canceled hint request</string>
     <string name="hint_manual_auth">User requests manual auth</string>
     <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
+
 </resources>

commit 2b77a46f986f9e420e77d933acdbd27813e77e93
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu May 4 14:06:44 2017 -0700

    Migrate hint retrieval flow to match spec draft 2

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index f6ce461..e5b8b21 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -19,2 +19,3 @@ import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_HINT_REQUEST;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_HINT_RESULT;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_RETRIEVE_RESULT;
@@ -45,3 +46,4 @@ import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
-import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.HintRetrieveRequest;
+import org.openyolo.protocol.HintRetrieveResult;
 import org.openyolo.protocol.Protobufs;
@@ -52,353 +54,350 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
-    public Intent getHintRetrieveIntent(final HintRequest request) {
+    public Intent getHintRetrieveIntent(final HintRetrieveRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
                 findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedCredential = credentialToSave.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedCredential);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedCredential));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] saveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
         return saveIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @NonNull
     public CredentialRetrieveResult getCredentialRetrieveResult(
             @Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
             Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
             return createDefaultCredentialRetrieveResult();
         }
 
         try {
             return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
             return createDefaultCredentialRetrieveResult();
         }
     }
 
     /**
      * Extracts the result of a hint retrieve request from the intent data returned by a provider.
      */
     @Nullable
-    public Credential getHintRetrieveResult(Intent resultData) {
-        // TODO: this has yet to be updated to the new hint retrieve result format and distinct
-        // hint result object type
-
+    public HintRetrieveResult getHintRetrieveResult(Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
-        if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
+        if (!resultData.hasExtra(EXTRA_HINT_RESULT)) {
             Log.i(LOG_TAG, "hint result missing from response, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
-        byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
+        byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_HINT_RESULT);
         if (resultBytes == null) {
             Log.i(LOG_TAG, "No hint result found in result data, returning default response");
             return createDefaultHintRetrieveResult();
         }
 
         try {
-            return Credential.fromProtoBytes(resultBytes);
+            return HintRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "hint result is malformed, returning default response");
             return createDefaultHintRetrieveResult();
         }
     }
 
     @NonNull
     private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
         return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.RESULT_UNKNOWN)
                 .build();
     }
 
     @Nullable
-    private static Credential createDefaultHintRetrieveResult() {
-        return null;
+    private static HintRetrieveResult createDefaultHintRetrieveResult() {
+        return HintRetrieveResult.UNKNOWN;
     }
 
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index f4971b3..99395fe 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -41,3 +41,3 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.HintRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
@@ -48,302 +48,302 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         credentialClient = new CredentialClient(mockContext);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
-                HintRequest.forEmailAndPasswordAccount());
+                HintRetrieveRequest.forEmailAndPasswordAccount());
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders("com.example.superpassword", "com.example.locker");
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void testGetCredentialRetrieveResult() throws Exception {
         Intent intent = new Intent();
         intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 new CredentialRetrieveResult.Builder(CredentialRetrieveResult.RESULT_SUCCESS)
                         .setCredential(testCredential)
                         .build()
                         .toProtobuf()
                         .toByteArray());
 
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.RESULT_SUCCESS);
 
         assertThat(result.getCredential()).isNotNull();
         assertThat(result.getCredential().getIdentifier())
                 .isEqualTo(testCredential.getIdentifier());
 
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     @Test
     public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
         CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
         assertThat(result).isNotNull();
         assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.RESULT_UNKNOWN);
         assertThat(result.getCredential()).isNull();
         assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 }
diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
index d52c6c2..f8c3e88 100644
--- a/demoproviders/barbican/AndroidManifest.xml
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -1,153 +1,153 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="org.openyolo.demoprovider.barbican">
 
     <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name_short"
         android:supportsRtl="false"
         android:theme="@style/AppTheme"
         android:name=".Application">
 
         <activity
             android:name=".LaunchActivity"
             android:label="@string/app_name_short"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateHidden"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data
                     android:host="barbican.openyolo.org"
                     android:scheme="https" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".WelcomeActivity"
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".UnlockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".LockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="false" />
 
         <activity
             android:name=".CredentialListActivity"
             android:label="Stored Credentials"
             android:theme="@style/AppTheme"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity
             android:name=".CreateCredentialActivity"
             android:theme="@style/AppTheme"
             android:label="@string/create_credential_activity_label"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity android:name=".provider.RetrieveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.credential.retrieve"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.save"/>
                 <category android:name="org.openyolo" />
                 <!--
                 as this app only supports saving email based credentials, this is
                 declared using a data filter.
                 -->
                 <data
                     android:scheme="openyolo"
                     android:host="email" />
             </intent-filter>
         </activity>
 
         <activity
-            android:name=".provider.HintActivity"
-            android:theme="@style/AppTheme.NoUi"
-            android:exported="true"
-            android:excludeFromRecents="true">
+            android:name=".provider.HintPickerActivity"
+            android:theme="@style/AppTheme.Dialog"
+            android:excludeFromRecents="true"
+            android:exported="true">
             <intent-filter>
                 <action android:name="org.openyolo.hint"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialConfirmationActivity"
                   android:theme="@style/AppTheme.Dialog"
                   android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveAfterUnlockActivity"
                   android:theme="@style/AppTheme.NoUi"
                   android:excludeFromRecents="true" />
 
         <activity
             android:name=".provider.AutoSignInActivity"
             android:theme="@style/AutoSignInTheme"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".provider.CredentialPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".NeverSaveListActivity"
             android:theme="@style/AppTheme"/>
             android:exported="false" />
 
         <service
             android:name=".storage.CredentialStorageService"
             android:label="@string/credential_storage_service_label"
             android:enabled="true"
             android:exported="false"
             android:permission="org.openyolo.demoprovider.STORAGE"/>
 
         <receiver
             android:name=".provider.CredentialQueryReceiver"
             android:exported="true"
             android:enabled="true"
             tools:ignore="ExportedReceiver">
             <intent-filter>
                 <action android:name="org.openyolo.credential" />
                 <category android:name="com.google.bbq.QUERY" />
             </intent-filter>
         </receiver>
     </application>
 </manifest>
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/ProtoListUtil.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/ProtoListUtil.java
new file mode 100644
index 0000000..dfc6319
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/ProtoListUtil.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.ByteString.Output;
+import com.google.protobuf.MessageLite;
+import com.google.protobuf.Parser;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility for reading and writing lists of protocol buffer messages.
+ */
+public final class ProtoListUtil {
+
+    /**
+     * Creates a {@link ByteString} by serializing the list of protos. Use
+     * {@link #readMessageList(ByteString, Parser)} to deserialize.
+     */
+    public static <T extends MessageLite> ByteString writeMessageList(List<T> protos) {
+        Output output = ByteString.newOutput();
+        try {
+            writeMessageListTo(output, protos);
+        } catch (IOException ex) {
+            throw new IllegalStateException("Unable to write protobufs to memory");
+        }
+
+        return output.toByteString();
+    }
+
+    /**
+     * Writes the provided list of protos to the provided output stream.
+     * @throws IOException if the protos cannot be written to the provided output stream.
+     */
+    public static <T extends MessageLite> void writeMessageListTo(
+            OutputStream stream,
+            List<T> protos)
+            throws IOException {
+        DataOutputStream dos = new DataOutputStream(stream);
+
+        dos.writeInt(protos.size());
+        for (MessageLite proto : protos) {
+            proto.writeDelimitedTo(stream);
+        }
+    }
+
+    /**
+     * Reads a list of protos, using the provided parser, from the provided {@link ByteString}.
+     * @throws IOException if the proto list could not be parsed.
+     */
+    public static <T extends MessageLite> List<T> readMessageList(
+            ByteString bytes,
+            Parser<T> parser)
+            throws IOException {
+        InputStream stream = bytes.newInput();
+        return readMessageList(stream, parser);
+    }
+
+    /**
+     * Reads a list of protos, using the provided parser, from the provided byte array.
+     * @throws IOException if the proto list could not be parsed.
+     */
+    public static <T extends MessageLite> List<T> readMessageList(
+            byte[] bytes,
+            Parser<T> parser)
+            throws IOException {
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        return readMessageList(bais, parser);
+    }
+
+    /**
+     * Reads a list of protos, using the provided parser, from the provided input stream.
+     * @throws IOException if the proto list could not be parsed.
+     */
+    public static <T extends MessageLite> List<T> readMessageList(
+            InputStream stream,
+            Parser<T> parser)
+            throws IOException {
+        DataInputStream dis = new DataInputStream(stream);
+        int messageCount = dis.readInt();
+
+        ArrayList<T> messages = new ArrayList<>(messageCount);
+        for (int i = 0; i < messageCount; i++) {
+            messages.add(parser.parseDelimitedFrom(stream));
+        }
+
+        return messages;
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
new file mode 100644
index 0000000..b8c94da
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AccountViewHolder.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.bumptech.glide.Glide;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.protocol.AuthenticationMethod;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.Hint;
+
+/**
+ * RecyclerView holder for displaying account options to the user in a credential or hint picker.
+ */
+public final class AccountViewHolder extends RecyclerView.ViewHolder {
+
+    private ImageView mProfileIcon;
+    private TextView mPrimaryLabel;
+    private TextView mSecondaryLabel;
+
+    AccountViewHolder(View itemView) {
+        super(itemView);
+
+        mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
+        mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
+        mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
+    }
+
+    void bind(final Credential credential, ClickHandler<Credential> clickHandler) {
+        bind(
+                credential.getIdentifier(),
+                credential.getAuthenticationMethod(),
+                credential.getDisplayName(),
+                credential.getDisplayPicture(),
+                credential,
+                clickHandler);
+    }
+
+    void bind(final Hint hint, ClickHandler<Hint> clickHandler) {
+        bind(
+                hint.getIdentifier(),
+                hint.getAuthenticationMethod(),
+                hint.getDisplayName(),
+                hint.getDisplayPictureUri(),
+                hint,
+                clickHandler);
+    }
+
+    <T> void bind(
+            @NonNull String id,
+            @NonNull AuthenticationMethod authMethod,
+            @Nullable String displayName,
+            @Nullable Uri profilePictureUri,
+            @NonNull final T sourceObject,
+            @NonNull final ClickHandler<T> clickHandler) {
+
+        int iconId;
+        if (AuthenticationMethods.EMAIL.equals(authMethod)) {
+            iconId = R.drawable.email;
+        } else if (AuthenticationMethods.PHONE.equals(authMethod)) {
+            iconId = R.drawable.phone;
+        } else {
+            iconId = R.drawable.person;
+        }
+
+        if (profilePictureUri != null) {
+            Glide.with(mProfileIcon.getContext())
+                    .load(profilePictureUri)
+                    .fitCenter()
+                    .fallback(iconId)
+                    .into(mProfileIcon);
+        } else {
+            mProfileIcon.setImageResource(iconId);
+        }
+
+        if (displayName != null) {
+            mPrimaryLabel.setText(displayName);
+            mSecondaryLabel.setText(id);
+            mSecondaryLabel.setVisibility(View.VISIBLE);
+        } else {
+            mPrimaryLabel.setText(id);
+            mSecondaryLabel.setVisibility(View.GONE);
+        }
+
+        itemView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                clickHandler.onClick(sourceObject);
+            }
+        });
+    }
+
+    interface ClickHandler<T> {
+        void onClick(T clicked);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index f858788..a8e83d7 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -18,3 +18,2 @@ import android.content.Context;
 import android.content.Intent;
-import android.net.Uri;
 import android.os.Bundle;
@@ -29,170 +28,126 @@ import android.view.View;
 import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
 import butterknife.BindView;
 import butterknife.ButterKnife;
-import com.bumptech.glide.Glide;
+import com.google.protobuf.ByteString;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-import org.openyolo.demoprovider.barbican.CredentialQualityScore;
+import org.openyolo.demoprovider.barbican.ProtoListUtil;
 import org.openyolo.demoprovider.barbican.R;
-import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.demoprovider.barbican.provider.AccountViewHolder.ClickHandler;
+import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.CredentialRetrieveResult;
-import org.openyolo.protocol.Protobufs.Credential;
-import org.openyolo.protocol.Protobufs.CredentialList;
+import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.CredentialConverter;
 
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
-    public static Intent createIntent(Context context, List<Credential> credentials) {
+    public static Intent createIntent(
+            Context context,
+            List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
-        intent.putExtra(EXTRA_CREDENTIALS,
-                CredentialList.newBuilder()
-                        .addAllCredentials(credentials)
-                        .build()
-                        .toByteArray());
+        ByteString data = ProtoListUtil.writeMessageList(
+                CollectionConverter.toList(
+                        credentials,
+                        CredentialConverter.CREDENTIAL_TO_PROTO));
+
+        intent.putExtra(EXTRA_CREDENTIALS, data.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResultAndFinish(
                     new CredentialRetrieveResult.Builder(
                             CredentialRetrieveResult.RESULT_REJECTED_BY_USER)
                             .build());
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
-            List<Credential> credentials =
-                    new ArrayList<>(CredentialList.parseFrom(credentialBytes).getCredentialsList());
-            Collections.sort(credentials, CredentialQualityScore.PROTO_QUALITY_SORT);
-            return credentials;
+            List<Protobufs.Credential> credentialProtos = ProtoListUtil
+                    .readMessageList(credentialBytes, Protobufs.Credential.parser());
+
+            return CollectionConverter.toList(
+                    credentialProtos,
+                    CredentialConverter.PROTO_TO_CREDENTIAL);
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
-    private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
+    private final class CredentialPickerAdapter
+            extends RecyclerView.Adapter<AccountViewHolder>
+            implements ClickHandler<Credential> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
-        public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
-            return new CredentialViewHolder(credentialView);
+            return new AccountViewHolder(credentialView);
         }
 
         @Override
-        public void onBindViewHolder(CredentialViewHolder holder, int position) {
-            holder.bind(mCredentials.get(position));
+        public void onBindViewHolder(AccountViewHolder holder, int position) {
+            holder.bind(mCredentials.get(position), this);
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
-    }
-
-    private final class CredentialViewHolder extends RecyclerView.ViewHolder {
-
-        private ImageView mProfileIcon;
-        private TextView mPrimaryLabel;
-        private TextView mSecondaryLabel;
 
-        CredentialViewHolder(View itemView) {
-            super(itemView);
-
-            mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
-            mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
-            mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
-        }
-
-        void bind(final Credential credential) {
-
-            int iconId;
-            if (AuthenticationMethods.EMAIL.toString().equals(credential.getAuthMethod())) {
-                iconId = R.drawable.email;
-            } else if (AuthenticationMethods.PHONE.toString().equals(credential.getAuthMethod())) {
-                iconId = R.drawable.phone;
-            } else {
-                iconId = R.drawable.person;
-            }
-
-            if (credential.getDisplayPictureUri() != null) {
-                Uri displayPictureUri = Uri.parse(credential.getDisplayPictureUri());
-                Glide.with(CredentialPickerActivity.this)
-                        .load(displayPictureUri)
-                        .fitCenter()
-                        .fallback(iconId)
-                        .into(mProfileIcon);
-            } else {
-                mProfileIcon.setImageResource(iconId);
-            }
-
-            if (credential.getDisplayName() != null) {
-                mPrimaryLabel.setText(credential.getDisplayName());
-                mSecondaryLabel.setText(credential.getId());
-                mSecondaryLabel.setVisibility(View.VISIBLE);
-            } else {
-                mPrimaryLabel.setText(credential.getId());
-                mSecondaryLabel.setVisibility(View.GONE);
-            }
-
-            itemView.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View view) {
-                    setResultAndFinish(
-                            new CredentialRetrieveResult.Builder(
-                                    CredentialRetrieveResult.RESULT_SUCCESS)
-                                    .setCredentialFromProto(credential)
-                                    .build());
-                }
-            });
+        @Override
+        public void onClick(Credential clicked) {
+            CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
+                    CredentialRetrieveResult.RESULT_SUCCESS)
+                    .setCredential(clicked)
+                    .build();
+            setResultAndFinish(result);
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
similarity index 60%
rename from demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
rename to demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
index ede3289..d8648a1 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintPickerActivity.java
@@ -17,3 +17,2 @@ package org.openyolo.demoprovider.barbican.provider;
 import android.content.ComponentName;
-import android.content.Intent;
 import android.os.Bundle;
@@ -22,3 +21,8 @@ import android.support.annotation.UiThread;
 import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
 import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
 import java.io.IOException;
@@ -28,2 +32,4 @@ import java.util.Set;
 import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.demoprovider.barbican.provider.AccountViewHolder.ClickHandler;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
@@ -32,144 +38,186 @@ import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.HintRequest;
-import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.Hint;
+import org.openyolo.protocol.HintRetrieveRequest;
+import org.openyolo.protocol.HintRetrieveResult;
 import org.openyolo.protocol.ProtocolConstants;
 
-public class HintActivity
+public class HintPickerActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
-    private static final String LOG_TAG = "HintActivity";
+    private static final String LOG_TAG = "HintPickerActivity";
 
-    private HintRequest mRequest;
+    private HintRetrieveRequest mRequest;
     private AuthenticationDomain mCallerAuthDomain;
     private CredentialStorageClient mClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (!getIntent().hasExtra(ProtocolConstants.EXTRA_HINT_REQUEST)) {
             Log.w(LOG_TAG, "No hint request object found in the intent");
-            finish(RESULT_CANCELED);
+            setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         try {
-            mRequest = HintRequest.fromProtoBytes(
+            mRequest = HintRetrieveRequest.fromProtoBytes(
                     getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_HINT_REQUEST));
         } catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
-            finish(RESULT_CANCELED);
+            setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         if (!extractCallerAuthDomain()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
-            finish(RESULT_CANCELED);
+            setResultAndFinish(HintRetrieveResult.BAD_REQUEST);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
 
         if (!mClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
-            finish(RESULT_CANCELED);
+            setResultAndFinish(HintRetrieveResult.UNKNOWN);
             return;
         }
 
         // some credential provider implementations may require an unlock to retrieve the
         // information required for hints, but for Barbican we instead choose to store basic
         // profile information usable for hints in plain text. With root access, this information
         // would be retrievable by malicious applications on the device, representing a privacy
         // risk. However, full credentials and associations between account identifiers
         // remain encrypted.
 
         List<AccountHint> hints;
         try {
             hints = mClient.getHints();
         } catch (IOException ex) {
             Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
-            finish(RESULT_CANCELED);
+            setResultAndFinish(HintRetrieveResult.UNKNOWN);
             return;
         }
 
         // filter the credentials to just those which are pertinent to the request. For those
         // selected, turn them into credentials. Order the hints by the amount of information
         // they contain (so more complete items are displayed first), and then alphabetically.
-        ArrayList<Credential> filteredHints = new ArrayList<>();
+        ArrayList<Hint> filteredHints = new ArrayList<>();
         for (AccountHint hint : hints) {
             AuthenticationMethod hintAuthMethod = new AuthenticationMethod(hint.getAuthMethod());
             Set<AuthenticationMethod> authMethods = mRequest.getAuthenticationMethods();
             if (!authMethods.contains(hintAuthMethod)) {
                 continue;
             }
 
-            Credential.Builder hintCredentialBuilder = Credential.newBuilder()
-                    .setId(hint.getIdentifier())
-                    .setAuthMethod(hintAuthMethod.toProtobuf())
-                    .setAuthDomain(mCallerAuthDomain.toProtobuf())
+            Hint.Builder hintProtoBuilder = new Hint.Builder(
+                    hint.getIdentifier(),
+                    hintAuthMethod)
                     .setDisplayName(hint.getName())
                     .setDisplayPictureUri(hint.getPictureUri());
 
             // include a generated password if appropriate
-            if (hint.getAuthMethod().equals(AuthenticationMethods.EMAIL.toString())) {
-                hintCredentialBuilder.setPassword(mRequest.getPasswordSpecification().generate());
+            if (hintAuthMethod.equals(AuthenticationMethods.EMAIL)
+                    || hintAuthMethod.equals(AuthenticationMethods.PHONE)
+                    || hintAuthMethod.equals(AuthenticationMethods.USER_NAME)) {
+                hintProtoBuilder.setGeneratedPassword(
+                        mRequest.getPasswordSpecification().generate());
             }
 
-            filteredHints.add(hintCredentialBuilder.build());
+            filteredHints.add(hintProtoBuilder.build());
         }
 
         // if there are no hints, immediately end the request
         if (filteredHints.isEmpty()) {
-            finish(RESULT_CANCELED);
+            setResultAndFinish(HintRetrieveResult.NO_HINTS_AVAILABLE);
             return;
         }
 
         // otherwise, display the standard credential picker.
-        Intent pickerIntent = CredentialPickerActivity.createIntent(
-                this,
-                filteredHints);
-        pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
-        startActivity(pickerIntent);
-        finish();
+        renderPicker(filteredHints);
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
+    private void renderPicker(List<Hint> hints) {
+        setContentView(R.layout.hint_picker_layout);
+
+        RecyclerView hintsView = (RecyclerView) findViewById(R.id.available_hints);
+
+        hintsView.setAdapter(new HintPickerAdapter(hints));
+        hintsView.setLayoutManager(new LinearLayoutManager(this));
+    }
+
     private boolean extractCallerAuthDomain() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
-        // TODO: a more complete implementation would need to expand this to the full set of
-        // affiliated apps and sites, though it is generally unusual for an app to save a
-        // credential for any authentication domain other than those it can directly identify as.
         String callingPackage = callingActivity.getPackageName();
         List<AuthenticationDomain> authDomains =
                 AuthenticationDomain.listForPackage(this, callingPackage);
 
         if (authDomains.isEmpty()) {
             return false;
         }
 
         mCallerAuthDomain = authDomains.get(0);
         return true;
     }
 
     @UiThread
-    private void finish(int resultCode) {
-        setResult(resultCode);
+    private void setResultAndFinish(HintRetrieveResult result) {
+        setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
+
+    private final class HintPickerAdapter extends RecyclerView.Adapter<AccountViewHolder> implements
+            ClickHandler<Hint> {
+
+        List<Hint> mHints;
+
+        HintPickerAdapter(List<Hint> hints) {
+            mHints = hints;
+        }
+
+        @Override
+        public AccountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+            View credentialView = LayoutInflater.from(parent.getContext())
+                    .inflate(R.layout.credential_picker_item_view, parent, false);
+
+            return new AccountViewHolder(credentialView);
+        }
+
+        @Override
+        public void onBindViewHolder(AccountViewHolder holder, int position) {
+            holder.bind(mHints.get(position), this);
+        }
+
+        @Override
+        public int getItemCount() {
+            return mHints.size();
+        }
+
+        @Override
+        public void onClick(Hint clicked) {
+            HintRetrieveResult result = new HintRetrieveResult.Builder(
+                    HintRetrieveResult.CODE_HINT_SELECTED)
+                    .setHint(clicked)
+                    .build();
+
+            setResultAndFinish(result);
+        }
+    }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index e4ae184..c4a2fee 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -27,112 +27,116 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.CredentialRetrieveResult;
-import org.openyolo.protocol.Protobufs.Credential;
 import org.openyolo.protocol.ProtocolConstants;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.CredentialConverter;
 
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
 public class RetrieveCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "RetrieveCredential";
     private CredentialStorageClient mClient;
     private CredentialRetrieveRequest mRequest;
 
     /**
      * Creates the intent to handle releasing a credential to the calling app.
      */
     public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
         // the format of this intent needs to be compatible with a "direct invocation" intent,
         // based on the spec (Section 4.3.1).
         Intent intent = new Intent(context, RetrieveCredentialActivity.class);
         intent.setAction(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
         intent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_REQUEST,
                 request.toProtocolBuffer().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             setResultAndFinish(CredentialRetrieveResult.REJECTED_BY_PROVIDER);
             return;
         }
 
         try {
             mRequest = CredentialRetrieveRequest.fromRequestIntent(getIntent());
         } catch (IOException e) {
             setResultAndFinish(CredentialRetrieveResult.REJECTED_BY_PROVIDER);
         }
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
         if (!client.isUnlocked()) {
             Intent retrieveAfterUnlockIntent =
                     RetrieveCredentialActivity.createIntent(this, mRequest);
             retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
             Intent unlockIntent =
                     UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
             unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(unlockIntent);
             finish();
         } else {
             // TODO: we actually need the full set of requested domains from the original request,
             // not just those based on the package name.
 
             List<AuthenticationDomain> authDomains =
                     AuthenticationDomain.listForPackage(this, getCallingPackage());
 
             List<Credential> credentials;
             try {
-                credentials = client.listCredentials(authDomains);
+                credentials = CollectionConverter.toList(
+                        client.listCredentials(authDomains),
+                        CredentialConverter.PROTO_TO_CREDENTIAL);
             } catch (IOException ex) {
                 Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
                 finish();
                 return;
             }
 
             if (credentials.size() == 1) {
                 Intent autoSignInIntent =
                         AutoSignInActivity.createIntent(this, credentials.get(0));
                 autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(autoSignInIntent);
             } else {
                 Intent pickerIntent =
                         CredentialPickerActivity.createIntent(this, credentials);
                 pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(pickerIntent);
             }
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private void setResultAndFinish(CredentialRetrieveResult result) {
         setResult(result.getResultCode(), result.toResultDataIntent());
         finish();
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
index 8853fd3..a17c06e 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
@@ -34,2 +34,3 @@ import java.util.TreeSet;
 import org.openyolo.demoprovider.barbican.CredentialQualityScore;
+import org.openyolo.demoprovider.barbican.ProtoListUtil;
 import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
@@ -38,3 +39,2 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.Protobufs.Credential;
-import org.openyolo.protocol.Protobufs.CredentialList;
 import org.spongycastle.crypto.digests.Blake2bDigest;
@@ -45,595 +45,591 @@ import org.spongycastle.crypto.io.CipherOutputStream;
 /**
  * An encrypted file-system based credential store. Uses bcrypt to derive an encryption key from
  * a password. Creates a directory for each authentication domain (using a hash of the domain)
  * under which the set of credentials for that domain is stored. This allows determining whether
  * a credential is available for a given authentication domain without the encryption key, which
  * is useful for answering OpenYOLO requests.
  */
 public final class CredentialStorage {
 
     private static final String LOG_TAG = "CredentialStorage";
 
     private static final int SALT_SIZE = 16;
     private static final int BCRYPT_COST = 10;
 
     private static final int AUTH_DOMAIN_HASH_SIZE = 32;
 
     private static final char[] HEX_CHARS =
             { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
     private static final byte[] KEY_VERIFICATION_BYTES =
             { 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0 };
     private static final int HALF_BYTE_WIDTH = 4;
     private static final int HALF_BYTE_MASK = 0xF;
 
     @NonNull
     private SecureRandom mRandom;
 
     @NonNull
     private File mStoreDir;
 
     private byte[] mSalt;
 
     @Nullable
     private byte[] mKey;
 
     /**
      * Initializes a credential store in the default location for the application.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(Context context) throws IOException {
         this(new SecureRandom(), new File(context.getFilesDir(), "store"));
     }
 
     /**
      * Initializes a credential store in the specified location.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(
             @NonNull SecureRandom random,
             @NonNull File storeDir)
             throws IOException {
         mRandom = random;
         mStoreDir = storeDir;
 
         if (mStoreDir.exists()) {
             CredentialMeta credentialMeta = readCredentialMeta();
             mSalt = credentialMeta.getSalt().toByteArray();
         }
     }
 
     /**
      * Determines whether a credential store exists in the initialized location.
      */
     public boolean isCreated() {
         return mStoreDir.exists();
     }
 
     /**
      * Determines whether the credential store is unlocked, meaning that the encryption key has
      * been derived from the password and is resident in memory.
      */
     public boolean isUnlocked() {
         return mKey != null;
     }
 
     /**
      * Locks the credential store, meaning that the derived encryption key is released from
      * memory if necessary.
      */
     public void lock() {
         // overwrite the key with random data, then release it for garbage collection
         mRandom.nextBytes(mKey);
         mKey = null;
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     @Nullable
     public List<String> retrieveNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         return meta.getNeverSaveList();
     }
 
     /**
      * Clears the "never save" list.
      * @throws IOException - in the case when the storage fails to be written
      */
     public void clearNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         writeCredentialMeta(meta.toBuilder().clearNeverSave().build());
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
         if (meta.getNeverSaveCount() < 1) {
             return false;
         }
 
         HashSet<String> authDomainsAsStrings = new HashSet<>();
         for (AuthenticationDomain authDomain : authDomains) {
             authDomainsAsStrings.add(authDomain.toString());
         }
 
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             if (authDomainsAsStrings.contains(neverSaveDomain)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Adds the specified authentication domain to the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             neverSaveDomains.add(neverSaveDomain);
         }
 
         neverSaveDomains.add(authDomain.toString());
 
         writeCredentialMeta(
                 meta.toBuilder()
                     .clearNeverSave()
                     .addAllNeverSave(neverSaveDomains)
                     .build());
     }
 
     /**
      * Removes the specified list of authentication domains from the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             neverSaveDomains.add(neverSaveDomain);
         }
 
         for (AuthenticationDomain authDomain : authDomains) {
             neverSaveDomains.remove(authDomain.toString());
         }
 
         writeCredentialMeta(
                 meta.toBuilder()
                     .clearNeverSave()
                     .addAllNeverSave(neverSaveDomains)
                     .build());
     }
 
     /**
      * Returns all account hints. The list of hints is automatically maintained as part of the
      * other credential save / delete operations.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public List<AccountHint> getHints() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         return meta.getHintsList();
     }
 
     /**
      * Determines whether any credentials are stored for the given authentication domain. This
      * does not require the credential store to be unlocked.
      */
     public boolean hasCredentialFor(@NonNull String authDomain) {
         return getAuthDomainDir(authDomain).exists();
     }
 
     /**
      * Returns a list of all stored credentials. Requires that the credential store is unlocked.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listAllCredentials() throws IOException {
         ArrayList<Credential> allCredentials = new ArrayList<>();
         checkUnlocked();
         for (File authDomainDir : mStoreDir.listFiles()) {
             if (!authDomainDir.isDirectory()) {
                 continue;
             }
 
             List<Credential> credentials = readCredentials(authDomainDir);
             allCredentials.addAll(credentials);
         }
 
         return allCredentials;
     }
 
     /**
      * Returns a list of credentials for the specified authentication domain. Requires
      * that the credential store is unlocked. May be empty.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listCredentials(String authDomain) throws IOException {
         checkUnlocked();
         return readCredentials(authDomain);
     }
 
     /**
      * Writes (or overwrites) the provided credential to the store. Requires that the credential
      * store is unlocked. May be empty.
      * @throws IOException if the credential could not be written.
      */
     public void upsertCredential(Credential credential) throws IOException {
         checkUnlocked();
         List<Credential> credentials = new ArrayList<>(
                 readCredentials(credential.getAuthDomain().getUri()));
 
         // replace any existing equivalent
         ListIterator<Credential> it = credentials.listIterator();
         boolean existingFound = false;
         while (it.hasNext() && !existingFound) {
             Credential existing = it.next();
             if (credential.getId().equals(existing.getId())
                     && eq(credential.getAuthDomain(), existing.getAuthDomain())) {
                 existingFound = true;
                 it.set(credential);
             }
         }
 
         if (!existingFound) {
             it.add(credential);
         }
 
         writeCredentials(credential.getAuthDomain().getUri(), credentials);
         upsertHint(credential);
     }
 
     /**
      * Removes the specified credential (or one with the same authentication domain, identifier
      * and "type") from the store. Requires that the store is unlocked.
      * @throws IOException if the credential could not be deleted.
      */
     public void deleteCredential(Credential credential) throws IOException {
         checkUnlocked();
         List<Credential> credentials = new ArrayList<>(readCredentials(
                 credential.getAuthDomain().getUri()));
 
         ListIterator<Credential> it = credentials.listIterator();
         boolean existingFound = false;
         while (it.hasNext() && !existingFound) {
             Credential existing = it.next();
             if (credentialsAreEquivalent(credential, existing)) {
                 existingFound = true;
                 it.remove();
             }
         }
 
         if (existingFound) {
             writeCredentials(credential.getAuthDomain().getUri(), credentials);
         }
     }
 
     private boolean credentialsAreEquivalent(Credential c1, Credential c2) {
         if (c1 == null) {
             return c2 == null;
         }
 
         if (c2 == null) {
             return false;
         }
 
         return c1.getId().equals(c2.getId())
                 && c1.getAuthDomain().equals(c2.getAuthDomain())
                 && c1.getAuthMethod().equals(c2.getAuthMethod());
     }
 
     private boolean areEqual(Object o1, Object o2) {
         return o1 == null ? o2 == null : o1.equals(o2);
     }
 
     /* **************************** store initialization ******************************************/
 
     /**
      * Creates a credential store at the initialized location, deriving an encryption key from
      * the specified password.
      * @throws IOException if the store could not be created.
      */
     public void create(String password) throws IOException {
         if (!mStoreDir.mkdirs()) {
             throw new IllegalStateException("unable to create credential store directory");
         }
 
         CredentialMeta meta = generateCredentialMeta();
         writeCredentialMeta(meta);
 
         mSalt = meta.getSalt().toByteArray();
         mKey = keyFromPassword(password, meta.getCost());
         generateKeyTestFile();
     }
 
     /**
      * Unlocks the credential store, deriving an encryption key from the specified password and
      * validates it.
      * @throws IOException if the store could not be unlocked.
      */
     public boolean unlock(String password) throws IOException {
         if (!isCreated()) {
             throw new IllegalStateException("Store has not been created");
         }
 
         CredentialMeta credentialMeta = readCredentialMeta();
         mSalt = credentialMeta.getSalt().toByteArray();
         mKey = keyFromPassword(password, credentialMeta.getCost());
         return verifyKey();
     }
 
     /* **************************** credential meta handling **************************************/
 
     private File getCredentialMetaFile() {
         return new File(mStoreDir, "meta");
     }
 
     private CredentialMeta generateCredentialMeta() {
         return CredentialMeta.newBuilder()
                 .setSalt(ByteString.copyFrom(generateRandomBytes(SALT_SIZE)))
                 .setCost(BCRYPT_COST)
                 .build();
     }
 
     private void writeCredentialMeta(CredentialMeta meta) throws IOException {
         FileOutputStream stream = null;
         try {
             stream = new FileOutputStream(getCredentialMetaFile());
             meta.writeTo(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private CredentialMeta readCredentialMeta() throws IOException {
         FileInputStream stream = null;
         try {
             stream = new FileInputStream(getCredentialMetaFile());
             return CredentialMeta.parseFrom(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private void upsertHint(Credential credential) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         // create a copy of the hints list for modification
         List<AccountHint> hints = new ArrayList<>(readCredentialMeta().getHintsList());
 
         ListIterator<AccountHint> hintIter = hints.listIterator();
         boolean found = false;
         while (!found && hintIter.hasNext()) {
             AccountHint existingHint = hintIter.next();
 
             if (existingHint.getIdentifier().equals(credential.getId())
                     && existingHint.getAuthMethod().equals(credential.getAuthMethod())
                     && CredentialQualityScore.getScore(existingHint)
                             <= CredentialQualityScore.getScore(credential)) {
                 hintIter.remove();
                 hintIter.add(convertCredentialToHint(credential));
                 found = true;
             }
         }
 
         if (!found) {
             hintIter.add(convertCredentialToHint(credential));
         }
 
         writeCredentialMeta(meta.toBuilder()
                 .clearHints()
                 .addAllHints(hints)
                 .build());
     }
 
     private AccountHint convertCredentialToHint(Credential credential) {
         return AccountHint.newBuilder()
                 .setIdentifier(credential.getId())
                 .setAuthMethod(credential.getAuthMethod().getUri())
                 .setName(credential.getDisplayName())
                 .setPictureUri(credential.getDisplayPictureUri())
                 .build();
     }
 
     /* **************************** key validation ************************************************/
 
     private File getKeyTestFile() {
         return new File(mStoreDir, "test");
     }
 
     private void generateKeyTestFile() throws IOException {
         CipherOutputStream stream = null;
         try {
             stream = IoUtil.encryptTo(getKeyTestFile(), mKey);
             stream.write(KEY_VERIFICATION_BYTES);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private boolean verifyKey() throws IOException {
         CipherInputStream stream = null;
         try {
             stream = IoUtil.decryptFrom(getKeyTestFile(), mKey);
             byte[] bytes = new byte[KEY_VERIFICATION_BYTES.length];
             int numRead = stream.read(bytes);
             return numRead == KEY_VERIFICATION_BYTES.length
                 && bytesEqual(KEY_VERIFICATION_BYTES, bytes);
         } catch (IOException ex) {
             Log.i(LOG_TAG, "Key verification failed");
             return false;
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* ************************** auth domain directory management ********************************/
 
     private File getAuthDomainDir(String authDomain) {
         return new File(mStoreDir, toBlakeHash(authDomain));
     }
 
     private File initAuthDomainDir(String authDomain) throws IOException {
         File authorityDir = getAuthDomainDir(authDomain);
         if (!authorityDir.exists()) {
             if (!authorityDir.mkdirs()) {
                 throw new IOException("failed to create authority dir");
             }
         }
 
         return authorityDir;
     }
 
     private void deleteAuthDomainDir(String authDomain) throws IOException {
         File credsFile = getCredentialsFile(authDomain);
         if (credsFile.exists()) {
             if (!credsFile.delete()) {
                 throw new IOException("failed to delete credentials file");
             }
         }
 
         File authorityDir = getAuthDomainDir(authDomain);
         if (authorityDir.exists()) {
             if (!authorityDir.delete()) {
                 throw new IOException("failed to delete authority directory");
             }
         }
     }
 
     private File getCredentialsFile(String authDomain) {
         return getCredentialsFile(getAuthDomainDir(authDomain));
     }
 
     private File getCredentialsFile(File authDomainDir) {
         return new File(authDomainDir, "creds");
     }
 
     /* **************************** credential manipulation ***************************************/
 
     private void writeCredentials(String authDomain, List<Credential> credentials)
             throws IOException {
         if (credentials.size() == 0) {
             deleteAuthDomainDir(authDomain);
             return;
         }
 
         initAuthDomainDir(authDomain);
         CipherOutputStream stream = null;
         try {
             stream = IoUtil.encryptTo(getCredentialsFile(authDomain), mKey);
-            CredentialList proto = CredentialList.newBuilder()
-                    .addAllCredentials(credentials)
-                    .build();
-
-            proto.writeTo(stream);
+            ProtoListUtil.writeMessageListTo(stream, credentials);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private List<Credential> readCredentials(String authDomain) throws IOException {
         return readCredentials(getAuthDomainDir(authDomain));
     }
 
     private List<Credential> readCredentials(File authDomain) throws IOException {
         File credentialsFile = getCredentialsFile(authDomain);
         if (!credentialsFile.exists()) {
             return Collections.emptyList();
         }
 
         CipherInputStream stream = null;
         try {
             stream = IoUtil.decryptFrom(credentialsFile, mKey);
-            return CredentialList.parseFrom(stream).getCredentialsList();
+            return ProtoListUtil.readMessageList(stream, Credential.parser());
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* *********************************** utils **************************************************/
 
     private void checkUnlocked() {
         if (!isUnlocked()) {
             throw new IllegalStateException("credential store is locked");
         }
     }
 
     private byte[] keyFromPassword(String password, int cost) {
         return BCrypt.generate(toUtf8Bytes(password), mSalt, cost);
     }
 
     private static byte[] toUtf8Bytes(String str) {
         try {
             return str.getBytes("UTF-8");
         } catch (UnsupportedEncodingException e) {
             throw new IllegalStateException("UTF-8 character set not supported, against spec");
         }
     }
 
     private byte[] generateRandomBytes(int length) {
         byte[] bytes = new byte[length];
         mRandom.nextBytes(bytes);
         return bytes;
     }
 
     private boolean bytesEqual(byte[] b1, byte[] b2) {
         if (b1 == null) {
             return b2 == null;
         }
 
         if (b2 == null || b1.length != b2.length) {
             return false;
         }
 
         for (int i = 0; i < b1.length; i++) {
             if (b1[i] != b2[i]) {
                 return false;
             }
         }
 
         return true;
     }
 
     private String toBlakeHash(String message) {
         Blake2bDigest digest = new Blake2bDigest(
                 null, /* no key */
                 AUTH_DOMAIN_HASH_SIZE,
                 mSalt,
                 null); /* no personalization of the hashing function */
         byte[] messageBytes = toUtf8Bytes(message);
         digest.update(messageBytes, 0, messageBytes.length);
         byte[] result = new byte[AUTH_DOMAIN_HASH_SIZE];
         digest.doFinal(result, 0);
         return toHexString(result);
     }
 
     private String toHexString(byte[] bytes) {
         char[] result = new char[bytes.length * 2];
         for (int i = 0, j = 0; i < bytes.length; i++, j += 2) {
             byte nextByte = bytes[i];
 
             result[j] = HEX_CHARS[(nextByte >>> HALF_BYTE_WIDTH) & HALF_BYTE_MASK];
             result[j + 1] = HEX_CHARS[nextByte & HALF_BYTE_MASK];
         }
         return new String(result);
     }
 
     private boolean eq(Object o1, Object o2) {
         if (o1 == null) {
             return o2 == null;
         }
         return o2 != null && o1.equals(o2);
     }
 }
diff --git a/demoproviders/barbican/res/layout/hint_picker_layout.xml b/demoproviders/barbican/res/layout/hint_picker_layout.xml
new file mode 100644
index 0000000..f283f96
--- /dev/null
+++ b/demoproviders/barbican/res/layout/hint_picker_layout.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/colorPrimary"
+    android:orientation="vertical"
+    android:paddingBottom="16dp"
+    android:paddingTop="16dp"
+    tools:ignore="InconsistentLayout">
+
+  <ImageView
+      android:layout_width="48dp"
+      android:layout_height="48dp"
+      android:layout_gravity="center_horizontal"
+      android:contentDescription="@string/logo_contentDescription"
+      app:srcCompat="@drawable/app_icon"/>
+
+  <TextView
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_gravity="center_horizontal"
+      android:text="@string/hint_selection_prompt"
+      android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
+
+  <android.support.v7.widget.RecyclerView
+      android:id="@+id/available_hints"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_marginTop="8dp"
+      android:layout_weight="1" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/values/strings.xml b/demoproviders/barbican/res/values/strings.xml
index 2e93dcb..99a53e4 100644
--- a/demoproviders/barbican/res/values/strings.xml
+++ b/demoproviders/barbican/res/values/strings.xml
@@ -1,37 +1,38 @@
 <resources xmlns:xliff="http://schemas.android.com/tools">
     <string name="action_create_done_contentDescription">Store credential</string>
     <string name="action_lock_contentDescription">Lock credential store</string>
     <string name="app_name_short">Barbican</string>
     <string name="app_spinner_label">App:</string>
     <string name="create_credential_activity_label">Store credential</string>
     <string name="create_failure">Failed to create the credential store :(</string>
     <string name="credential_storage_service_label">Barbican credential storage service</string>
     <string name="credential_authority_icon">App icon</string>
     <string name="credential_selection_prompt">Continue with:</string>
+    <string name="hint_selection_prompt">Continue with:</string>
     <string name="credential_icon">Credential profile picture</string>
     <string name="id_hint">User name</string>
     <string name="invalid_password">Invalid password, try again</string>
     <string name="logo_contentDescription">Barbican logo</string>
     <string name="password_hint">Password</string>
     <string name="save_failed">Failed to save credential :(</string>
     <string name="unlock_prompt">Enter your password:</string>
     <string name="unlock_loading_prompt">Decrypting store…</string>
     <string name="unlocked_notification_title">Barbican is unlocked</string>
     <string name="unlocked_notification_text">Passwords are currently readable.</string>
     <string name="unlocked_notification_lock_action">Lock now</string>
     <string name="welcome_loading_prompt">Initializing storage…</string>
     <string name="welcome_title">Welcome!</string>
     <string name="welcome_prompt">Please choose a password with at least 6 characters:</string>
     <string name="never_save">Never</string>
     <string name="save_account">Save account</string>
     <string name="save_prompt_template">
         Would you like to save your account for
         <xliff:g example="Netflix" id="appName">%1$s</xliff:g>
         to Barbican?
     </string>
     <string name="action_wipe_contentDescription">Wipe associations for save</string>
     <string name="remove_unpaired_api_dialog_title">Remove this App from the \"Never Save\" list?</string>
     <string name="openyolo_simple_yes">Yes</string>
     <string name="openyolo_simple_no">No</string>
     <string name="ask_delete_credential">Delete credential?</string>
 </resources>
diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index 63f989e..426545e 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -38,405 +38,407 @@ import org.openyolo.protocol.internal.ByteStringConverters;
 import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
- * A representation of a credential for use in sign-in or sign-up. This provides a
- * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential
- * protocol buffer} that is returned by the app.
+ * A representation of a credential for use in sign-in. This provides a higher-level,
+ * data-verifying wrapper for the underlying {@link Protobufs.Credential protocol buffer} that is
+ * returned by the provider.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     /**
      * Creates a credential from its protocol buffer equivalent, in byte form.
      * @throws IOException if the protocol buffer cannot be parsed.
      */
     public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
         return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
     }
 
     /**
      * Creates a credential from its protocol buffer equivalent.
      */
     public static Credential fromProtobuf(Protobufs.Credential credential) {
         return new Credential.Builder(credential).build();
     }
 
     @NonNull
     private final String mId;
 
     @NonNull
     private final AuthenticationDomain mAuthDomain;
 
     @NonNull
     private final AuthenticationMethod mAuthMethod;
 
     @Nullable
     private final String mDisplayName;
 
     @Nullable
     private final Uri mDisplayPicture;
 
     @Nullable
     private final String mPassword;
 
     @Nullable
     private final String mIdToken;
 
     @NonNull
     private final Map<String, ByteString> mAdditionalProps;
 
     private Credential(
             @NonNull String id,
             @NonNull AuthenticationDomain authDomain,
             @NonNull AuthenticationMethod authMethod,
             @Nullable String displayName,
             @Nullable Uri displayPicture,
             @Nullable String password,
             @Nullable String idToken,
             @NonNull Map<String, ByteString> additionalProps) {
         mId = id;
         mAuthDomain = authDomain;
         mAuthMethod = authMethod;
         mDisplayName = displayName;
         mDisplayPicture = displayPicture;
         mPassword = password;
         mIdToken = idToken;
         mAdditionalProps = additionalProps;
     }
 
     /**
      * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
     public Protobufs.Credential toProtobuf() {
         Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
                 .setId(mId)
                 .setAuthMethod(mAuthMethod.toProtobuf())
                 .setAuthDomain(mAuthDomain.toProtobuf())
                 .putAllAdditionalProps(mAdditionalProps);
 
         if (mDisplayName != null) {
             builder.setDisplayName(mDisplayName);
         }
 
         if (mDisplayPicture != null) {
             builder.setDisplayPictureUri(mDisplayPicture.toString());
         }
 
         if (mPassword != null) {
             builder.setPassword(mPassword);
         }
 
         if (mIdToken != null) {
             builder.setIdToken(mIdToken);
         }
 
         return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
         return mId;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public AuthenticationMethod getAuthenticationMethod() {
         return mAuthMethod;
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
     @NonNull
     public AuthenticationDomain getAuthenticationDomain() {
         return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
         return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
         return mDisplayPicture;
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
         return mPassword;
     }
 
     /**
      * An ID token which provides "proof of access" to the identifier for this credential, if
      * available.
      */
     @Nullable
     public String getIdToken() {
         return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
             mAdditionalProps,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
         private String mId;
         private AuthenticationMethod mAuthMethod;
         private AuthenticationDomain mAuthDomain;
         private String mDisplayName;
         private Uri mDisplayPicture;
         private String mPassword;
         private String mIdToken;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          */
         public Builder(@NonNull Protobufs.Credential proto) {
             // required properties
             setIdentifier(proto.getId());
             setAuthenticationMethod(
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT
                             .convert(proto.getAuthMethod()));
             setAuthenticationDomain(
                     AuthenticationDomainConverters.PROTOBUF_TO_OBJECT
                             .convert(proto.getAuthDomain()));
 
             // optional properties
 
             setDisplayName(proto.getDisplayName());
             setDisplayPicture(proto.getDisplayPictureUri());
             setPassword(proto.getPassword());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             proto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
          * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
                     new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
             require(!TextUtils.isEmpty(identifier), "identifier must not be null or empty");
             mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             require(domain, notNullValue());
             mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
         public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
             require(authMethod, notNullValue());
             mAuthMethod = authMethod;
             return this;
         }
 
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
             mPassword = nullifyEmptyString(password);
             return this;
         }
 
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
             mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             require(displayPicture, nullOr(isWebUri()));
             mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
             if (additionalProps == null) {
                 mAdditionalProps.clear();
+                return this;
             }
+
             require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProps.values(), everyItem(notNullValue()));
 
             mAdditionalProps = CollectionConverter.convertMapValues(
                     additionalProps,
                     ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
             return new Credential(
                     mId,
                     mAuthDomain,
                     mAuthMethod,
                     mDisplayName,
                     mDisplayPicture,
                     mPassword,
                     mIdToken,
                     mAdditionalProps);
         }
     }
 
     private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
                 Protobufs.Credential proto = Protobufs.Credential.parseFrom(encodedBytes);
                 return new Credential.Builder(proto).build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
index 7a259fd..305bc7b 100644
--- a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -32,221 +32,221 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * Result data which is sent in response to a credential retrieve request. Contains a result code,
  * indicating whether the request was successful or not, an optional returned credential, and
  * an optional set of additional, non-standard result properties.
  */
 public final class CredentialRetrieveResult {
 
     /**
      * Indicates that the provider returned a response that could not be interpreted.
      */
     public static final int RESULT_UNKNOWN =
             Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
 
     /**
      * Indicates that the credential request completed without any issues.
      */
     public static final int RESULT_SUCCESS =
             Protobufs.CredentialRetrieveResult.ResultCode.SUCCESS_VALUE;
 
     /**
      * Indicates that the credential request was denied by the provider.
      */
     public static final int RESULT_REJECTED_BY_PROVIDER =
             Protobufs.CredentialRetrieveResult.ResultCode.REJECTED_BY_PROVIDER_VALUE;
 
     /**
-     * Indicates that the credential request was defined by the user.
+     * Indicates that the credential request was denied by the user.
      */
     public static final int RESULT_REJECTED_BY_USER =
             Protobufs.CredentialRetrieveResult.ResultCode.REJECTED_BY_USER_VALUE;
 
     /**
      * Indicates that the credential request was rejected by the provider.
      */
     public static final CredentialRetrieveResult REJECTED_BY_PROVIDER =
             new CredentialRetrieveResult.Builder(RESULT_REJECTED_BY_PROVIDER).build();
 
     /**
      * Indicates that the credential request was rejected by the user.
      */
     public static final CredentialRetrieveResult REJECTED_BY_USER =
             new CredentialRetrieveResult.Builder(RESULT_REJECTED_BY_USER).build();
 
     /**
      * Creates a credential retrieve request from its protocol buffer byte equivalent.
      * @throws IOException if the request could not be parsed or validated.
      */
     public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
             throws IOException {
         return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
     }
 
     /**
      * Creates a credential retrieve request from its protocol buffer equivalent.
      */
     public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto) {
         return new CredentialRetrieveResult.Builder(proto).build();
     }
 
     private final int mResultCode;
 
     @Nullable
     private final Credential mCredential;
 
     @NonNull
     private Map<String, ByteString> mAdditionalProps;
 
     private CredentialRetrieveResult(
             int resultCode,
             Credential credential,
             Map<String, ByteString> additionalProps) {
         mResultCode = resultCode;
         mCredential = credential;
         mAdditionalProps = additionalProps;
     }
 
     /**
      * The result code for the credential retrieve operation.
      */
     public int getResultCode() {
         return mResultCode;
     }
 
     /**
      * The credential returned by the credential provider, if available.
      */
     @Nullable
     public Credential getCredential() {
         return mCredential;
     }
 
     /**
      * The additional, non-standard properties returned by the credential provider, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProps() {
         return CollectionConverter.convertMapValues(
                 mAdditionalProps,
                 ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates a protocol buffer representation of the credential retrieve result, for transmission
      * or storage.
      */
     public Protobufs.CredentialRetrieveResult toProtobuf() {
         Protobufs.CredentialRetrieveResult.Builder builder =
                 Protobufs.CredentialRetrieveResult.newBuilder()
                         .setResultCodeValue(mResultCode)
                         .putAllAdditionalProps(mAdditionalProps);
 
         if (mCredential != null) {
             builder.setCredential(mCredential.toProtobuf());
         }
 
         return builder.build();
     }
 
     /**
      * Creates an {@link Intent} containing this credential retrieve result, that a provider should
      * return as its activity result.
      */
     public Intent toResultDataIntent() {
         Intent intent = new Intent();
         intent.putExtra(
                 ProtocolConstants.EXTRA_RETRIEVE_RESULT,
                 toProtobuf().toByteArray());
         return intent;
     }
 
     /**
      * Creates validated {@link CredentialRetrieveResult} instances.
      */
     public static final class Builder {
 
         private int mResultCode;
         private Credential mCredential;
         private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of describing a credential retrieve result, and includes the
          * mandatory status code.
          */
         public Builder(int resultCode) {
             setResultCode(resultCode);
         }
 
         /**
          * Seeds a credential retrieval result from its protocol buffer equivalent.
          */
         public Builder(Protobufs.CredentialRetrieveResult proto) {
             setResultCode(proto.getResultCodeValue());
             setCredentialFromProto(proto.getCredential());
             setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
         }
 
         /**
          * Specifies the result code. It is recommended to use one of the standard values, though
          * any value may be used.
          *
          * @see CredentialRetrieveResult#RESULT_SUCCESS
          * @see CredentialRetrieveResult#RESULT_REJECTED_BY_PROVIDER
          * @see CredentialRetrieveResult#RESULT_REJECTED_BY_USER
          * @see CredentialRetrieveResult#RESULT_UNKNOWN
          */
         public Builder setResultCode(int resultCode) {
             mResultCode = resultCode;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result. Can be null.
          */
         public Builder setCredential(@Nullable Credential credential) {
             mCredential = credential;
             return this;
         }
 
         /**
          * Specifies the credential being returned as part of this result, in protocol buffer
          * form. Can be null.
          */
         public Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
             mCredential = credential != null ? Credential.fromProtobuf(credential) : null;
             return this;
         }
 
         /**
          * Specifies the set of additional, non-standard properties to return as part of this
          * result. The keys and values of the provided map must not be null. The keys must not
          * be empty.
          */
         public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
             require(additionalProperties, notNullValue());
             require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProperties.values(), everyItem(notNullValue()));
 
             mAdditionalProps =
                     CollectionConverter.convertMapValues(
                             additionalProperties,
                             ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProperties) {
             require(additionalProperties, notNullValue());
             require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalProperties.values(), everyItem(notNullValue()));
 
             mAdditionalProps = additionalProperties;
             return this;
         }
 
         /**
          * Finalizes the creation of the credential retrieval result.
          */
         public CredentialRetrieveResult build() {
             return new CredentialRetrieveResult(mResultCode, mCredential, mAdditionalProps);
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Hint.java b/protocol/java/org/openyolo/protocol/Hint.java
new file mode 100644
index 0000000..dbb2fca
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/Hint.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.protocol.internal.CustomMatchers.isWebUri;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.openyolo.protocol.internal.CustomMatchers.nullOr;
+import static org.openyolo.protocol.internal.StringUtil.nullifyEmptyString;
+import static org.valid4j.Assertive.require;
+
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * A representation of a hint for use in account discovery or account creation. This provides a
+ * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential protocol
+ * buffer} that is returned by the provider.
+ *
+ * <p>Hints must have an {@link #getIdentifier() identifier} and an
+ * an {@link #getAuthenticationMethod() authentication method}, but all other properties are
+ * optional.
+ */
+public final class Hint implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link Hint} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<Hint> CREATOR = new HintCreator();
+
+    /**
+     * Creates a hint from its protocol buffer equivalent.
+     */
+    public static Hint fromProtobuf(Protobufs.Hint proto) {
+        return new Hint.Builder(proto).build();
+    }
+
+    /**
+     * Creates a hint from its protocol buffer equivalent, in byte array form.
+     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     */
+    public static Hint fromProtobufBytes(byte[] protoBytes) throws IOException {
+        return fromProtobuf(Protobufs.Hint.parseFrom(protoBytes));
+    }
+
+    @NonNull
+    private final String mId;
+
+    @NonNull
+    private final AuthenticationMethod mAuthMethod;
+
+    @Nullable
+    private final String mDisplayName;
+
+    @Nullable
+    private final Uri mDisplayPictureUri;
+
+    @Nullable
+    private final String mGeneratedPassword;
+
+    @Nullable
+    private final String mIdToken;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProps;
+
+    private Hint(Hint.Builder builder) {
+        mId = builder.mId;
+        mAuthMethod = builder.mAuthMethod;
+        mDisplayName = builder.mDisplayName;
+        mDisplayPictureUri = builder.mDisplayPictureUri;
+        mGeneratedPassword = builder.mGeneratedPassword;
+        mIdToken = builder.mIdToken;
+        mAdditionalProps = Collections.unmodifiableMap(builder.mAdditionalProps);
+    }
+
+    /**
+     * Creates a protocol buffer representation of the hint, for transmission or storage.
+     */
+    public Protobufs.Hint toProtobuf() {
+        Protobufs.Hint.Builder builder = Protobufs.Hint.newBuilder()
+                .setId(mId)
+                .setAuthMethod(mAuthMethod.toProtobuf())
+                .putAllAdditionalProps(mAdditionalProps);
+
+        if (mDisplayName != null) {
+            builder.setDisplayName(mDisplayName);
+        }
+
+        if (mDisplayPictureUri != null) {
+            builder.setDisplayPictureUri(mDisplayPictureUri.toString());
+        }
+
+        if (mGeneratedPassword != null) {
+            builder.setGeneratedPassword(mGeneratedPassword);
+        }
+
+        if (mIdToken != null) {
+            builder.setIdToken(mIdToken);
+        }
+
+        return builder.build();
+    }
+
+    /**
+     * The hint identifier, for use in discovering an existing account within the context of the
+     * authentication method and authentication domain (which is implicitly that of the requester),
+     * or creating a new account.
+     */
+    @NonNull
+    public String getIdentifier() {
+        return mId;
+    }
+
+    /**
+     * The authentication domain associated with the hint.
+     */
+    @NonNull
+    public AuthenticationMethod getAuthenticationMethod() {
+        return mAuthMethod;
+    }
+
+    /**
+     * A suggested display name for accounts created using this hint, if available.
+     */
+    @Nullable
+    public String getDisplayName() {
+        return mDisplayName;
+    }
+
+    /**
+     * A suggested profile picture for accounts created using this hint. if available.
+     */
+    @Nullable
+    public Uri getDisplayPictureUri() {
+        return mDisplayPictureUri;
+    }
+
+    /**
+     * A suggested password for use with accounts created using this hint, if available.
+     */
+    @Nullable
+    public String getGeneratedPassword() {
+        return mGeneratedPassword;
+    }
+
+    /**
+     * An ID token that provides "proof of access" to the hint identifier, if available.
+     * When provided this can be used either as a means of authentication in its
+     * own right, or as a means to bypass manual proof of access verification, such as by sending
+     * an email with a verification link or an SMS with a code.
+     */
+    @Nullable
+    public String getIdToken() {
+        return mIdToken;
+    }
+
+    /**
+     * Additional, non-standard properties associated with the hint.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        byte[] hintBytes = toProtobuf().toByteArray();
+        dest.writeInt(hintBytes.length);
+        dest.writeByteArray(hintBytes);
+    }
+
+    /**
+     * Creates instances of {@link Hint}.
+     */
+    public static final class Builder {
+
+        @NonNull
+        private String mId;
+
+        @NonNull
+        private AuthenticationMethod mAuthMethod;
+
+        @Nullable
+        private String mDisplayName;
+
+        @Nullable
+        private Uri mDisplayPictureUri;
+
+        @Nullable
+        private String mGeneratedPassword;
+
+        @Nullable
+        private String mIdToken;
+
+        @NonNull
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Starts the process of creating a hint, with the mandatory properties specified.
+         */
+        public Builder(
+                @NonNull String id,
+                @NonNull AuthenticationMethod authMethod) {
+            setIdentifier(id);
+            setAuthMethod(authMethod);
+        }
+
+        /**
+         * Starts the process of creating a hint, with the mandatory properties specified.
+         */
+        public Builder(
+                @NonNull String id,
+                @NonNull String authMethod) {
+            this(id, new AuthenticationMethod(authMethod));
+        }
+
+        /**
+         * Starts the process of creating a hint, based on the properties of the provided
+         * protocol buffer representation of the credential. The protocol buffer must contain
+         * valid data for a hint.
+         */
+        public Builder(
+                @NonNull Protobufs.Hint proto) {
+            require(proto, notNullValue());
+            setIdentifier(proto.getId());
+            setAuthMethod(proto.getAuthMethod().getUri());
+            setDisplayName(proto.getDisplayName());
+            setDisplayPictureUri(proto.getDisplayPictureUri());
+            setGeneratedPassword(proto.getGeneratedPassword());
+            setIdToken(proto.getIdToken());
+            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        }
+
+        /**
+         * Specifies the identifier for the hint. Must not be null or empty.
+         */
+        public Builder setIdentifier(@NonNull String id) {
+            require(id, notNullOrEmptyString());
+            mId = id;
+            return this;
+        }
+
+        /**
+         * Specifies the authentication method for the hint, in string form. Must be a valid
+         * authentication method URI.
+         *
+         * @see AuthenticationMethod
+         */
+        public Builder setAuthMethod(@NonNull String authMethod) {
+            require(authMethod, isValidAuthenticationMethod());
+            mAuthMethod = new AuthenticationMethod(authMethod);
+            return this;
+        }
+
+        /**
+         * Specifies the authentication method for the hint. Must not be null.
+         */
+        public Builder setAuthMethod(@NonNull AuthenticationMethod authMethod) {
+            require(authMethod, notNullValue());
+            mAuthMethod = authMethod;
+            return this;
+        }
+
+        /**
+         * Specifies the display name for the hint. Empty values are treated as null.
+         */
+        public Builder setDisplayName(@Nullable String displayName) {
+            mDisplayName = nullifyEmptyString(displayName);
+            return this;
+        }
+
+        /**
+         * Specifies the display picture URI for the hint, in string form. Empty values are
+         * treated as null. Non-empty values must be valid http(s) URIs.
+         */
+        public Builder setDisplayPictureUri(@Nullable String displayPictureUri) {
+            setDisplayPictureUri(nullifyEmptyString(displayPictureUri) != null
+                            ? Uri.parse(displayPictureUri)
+                            : null);
+            return this;
+        }
+
+        /**
+         * Specifies the display picture URI for the hint, in string form. Non-null values
+         * must be valid http(s) URIs.
+         */
+        public Builder setDisplayPictureUri(@Nullable Uri displayPictureUri) {
+            require(displayPictureUri, nullOr(isWebUri()));
+            mDisplayPictureUri = displayPictureUri;
+            return this;
+        }
+
+        /**
+         * Specifies the generated password for the hint. Empty values are treated as null.
+         */
+        public Builder setGeneratedPassword(@Nullable String generatedPassword) {
+            mGeneratedPassword = nullifyEmptyString(generatedPassword);
+            return this;
+        }
+
+        /**
+         * Specifies the "proof of access" ID token for the hint. Empty values are treated as null.
+         */
+        public Builder setIdToken(@Nullable String idToken) {
+            mIdToken = nullifyEmptyString(idToken);
+            return this;
+        }
+
+        /**
+         * Specifies any additional, non-standard properties associated with the hint.
+         */
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+            return this;
+        }
+
+        private Builder setAdditionalPropertiesFromProto(
+                @Nullable Map<String, ByteString> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
+            return this;
+        }
+
+        /**
+         * Creates the {@link Hint hint} instance with the specified properties.
+         */
+        public Hint build() {
+            return new Hint(this);
+        }
+    }
+
+    private static final class HintCreator implements Creator<Hint> {
+
+        @Override
+        public Hint createFromParcel(Parcel source) {
+            int length = source.readInt();
+            byte[] hintBytes = new byte[length];
+            source.readByteArray(hintBytes);
+            try {
+                return Hint.fromProtobufBytes(hintBytes);
+            } catch (IOException e) {
+                throw new IllegalArgumentException("Unable to parse hint from parcel");
+            }
+        }
+
+        @Override
+        public Hint[] newArray(int size) {
+            return new Hint[size];
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/HintRequest.java b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
similarity index 91%
rename from protocol/java/org/openyolo/protocol/HintRequest.java
rename to protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
index 9275064..e91371d 100644
--- a/protocol/java/org/openyolo/protocol/HintRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveRequest.java
@@ -40,314 +40,314 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
-public class HintRequest implements Parcelable {
+public class HintRetrieveRequest implements Parcelable {
 
     /**
-     * Parcelable reader for {@link HintRequest} instances.
+     * Parcelable reader for {@link HintRetrieveRequest} instances.
      * @see android.os.Parcelable
      */
-    public static final Creator<HintRequest> CREATOR = new HintRequestCreator();
+    public static final Creator<HintRetrieveRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
-    public static HintRequest forEmailAndPasswordAccount() {
-        return new HintRequest.Builder(AuthenticationMethods.EMAIL)
+    public static HintRetrieveRequest forEmailAndPasswordAccount() {
+        return new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws IOException if the hint request could not be decoded.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
-    public static HintRequest fromProtoBytes(byte[] hintRequestProtoBytes)
+    public static HintRetrieveRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws IOException {
         if (hintRequestProtoBytes == null) {
             throw new IOException("Unable to decode hint request from null array");
         }
-        return new HintRequest.Builder(
+        return new HintRetrieveRequest.Builder(
                 Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
                 .build();
     }
 
-    private HintRequest(
+    private HintRetrieveRequest(
             @NonNull Set<AuthenticationMethod> authMethods,
             @NonNull PasswordSpecification passwordSpec,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mPasswordSpec = passwordSpec;
         mAdditionalProperties = additionalParams;
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProperties;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8
      * encoded string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         require(key, notNullValue());
         if (mAdditionalProperties.containsKey(key)) {
             return new String(mAdditionalProperties.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         require(key, notNullValue());
         return mAdditionalProperties.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                     CollectionConverter.convertMapValues(
                             mAdditionalProperties,
                             ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
-     * Creates {@link HintRequest} instances.
+     * Creates {@link HintRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalProps = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          *
-         * @see HintRequest#toProtocolBuffer()
+         * @see HintRetrieveRequest#toProtocolBuffer()
          */
         public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setPasswordSpecification(
                     new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(
                 @NonNull AuthenticationMethod authMethod,
                 @NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
                 @NonNull AuthenticationMethod authMethod,
                 AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             require(authMethods, notNullValue());
             require(!authMethods.contains(null), "every authentication methods must be non-null");
             require(!authMethods.isEmpty(), "At least one authentication method must be specified");
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
             require(authenticationMethod, notNullValue());
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
             mAdditionalProps = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request with a string value, that
          * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
          * key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
             require(value, notNullValue());
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request, that will be encoded as
          * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
             mAdditionalProps.put(name, value);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             require(passwordSpec, notNullValue());
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
-         * Creates a {@link HintRequest} with the properties specified on the builder.
+         * Creates a {@link HintRetrieveRequest} with the properties specified on the builder.
          */
         @NonNull
-        public HintRequest build() {
-            return new HintRequest(
+        public HintRetrieveRequest build() {
+            return new HintRetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     mPasswordSpec,
                     unmodifiableMap(mAdditionalProps));
         }
     }
 
-    private static final class HintRequestCreator implements Creator<HintRequest> {
+    private static final class HintRequestCreator implements Creator<HintRetrieveRequest> {
         @Override
-        public HintRequest createFromParcel(Parcel in) {
+        public HintRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
-                return new HintRequest.Builder(
+                return new HintRetrieveRequest.Builder(
                         Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
-        public HintRequest[] newArray(int size) {
-            return new HintRequest[size];
+        public HintRetrieveRequest[] newArray(int size) {
+            return new HintRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRetrieveResult.java b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
new file mode 100644
index 0000000..f5369ad
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/HintRetrieveResult.java
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.Protobufs.HintRetrieveResult.ResultCode;
+import org.openyolo.protocol.internal.AdditionalPropertiesUtil;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * A response to a {@link HintRetrieveRequest hint request}. The status code indicates the outcome
+ * of the request, and the response may contain a hint.
+ */
+public final class HintRetrieveResult {
+
+    /**
+     * Indicates that the provider returned a response that could not be interpreted.
+     */
+    public static final int CODE_UNKNOWN = ResultCode.UNSPECIFIED_VALUE;
+
+    /**
+     * Indicates that the hint request sent to the provider was malformed.
+     */
+    public static final int CODE_BAD_REQUEST = ResultCode.BAD_REQUEST_VALUE;
+
+    /**
+     * Indicates that the user selected a hint, that has been returned as part of this response.
+     */
+    public static final int CODE_HINT_SELECTED = ResultCode.HINT_SELECTED_VALUE;
+
+    /**
+     * Indicates that no hints are available that meet the requirements of the hint request.
+     */
+    public static final int CODE_NO_HINTS_AVAILABLE = ResultCode.NO_HINTS_AVAILABLE_VALUE;
+
+    /**
+     * Indicates that the user  canceled the selection of a hint in a manner that indicates they
+     * wish to proceed with authentication, but by manually entering their details.
+     */
+    public static final int CODE_USER_REQUESTS_MANUAL_AUTH =
+            ResultCode.USER_REQUESTS_MANUAL_AUTH_VALUE;
+
+    /**
+     * Indicates that The user canceled the selection of a hint in a manner that indicates they do
+     * not wish to authenticate at this time.
+     */
+    public static final int CODE_USER_CANCELED = ResultCode.USER_CANCELED_VALUE;
+
+    /**
+     * Pre-built hint result for an unspecified outcome. Carries no hint or additional properties.
+     */
+    public static final HintRetrieveResult UNKNOWN =
+            new HintRetrieveResult.Builder(HintRetrieveResult.CODE_UNKNOWN).build();
+
+    /**
+     * Pre-built hint result for a bad request. Carries no hint or additional properties.
+     */
+    public static final HintRetrieveResult BAD_REQUEST =
+            new HintRetrieveResult.Builder(HintRetrieveResult.CODE_BAD_REQUEST).build();
+
+    /**
+     * Pre-built hint result for when no hints are available. Carries no hint or additional
+     * properties.
+     */
+    public static final HintRetrieveResult NO_HINTS_AVAILABLE =
+            new HintRetrieveResult.Builder(HintRetrieveResult.CODE_NO_HINTS_AVAILABLE).build();
+
+    /**
+     * Pre-built hint result for when the user requests manual authentication. Carries no hint
+     * or additional properties.
+     */
+    public static final HintRetrieveResult USER_REQUESTS_MANUAL_AUTH =
+            new HintRetrieveResult.Builder(
+                    HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH)
+                    .build();
+
+    /**
+     * Pre-built hint result for when the user canceled the selection of a hint in a manner that
+     * indicates they do not wish to authenticate at this time. Carries no hint or additional
+     * properties.
+     */
+    public static final HintRetrieveResult USER_CANCELED =
+            new HintRetrieveResult.Builder(HintRetrieveResult.CODE_USER_CANCELED).build();
+
+    /**
+     * Creates a hint result from its protocol buffer equivalent.
+     */
+    public static HintRetrieveResult fromProtobuf(Protobufs.HintRetrieveResult proto) {
+        return new HintRetrieveResult.Builder(proto).build();
+    }
+
+    /**
+     * Creates a hint result from its protocol buffer equivalent, in byte array form.
+     * @throws IOException if the protocol buffer cannot be parsed from the byte array.
+     */
+    public static HintRetrieveResult fromProtobufBytes(byte[] protoBytes)
+            throws IOException {
+        return fromProtobuf(Protobufs.HintRetrieveResult.parseFrom(protoBytes));
+    }
+
+    private final int mResultCode;
+
+    @Nullable
+    private final Hint mHint;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProps;
+
+    private HintRetrieveResult(
+            int resultCode,
+            @Nullable Hint hint,
+            @NonNull Map<String, ByteString> additionalProps) {
+        mResultCode = resultCode;
+        mHint = hint;
+        mAdditionalProps = additionalProps;
+    }
+
+    /**
+     * Creates a protocol buffer representation of the hint retrieve result, for transmission or
+     * storage.
+     */
+    public Protobufs.HintRetrieveResult toProtobuf() {
+        Protobufs.HintRetrieveResult.Builder builder =
+                Protobufs.HintRetrieveResult.newBuilder()
+                        .setResultCodeValue(mResultCode)
+                        .putAllAdditionalProps(mAdditionalProps);
+
+        if (mHint != null) {
+            builder.setHint(mHint.toProtobuf());
+        }
+
+        return builder.build();
+    }
+
+    /**
+     * Creates an {@link Intent} containing this hint retrieve result, that a provider should
+     * return as its hint activity result.
+     */
+    public Intent toResultDataIntent() {
+        Intent intent = new Intent();
+        intent.putExtra(
+                ProtocolConstants.EXTRA_HINT_RESULT,
+                toProtobuf().toByteArray());
+        return intent;
+    }
+
+    /**
+     * The hint retrieve result code.
+     */
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    /**
+     * The hint returned as part of the hint result, if available.
+     */
+    @Nullable
+    public Hint getHint() {
+        return mHint;
+    }
+
+    /**
+     * The additional, non-standard properties returned by the credential provider as part of the
+     * hint result, if available.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Creates {@link HintRetrieveResult} instances.
+     */
+    public static final class Builder {
+
+        private int mResultCode;
+
+        @Nullable
+        private Hint mHint;
+
+        @NonNull
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Starts the process of describing a hint retrieve result, based on the properties
+         * contained in the provided protocol buffer.
+         */
+        public Builder(@NonNull Protobufs.HintRetrieveResult proto) {
+            setResultCode(proto.getResultCodeValue());
+            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+            setHintFromProto(proto.getHint());
+        }
+
+        /**
+         * Starts the process of describing a hint retrieve result, specifying the mandatory
+         * result code.
+         */
+        public Builder(int resultCode) {
+            setResultCode(resultCode);
+        }
+
+        /**
+         * Specifies the result code.
+         */
+        public Builder setResultCode(int resultCode) {
+            mResultCode = resultCode;
+            return this;
+        }
+
+        /**
+         * Specifies the returned hint, if available.
+         */
+        public Builder setHint(@Nullable Hint hint) {
+            mHint = hint;
+            return this;
+        }
+
+        private Builder setHintFromProto(@Nullable Protobufs.Hint hint) {
+            mHint = (hint != null) ? Hint.fromProtobuf(hint) : null;
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to return as part of this
+         * result. A null map is treated as an empty map. For a non-null map, all keys and values
+         * must not be null, and the keys must not be empty.
+         */
+        public Builder setAdditionalProperties(Map<String, byte[]> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalProperties(additionalProps);
+            return this;
+        }
+
+        private Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProps) {
+            mAdditionalProps =
+                    AdditionalPropertiesUtil.validateAdditionalPropertiesFromProto(additionalProps);
+            return this;
+        }
+
+        /**
+         * Creates the hint retrieve result, from the specified properties.
+         */
+        public HintRetrieveResult build() {
+            return new HintRetrieveResult(
+                    mResultCode,
+                    mHint,
+                    Collections.unmodifiableMap(mAdditionalProps));
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
index 8098649..ffd408f 100644
--- a/protocol/java/org/openyolo/protocol/ProtocolConstants.java
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -17,55 +17,60 @@ package org.openyolo.protocol;
 /**
  * Defines key constants that are used to identify data carried in intents.
  */
 public final class ProtocolConstants {
 
     /**
      * The data type used for credential queries using the BBQ protocol.
      */
     public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
 
     /**
      * The extra value key used to store the credential in a retrieve intent response.
      */
     public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
 
     /**
      * The extra value key used to carry a credential retrieve request.
      */
     public static final String EXTRA_RETRIEVE_REQUEST = "org.openyolo.credential.retrieve.request";
 
     /**
      * The extra value key used to carry a credential retrieve result.
      */
     public static final String EXTRA_RETRIEVE_RESULT = "org.openyolo.credential.retrieve.result";
 
     /**
-     * The extra key value used to carry a hint request to a credential provider.
+     * The extra key value used to carry a hint request.
      */
     public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
 
+    /**
+     * The extra key value used to carry a hint result.
+     */
+    public static final String EXTRA_HINT_RESULT = "org.openyolo.hint.result";
+
     /**
      * The category used for all OpenYOLO-related intents.
      */
     public static final String OPENYOLO_CATEGORY = "org.openyolo";
 
     /**
      * The action used for credential retrieval request intents.
      */
     public static final String RETRIEVE_CREDENTIAL_ACTION = "org.openyolo.credential.retrieve";
 
     /**
      * The action used for hint intents.
      */
     public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
 
     /**
      * The action used for save intents.
      */
     public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
 
 
     private ProtocolConstants() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java b/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
new file mode 100644
index 0000000..df73384
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/AdditionalPropertiesUtil.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Utility methods for the conversion and manipulation of additional property maps.
+ */
+public final class AdditionalPropertiesUtil {
+
+    /**
+     * Ensures that the provided map contains no null or empty keys, and no null values.
+     * Treats a null map as an empty map.
+     */
+    public static Map<String, ByteString> validateAdditionalProperties(
+            @Nullable Map<String, byte[]> additionalProps) {
+        if (additionalProps == null) {
+            return new HashMap<>();
+        }
+
+        require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
+        require(additionalProps.values(), everyItem(notNullValue()));
+
+        return CollectionConverter.convertMapValues(
+                additionalProps,
+                ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
+    }
+
+    /**
+     * Ensures that the provided protocol buffer sourced map contains no null or empty keys, and
+     * no null values. Treats a null map as an empty map.
+     */
+    public static Map<String, ByteString> validateAdditionalPropertiesFromProto(
+            @Nullable Map<String, ByteString> additionalProps) {
+        if (additionalProps == null) {
+            return new HashMap<>();
+        }
+
+        require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
+        require(additionalProps.values(), everyItem(notNullValue()));
+
+        return additionalProps;
+    }
+
+    private AdditionalPropertiesUtil() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/internal/CredentialConverter.java b/protocol/java/org/openyolo/protocol/internal/CredentialConverter.java
new file mode 100644
index 0000000..791fdb0
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/CredentialConverter.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.Protobufs;
+
+/**
+ * Converts credential instances to and from their protocol buffer equivalent.
+ */
+public final class CredentialConverter {
+
+    /**
+     * Converts credential instances to their protocol buffer equivalent.
+     */
+    public static final ValueConverter<Credential, Protobufs.Credential> CREDENTIAL_TO_PROTO =
+            new CredentialToProtoConverter();
+
+    /**
+     * Converts credential instances from their protocol buffer equivalent.
+     */
+    public static final ValueConverter<Protobufs.Credential, Credential> PROTO_TO_CREDENTIAL =
+            new ProtoToCredentialConverter();
+
+    private static final class CredentialToProtoConverter
+            implements ValueConverter<Credential, Protobufs.Credential> {
+        @Override
+        public Protobufs.Credential convert(Credential value) {
+            return value.toProtobuf();
+        }
+    }
+
+    private static final class ProtoToCredentialConverter
+            implements ValueConverter<Protobufs.Credential, Credential> {
+        @Override
+        public Credential convert(Protobufs.Credential value) {
+            return Credential.fromProtobuf(value);
+        }
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
similarity index 83%
rename from protocol/javatests/org/openyolo/protocol/HintRequestTest.java
rename to protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
index 4cc5b35..000b518 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveRequestTest.java
@@ -19,3 +19,2 @@ import static org.assertj.core.data.MapEntry.entry;
 
-import android.net.Uri;
 import android.os.Parcel;
@@ -31,292 +30,292 @@ import org.robolectric.annotation.Config;
 import org.valid4j.errors.RequireViolation;
 
 /**
- * Tests for {@link HintRequest}.
+ * Tests for {@link HintRetrieveRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
-public class HintRequestTest {
+public class HintRetrieveRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
-        HintRequest request = new HintRequest.Builder(
+        HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .addAdditionalProperty("a", new byte[] { 1, 2, 3})
                 .addAdditionalProperty("b", "hello")
                 .setPasswordSpecification(originalSpec)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
 
         assertThat(request.getAdditionalProperties())
                 .containsOnly(
                         entry("a", new byte[] {1, 2, 3}),
                         entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
 
         assertThat(request.getAdditionalProperty("a")).isEqualTo(new byte[] {1, 2, 3});
         assertThat(request.getAdditionalPropertyAsString("b")).isEqualTo("hello");
 
         assertThat(request.getAdditionalProperty("c")).isNull();
         assertThat(request.getAdditionalPropertyAsString("d")).isNull();
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
-        HintRequest request = new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        HintRetrieveRequest request = new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testForEmailAndPasswordAccount() {
-        HintRequest request = HintRequest.forEmailAndPasswordAccount();
+        HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
-            HintRequest request = HintRequest.forEmailAndPasswordAccount();
+            HintRetrieveRequest request = HintRetrieveRequest.forEmailAndPasswordAccount();
             Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     @Test
     public void testSerialize() {
-        HintRequest request = new HintRequest.Builder(
+        HintRetrieveRequest request = new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
-            HintRequest read = HintRequest.CREATOR.createFromParcel(p);
+            HintRetrieveRequest read = HintRetrieveRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullRequestProto() {
-        new HintRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
+        new HintRetrieveRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
-        new HintRequest.Builder((AuthenticationMethod) null).build();
+        new HintRetrieveRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriSet() {
-        new HintRequest.Builder((Set<AuthenticationMethod>) null).build();
+        new HintRetrieveRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriInVarargs() {
-        new HintRequest.Builder(
+        new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullInVarargs() {
-        new HintRequest.Builder(
+        new HintRetrieveRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_emptySet() {
-        new HintRequest.Builder(new HashSet<AuthenticationMethod>()).build();
+        new HintRetrieveRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
-        new HintRequest.Builder(new HashSet<>(authMethods)).build();
+        new HintRetrieveRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullMap() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(null)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullKey() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty(null, "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_emptyKey() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("", "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullByteArrayValue() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (byte[]) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullStringValue() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setPasswordSpecification_null() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
+        new HintRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
new file mode 100644
index 0000000..5c02793
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/HintRetrieveResultTest.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.content.Intent;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.protocol.Protobufs.HintRetrieveResult.ResultCode;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class HintRetrieveResultTest {
+
+    private static final String ALICE_ID = "alice@example.com";
+    private static final String ADDITIONAL_KEY = "extra";
+    private static final byte[] ADDITIONAL_VALUE = "value".getBytes();
+    private static final Map<String, byte[]> ADDITIONAL_PROPS;
+
+    private static final Hint HINT =
+            new Hint.Builder(
+                    ALICE_ID,
+                    AuthenticationMethods.EMAIL)
+                    .build();
+
+    static {
+        HashMap<String, byte[]> additionalProps = new HashMap<>();
+        additionalProps.put(ADDITIONAL_KEY, ADDITIONAL_VALUE);
+        ADDITIONAL_PROPS = Collections.unmodifiableMap(additionalProps);
+    }
+
+    @Test
+    public void build() {
+
+        HintRetrieveResult result = new HintRetrieveResult.Builder(
+                HintRetrieveResult.CODE_HINT_SELECTED)
+                .setHint(HINT)
+                .build();
+
+        assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
+        assertThat(result.getHint()).isSameAs(HINT);
+        assertThat(result.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void buildSetHint_nullValue() {
+        HintRetrieveResult result = new HintRetrieveResult.Builder(
+                HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
+                .setHint(null)
+                .build();
+
+        assertThat(result.getHint()).isNull();
+    }
+
+    @Test
+    public void buildSetAdditionalProperties() {
+        HintRetrieveResult result = new HintRetrieveResult.Builder(
+                HintRetrieveResult.CODE_NO_HINTS_AVAILABLE)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build();
+
+        assertThat(result.getAdditionalProperties()).hasSize(1);
+        assertThat(result.getAdditionalProperties()).containsKey(ADDITIONAL_KEY);
+        assertThat(result.getAdditionalProperties().get(ADDITIONAL_KEY))
+                .isEqualTo(ADDITIONAL_VALUE);
+    }
+
+    @Test
+    public void toProtobuf() {
+        HintRetrieveResult result = new HintRetrieveResult.Builder(
+                HintRetrieveResult.CODE_HINT_SELECTED)
+                .setHint(HINT)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build();
+
+        Protobufs.HintRetrieveResult proto = result.toProtobuf();
+        assertThat(proto.getResultCodeValue()).isEqualTo(ResultCode.HINT_SELECTED_VALUE);
+        assertThat(proto.hasHint());
+        assertThat(proto.containsAdditionalProps(ADDITIONAL_KEY));
+        assertThat(proto.getAdditionalPropsOrThrow(ADDITIONAL_KEY).toByteArray())
+                .isEqualTo(ADDITIONAL_VALUE);
+    }
+
+    @Test
+    public void fromProtobuf() {
+        Protobufs.HintRetrieveResult proto = Protobufs.HintRetrieveResult.newBuilder()
+                .setResultCode(ResultCode.HINT_SELECTED)
+                .setHint(Protobufs.Hint.newBuilder()
+                        .setId(ALICE_ID)
+                        .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf()))
+                .putAdditionalProps(ADDITIONAL_KEY, ByteString.copyFrom(ADDITIONAL_VALUE))
+                .build();
+
+        HintRetrieveResult result = HintRetrieveResult.fromProtobuf(proto);
+        assertThat(result.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
+        assertThat(result.getHint()).isNotNull();
+        assertThat(result.getAdditionalProperties()).hasSize(1);
+        assertThat(result.getAdditionalProperties()).containsKey(ADDITIONAL_KEY);
+        assertThat(result.getAdditionalProperties().get(ADDITIONAL_KEY))
+                .isEqualTo(ADDITIONAL_VALUE);
+    }
+
+    @Test
+    public void toResultIntentData() throws IOException {
+        HintRetrieveResult result = new HintRetrieveResult.Builder(
+                HintRetrieveResult.CODE_HINT_SELECTED)
+                .setHint(HINT)
+                .setAdditionalProperties(ADDITIONAL_PROPS)
+                .build();
+
+        Intent intent = result.toResultDataIntent();
+        assertThat(intent.hasExtra(ProtocolConstants.EXTRA_HINT_RESULT));
+        byte[] data = intent.getByteArrayExtra(ProtocolConstants.EXTRA_HINT_RESULT);
+
+        HintRetrieveResult readResult = HintRetrieveResult.fromProtobufBytes(data);
+        assertThat(readResult.getResultCode()).isEqualTo(HintRetrieveResult.CODE_HINT_SELECTED);
+        assertThat(readResult.getHint()).isNotNull();
+        assertThat(readResult.getAdditionalProperties()).hasSize(1);
+    }
+}
diff --git a/protocol/javatests/org/openyolo/protocol/HintTest.java b/protocol/javatests/org/openyolo/protocol/HintTest.java
new file mode 100644
index 0000000..9cc51cb
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/HintTest.java
@@ -0,0 +1,338 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+import android.net.Uri;
+import android.os.Parcel;
+import java.io.IOException;
+import java.net.IDN;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class HintTest {
+
+    private static final String ALICE_ID = "alice@example.com";
+    private static final String ALICE_NAME = "Alice";
+    private static final String ALICE_DISPLAY_PICTURE_URI_STR = "https://avatars.example.com/alice";
+    private static final Uri ALICE_DISPLAY_PICTURE_URI = Uri.parse(ALICE_DISPLAY_PICTURE_URI_STR);
+    private static final String PASSWORD = "correctH0rseBatterySt4ple";
+    private static final String ID_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
+            + "eyJzdWIiOiJ5b2xvIn0."
+            + "BI1g9ns0shv6PKfwlhfPKwh5XzxQyg_el_35_wZbtsI";
+
+    @Test
+    public void build_minimalData() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL).build();
+        assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
+        assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
+        assertThat(hint.getDisplayName()).isNull();
+        assertThat(hint.getDisplayPictureUri()).isNull();
+        assertThat(hint.getIdToken()).isNull();
+        assertThat(hint.getAdditionalProperties()).isEmpty();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void build_nullId_shouldThrowException() {
+        new Hint.Builder(
+                null,// id
+                AuthenticationMethods.EMAIL)
+                .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void build_emptyId_shouldThrowException() {
+        new Hint.Builder(
+                "", // id
+                AuthenticationMethods.EMAIL)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void build_nullAuthMethod_shouldThrowException() {
+        new Hint.Builder(
+                ALICE_ID,
+                (AuthenticationMethod) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void build_nullAuthMethodStr_shouldThrowException() {
+        new Hint.Builder(
+                ALICE_ID,
+                (String) null)
+                .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void build_emptyAuthMethodStr_shouldThrowException() {
+        new Hint.Builder(
+                ALICE_ID,
+                "")
+                .build();
+    }
+
+    @Test
+    public void builderSetDisplayName() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayName(ALICE_NAME)
+                .build();
+        assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
+    }
+
+    @Test
+    public void builderSetDisplayName_nullValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayName(null)
+                .build();
+
+        assertThat(hint.getDisplayName()).isNull();
+    }
+
+    @Test
+    public void builderSetDisplayName_emptyValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayName("")
+                .build();
+
+        assertThat(hint.getDisplayName()).isNull();
+    }
+
+    @Test
+    public void builderSetDisplayPictureUri() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
+                .build();
+        assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+    }
+
+    @Test
+    public void builderSetDisplayPictureUri_nullValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayPictureUri((Uri) null)
+                .build();
+        assertThat(hint.getDisplayPictureUri()).isNull();
+    }
+
+    @Test(expected=RequireViolation.class)
+    public void builderSetDisplayPictureUri_nonHttp_shouldThrowException() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayPictureUri(Uri.parse("gopher://hello"))
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test
+    public void builderSetDisplayPictureUriStr() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
+                .build();
+        assertThat(hint.getDisplayPictureUri().toString()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
+    }
+
+    @Test
+    public void builderSetDisplayPictureUriStr_nullValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayPictureUri((String) null)
+                .build();
+        assertThat(hint.getDisplayPictureUri()).isNull();
+    }
+
+    @Test
+    public void builderSetDisplayPictureUriStr_emptyValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setDisplayPictureUri("")
+                .build();
+        assertThat(hint.getDisplayPictureUri()).isNull();
+    }
+
+    @Test
+    public void builderSetGeneratedPassword() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setGeneratedPassword(PASSWORD)
+                .build();
+
+        assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
+    }
+
+    @Test
+    public void builderSetGeneratedPassword_nullValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setGeneratedPassword(null)
+                .build();
+
+        assertThat(hint.getGeneratedPassword()).isNull();
+    }
+
+    @Test
+    public void builderSetGeneratedPassword_emptyValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setGeneratedPassword("")
+                .build();
+
+        assertThat(hint.getGeneratedPassword()).isNull();
+    }
+
+    @Test
+    public void builderSetIdToken() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setIdToken(ID_TOKEN)
+                .build();
+
+        assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+    }
+
+    @Test
+    public void builderSetIdToken_nullValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setIdToken(null)
+                .build();
+
+        assertThat(hint.getIdToken()).isNull();
+    }
+
+    @Test
+    public void builderSetIdToken_emptyValue() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setIdToken(null)
+                .build();
+
+        assertThat(hint.getIdToken()).isNull();
+    }
+
+    @Test
+    public void builderSetAdditionalProps() {
+        String additionalKey = "extra";
+        byte[] additionalValue = "value".getBytes();
+
+        Map<String, byte[]> additionalProps = new HashMap<>();
+        additionalProps.put(additionalKey, additionalValue);
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL)
+                .setAdditionalProperties(additionalProps)
+                .build();
+
+        assertThat(hint.getAdditionalProperties()).hasSize(1);
+        assertThat(hint.getAdditionalProperties()).containsKey(additionalKey);
+        assertThat(hint.getAdditionalProperties().get(additionalKey)).isEqualTo(additionalValue);
+    }
+
+    @Test
+    public void toProtobuf() {
+        Hint hint = new Hint.Builder(
+                ALICE_ID,
+                AuthenticationMethods.EMAIL)
+                .setDisplayName(ALICE_NAME)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
+                .setGeneratedPassword(PASSWORD)
+                .setIdToken(ID_TOKEN)
+                .build();
+
+        Protobufs.Hint proto = hint.toProtobuf();
+        assertThat(proto.getId()).isEqualTo(ALICE_ID);
+        assertThat(proto.getAuthMethod().getUri())
+                .isEqualTo(AuthenticationMethods.EMAIL.toString());
+        assertThat(proto.getDisplayName()).isEqualTo(ALICE_NAME);
+        assertThat(proto.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI_STR);
+        assertThat(proto.getGeneratedPassword()).isEqualTo(PASSWORD);
+        assertThat(proto.getIdToken()).isEqualTo(ID_TOKEN);
+    }
+
+    @Test
+    public void fromProtobuf() {
+        Protobufs.Hint proto = Protobufs.Hint.newBuilder()
+                .setId(ALICE_ID)
+                .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
+                .setDisplayName(ALICE_NAME)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
+                .setGeneratedPassword(PASSWORD)
+                .setIdToken(ID_TOKEN)
+                .build();
+
+        Hint hint = Hint.fromProtobuf(proto);
+        assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
+        assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
+        assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
+        assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+        assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
+        assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+    }
+
+    @Test
+    public void fromProtobufBytes() throws IOException {
+        Protobufs.Hint proto = Protobufs.Hint.newBuilder()
+                .setId(ALICE_ID)
+                .setAuthMethod(AuthenticationMethods.EMAIL.toProtobuf())
+                .setDisplayName(ALICE_NAME)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI_STR)
+                .setGeneratedPassword(PASSWORD)
+                .setIdToken(ID_TOKEN)
+                .build();
+
+        Hint hint = Hint.fromProtobufBytes(proto.toByteArray());
+        assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
+        assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
+        assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
+        assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+        assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
+        assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+    }
+
+    @Test
+    public void writeToAndReadFromParcel() {
+        Hint hint = new Hint.Builder(
+                ALICE_ID,
+                AuthenticationMethods.EMAIL)
+                .setDisplayName(ALICE_NAME)
+                .setDisplayPictureUri(ALICE_DISPLAY_PICTURE_URI)
+                .setGeneratedPassword(PASSWORD)
+                .setIdToken(ID_TOKEN)
+                .build();
+
+        Parcel p = Parcel.obtain();
+        try {
+            hint.writeToParcel(p, 0);
+            p.setDataPosition(0);
+            Hint readHint = Hint.CREATOR.createFromParcel(p);
+
+            assertThat(hint.getIdentifier()).isEqualTo(ALICE_ID);
+            assertThat(hint.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.EMAIL);
+            assertThat(hint.getDisplayName()).isEqualTo(ALICE_NAME);
+            assertThat(hint.getDisplayPictureUri()).isEqualTo(ALICE_DISPLAY_PICTURE_URI);
+            assertThat(hint.getGeneratedPassword()).isEqualTo(PASSWORD);
+            assertThat(hint.getIdToken()).isEqualTo(ID_TOKEN);
+        } finally {
+            p.recycle();
+        }
+    }
+
+    @Test
+    public void describeContents() {
+        Hint hint = new Hint.Builder(ALICE_ID, AuthenticationMethods.EMAIL).build();
+        assertThat(hint.describeContents()).isEqualTo(0);
+    }
+}
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index 8a6e98f..dbc5d93 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -69,4 +69,16 @@ message HintRetrieveRequest {
 message HintRetrieveResult {
-    Credential credential = 1;
-    map<string, bytes> additionalProps = 2;
+    enum ResultCode {
+        UNSPECIFIED = 0;
+        BAD_REQUEST = 1;
+        HINT_SELECTED = 2;
+        NO_HINTS_AVAILABLE = 3;
+        USER_REQUESTS_MANUAL_AUTH = 4;
+        USER_CANCELED = 5;
+    }
+
+    // required
+    ResultCode resultCode = 1;
+
+    Hint hint = 2;
+    map<string, bytes> additionalProps = 3;
 }
@@ -90,4 +102,14 @@ message Credential {
 
-message CredentialList {
-    repeated Credential credentials = 1;
+message Hint {
+    // required
+    string id = 1;
+
+    // required
+    AuthenticationMethod authMethod = 2;
+
+    string displayName = 3;
+    string displayPictureUri = 4;
+    string generatedPassword = 5;
+    string idToken = 6;
+    map<string, bytes> additionalProps = 7;
 }
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 64034b6..9a490f9 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -36,2 +36,3 @@ import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.Hint;
 import org.openyolo.protocol.PasswordSpecification;
@@ -40,220 +41,231 @@ import org.valid4j.errors.RequireViolation;
 public final class CredentialView extends LinearLayout {
 
     private static final String TAG = "CredentialView";
 
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_email_provider_button)
     ImageButton mEmailProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
     /**
      * Simple constructor to use when creating a credential view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mEmailProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void setEmailAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
         Glide.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
+    /**
+     * Populates the fragment's fields from a given OpenYOLO hint.
+     */
+    public void setFieldsFromHint(Hint hint) {
+        copyIfNotNull(hint.getIdentifier(), mIdField);
+        copyIfNotNull(hint.getGeneratedPassword(), mPasswordField);
+        copyIfNotNull(hint.getDisplayName(), mDisplayNameField);
+        copyIfNotNull(hint.getDisplayPictureUri(), mProfilePictureField);
+        copyIfNotNull(hint.getAuthenticationMethod(), mAuthenticationMethodField);
+    }
+
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authMethodStr = mAuthenticationMethodField.getText().toString();
         AuthenticationMethod authMethod;
         try {
             authMethod = new AuthenticationMethod(authMethodStr);
         } catch (RequireViolation ex) {
             Log.w(TAG, "User entered authentication method " + authMethodStr + " is invalid", ex);
             return null;
         }
 
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethod,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         credentialBuilder.setPassword(mPasswordField.getText().toString());
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 6bcb1ca..f4a755a 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -16,5 +16,2 @@ package org.openyolo.testapp;
 
-import static android.app.Activity.RESULT_CANCELED;
-import static android.app.Activity.RESULT_OK;
-
 import android.content.Intent;
@@ -33,4 +30,5 @@ import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.Hint;
+import org.openyolo.protocol.HintRetrieveRequest;
+import org.openyolo.protocol.HintRetrieveResult;
 import org.valid4j.errors.RequireViolation;
@@ -38,105 +36,119 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_method_text_input)
     EditText mAuthenticationMethodInput;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
-        if (resultCode == RESULT_OK) {
-            Credential credential = mApi.getHintRetrieveResult(data);
-            if (credential == null) {
-                showSnackbar(R.string.no_credential_returned);
-            } else {
-                mCredentialView.setFieldsFromCredential(credential);
-            }
-        } else if (resultCode == RESULT_CANCELED) {
-            showSnackbar(R.string.hint_cancelled);
-        } else {
-            showSnackbar(R.string.unknown_response);
+        // CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
+        HintRetrieveResult result = mApi.getHintRetrieveResult(data);
+        Hint hint = result.getHint();
+        if (hint != null) {
+            mCredentialView.setFieldsFromHint(hint);
+            return;
+        }
+
+        int errorStringResId;
+        switch (result.getResultCode()) {
+            case HintRetrieveResult.CODE_BAD_REQUEST:
+                errorStringResId = R.string.hint_bad_request;
+                break;
+            case HintRetrieveResult.CODE_NO_HINTS_AVAILABLE:
+                errorStringResId = R.string.hint_none_available;
+                break;
+            case HintRetrieveResult.CODE_USER_CANCELED:
+                errorStringResId = R.string.hint_user_canceled;
+                break;
+            case HintRetrieveResult.CODE_USER_REQUESTS_MANUAL_AUTH:
+                errorStringResId = R.string.hint_manual_auth;
+                break;
+            default:
+                errorStringResId = R.string.hint_unknown_response;
         }
+        showSnackbar(errorStringResId);
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         String authMethodStr = mAuthenticationMethodInput.getText().toString();
         AuthenticationMethod authMethod;
         try {
             authMethod = new AuthenticationMethod(authMethodStr);
         } catch (RequireViolation ex) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
 
-        HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethod);
+        HintRetrieveRequest.Builder requestBuilder = new HintRetrieveRequest.Builder(authMethod);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void onEmailAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 0a5d1ee..9ffab9a 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,59 +1,61 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
     <string name="no_credentials">No credentials available</string>
     <string name="credential_retrieve_user_rejected">Credential retrieve canceled by user</string>
     <string name="credential_retrieve_provider_rejected">Credential retrieve rejected by provider</string>
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
-    <string name="hint_cancelled">Hint retrieve cancelled</string>
+    <string name="hint_bad_request">Bad hint request</string>
+    <string name="hint_none_available">No hints available</string>
+    <string name="hint_user_canceled">User canceled hint request</string>
+    <string name="hint_manual_auth">User requests manual auth</string>
+    <string name="hint_unknown_response">Unknown hint response</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
-    <string name="no_credential_returned">No credential returned</string>
-
 </resources>

commit 2c5082989ca2c336e2209b1426519b780269c112
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu Apr 27 20:06:38 2017 -0700

    Migrate credential retrieval code and demos to match spec

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 54b89d1..f6ce461 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -19,2 +19,3 @@ import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_HINT_REQUEST;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_RETRIEVE_RESULT;
 import static org.openyolo.protocol.ProtocolConstants.HINT_CREDENTIAL_ACTION;
@@ -42,2 +43,4 @@ import org.openyolo.api.ui.ProviderPickerActivity;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
 import org.openyolo.protocol.HintRequest;
@@ -45,4 +48,3 @@ import org.openyolo.protocol.Protobufs;
 import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
-import org.openyolo.protocol.RetrieveRequest;
-import org.openyolo.protocol.RetrieveResult;
+import org.openyolo.protocol.RetrieveBbqResponse;
 import org.openyolo.protocol.internal.IntentUtil;
@@ -50,317 +52,353 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
-            final RetrieveRequest request,
+            final CredentialRetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
                 findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedCredential = credentialToSave.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
                     encodedCredential);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
                     encodedCredential));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
             byte[] saveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
         saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
         return saveIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
-    @Nullable
-    public Credential getCredentialFromActivityResult(@Nullable Intent resultData) {
+    @NonNull
+    public CredentialRetrieveResult getCredentialRetrieveResult(
+            @Nullable Intent resultData) {
         if (resultData == null) {
-            Log.i(LOG_TAG, "resultData is null, exiting (returning null)");
-            return null;
+            Log.i(LOG_TAG, "resultData is null, returning default response");
+            return createDefaultCredentialRetrieveResult();
         }
 
-        if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
-            Log.i(LOG_TAG, "credential data missing from response");
-            return null;
+        if (!resultData.hasExtra(EXTRA_RETRIEVE_RESULT)) {
+            Log.i(LOG_TAG, "retrieve result missing from response, returning default response");
+            return createDefaultCredentialRetrieveResult();
         }
 
-        byte[] credentialBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
-        if (credentialBytes == null) {
-            Log.i(LOG_TAG, "No credential found in response");
-            return null;
+        byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_RETRIEVE_RESULT);
+        if (resultBytes == null) {
+            Log.i(LOG_TAG, "No retrieve result found in result data, returning default response");
+            return createDefaultCredentialRetrieveResult();
         }
 
-        Protobufs.Credential credentialProto;
         try {
-            credentialProto = Protobufs.Credential.parseFrom(credentialBytes);
+            return CredentialRetrieveResult.fromProtobufBytes(resultBytes);
         } catch (IOException ex) {
-            Log.e(LOG_TAG, "failed to decode credential from response data");
-            return null;
+            Log.e(LOG_TAG, "validation of result proto failed, returning default response", ex);
+            return createDefaultCredentialRetrieveResult();
+        }
+    }
+
+    /**
+     * Extracts the result of a hint retrieve request from the intent data returned by a provider.
+     */
+    @Nullable
+    public Credential getHintRetrieveResult(Intent resultData) {
+        // TODO: this has yet to be updated to the new hint retrieve result format and distinct
+        // hint result object type
+
+        if (resultData == null) {
+            Log.i(LOG_TAG, "resultData is null, returning default response");
+            return createDefaultHintRetrieveResult();
+        }
+
+        if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
+            Log.i(LOG_TAG, "hint result missing from response, returning default response");
+            return createDefaultHintRetrieveResult();
+        }
+
+        byte[] resultBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
+        if (resultBytes == null) {
+            Log.i(LOG_TAG, "No hint result found in result data, returning default response");
+            return createDefaultHintRetrieveResult();
         }
 
         try {
-            return new Credential.Builder(credentialProto).build();
-        } catch (IllegalArgumentException ex) {
-            Log.e(LOG_TAG, "validation of received credential failed", ex);
-            return null;
+            return Credential.fromProtoBytes(resultBytes);
+        } catch (IOException ex) {
+            Log.e(LOG_TAG, "hint result is malformed, returning default response");
+            return createDefaultHintRetrieveResult();
         }
     }
 
+    @NonNull
+    private static CredentialRetrieveResult createDefaultCredentialRetrieveResult() {
+        return new CredentialRetrieveResult.Builder(CredentialRetrieveResult.RESULT_UNKNOWN)
+                .build();
+    }
+
+    @Nullable
+    private static Credential createDefaultHintRetrieveResult() {
+        return null;
+    }
+
     private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveBbqResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
-                    new RetrieveResult.Builder()
+                    new RetrieveBbqResponse.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/RetrieveCallback.java b/api/java/org/openyolo/api/RetrieveCallback.java
index 1785b9d..b4fc326 100644
--- a/api/java/org/openyolo/api/RetrieveCallback.java
+++ b/api/java/org/openyolo/api/RetrieveCallback.java
@@ -16,7 +16,7 @@ package org.openyolo.api;
 
-import org.openyolo.protocol.RetrieveResult;
+import org.openyolo.protocol.RetrieveBbqResponse;
 
 /**
  * Asyncronous callback type for credential retrieval.
  */
-public interface RetrieveCallback extends ResultCallback<RetrieveResult, Throwable> {}
+public interface RetrieveCallback extends ResultCallback<RetrieveBbqResponse, Throwable> {}
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 1868c30..f4971b3 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -19,4 +19,2 @@ package org.openyolo.api;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
 import static junit.framework.TestCase.assertNotNull;
@@ -27,3 +25,2 @@ import static org.mockito.Mockito.when;
 import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
-import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
 
@@ -43,5 +40,6 @@ import org.mockito.MockitoAnnotations;
 import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.ProtocolConstants;
 import org.robolectric.RobolectricTestRunner;
@@ -50,289 +48,302 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         credentialClient = new CredentialClient(mockContext);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders("com.example.superpassword", "com.example.locker");
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
-    public void getCredentialFromActivityResult_noExtras() throws Exception {
+    public void testGetCredentialRetrieveResult() throws Exception {
         Intent intent = new Intent();
-        Credential result = credentialClient.getCredentialFromActivityResult(intent);
-        assertNull(result);
+        intent.putExtra(ProtocolConstants.EXTRA_RETRIEVE_RESULT,
+                new CredentialRetrieveResult.Builder(CredentialRetrieveResult.RESULT_SUCCESS)
+                        .setCredential(testCredential)
+                        .build()
+                        .toProtobuf()
+                        .toByteArray());
+
+        CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
+        assertThat(result).isNotNull();
+        assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.RESULT_SUCCESS);
+
+        assertThat(result.getCredential()).isNotNull();
+        assertThat(result.getCredential().getIdentifier())
+                .isEqualTo(testCredential.getIdentifier());
+
+        assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     @Test
-    public void getCredentialFromActivityResult_withExtras() throws Exception {
+    public void testGetCredentialRetrieveResult_noExtra() throws Exception {
         Intent intent = new Intent();
-        byte[] array = testCredential.toProtobuf().toByteArray();
-        intent.putExtra(EXTRA_CREDENTIAL, array);
-        Credential result = credentialClient.getCredentialFromActivityResult(intent);
-        assertEquals(result.getIdentifier(), "alice@example.com");
-        assertEquals(result.getAuthenticationMethod(), AuthenticationMethods.EMAIL);
-        assertEquals(result.getAuthenticationDomain(), AUTH_DOMAIN);
-    }
-
-    private ResolveInfo createResolveInfo(String packageName, String name) {
-        ResolveInfo resolveInfo = new ResolveInfo();
-        ActivityInfo activityInfo = new ActivityInfo();
-        activityInfo.packageName = packageName;
-        activityInfo.name =  name;
-        resolveInfo.activityInfo = activityInfo;
-
-        return resolveInfo;
+        CredentialRetrieveResult result = credentialClient.getCredentialRetrieveResult(intent);
+        assertThat(result).isNotNull();
+        assertThat(result.getResultCode()).isEqualTo(CredentialRetrieveResult.RESULT_UNKNOWN);
+        assertThat(result.getCredential()).isNull();
+        assertThat(result.getAdditionalProps()).isEmpty();
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
-}
\ No newline at end of file
+
+    private ResolveInfo createResolveInfo(String packageName, String name) {
+        ResolveInfo resolveInfo = new ResolveInfo();
+        ActivityInfo activityInfo = new ActivityInfo();
+        activityInfo.packageName = packageName;
+        activityInfo.name =  name;
+        resolveInfo.activityInfo = activityInfo;
+
+        return resolveInfo;
+    }
+}
diff --git a/bbq/proto/bbq.proto b/bbq/proto/bbq.proto
index d1763f7..bda2086 100644
--- a/bbq/proto/bbq.proto
+++ b/bbq/proto/bbq.proto
@@ -54,13 +54,13 @@ message BroadcastQueryResponse {
 message ClientVersion {
     // required
     string vendor = 1;
 
     // required
-    uint32 major = 3;
+    uint32 major = 2;
 
     // required
-    uint32 minor = 4;
+    uint32 minor = 3;
 
     // required
-    uint32 patch = 5;
+    uint32 patch = 4;
 }
\ No newline at end of file
diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
index 5abd2cc..d52c6c2 100644
--- a/demoproviders/barbican/AndroidManifest.xml
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -1,148 +1,153 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="org.openyolo.demoprovider.barbican">
 
     <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name_short"
         android:supportsRtl="false"
         android:theme="@style/AppTheme"
         android:name=".Application">
 
         <activity
             android:name=".LaunchActivity"
             android:label="@string/app_name_short"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateHidden"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data
                     android:host="barbican.openyolo.org"
                     android:scheme="https" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".WelcomeActivity"
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".UnlockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".LockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="false" />
 
         <activity
             android:name=".CredentialListActivity"
             android:label="Stored Credentials"
             android:theme="@style/AppTheme"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity
             android:name=".CreateCredentialActivity"
             android:theme="@style/AppTheme"
             android:label="@string/create_credential_activity_label"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity android:name=".provider.RetrieveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
-            android:excludeFromRecents="true" />
+            android:excludeFromRecents="true">
+            <intent-filter>
+                <action android:name="org.openyolo.credential.retrieve"/>
+                <category android:name="org.openyolo" />
+            </intent-filter>
+        </activity>
 
         <activity android:name=".provider.SaveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.save"/>
                 <category android:name="org.openyolo" />
                 <!--
                 as this app only supports saving email based credentials, this is
                 declared using a data filter.
                 -->
                 <data
                     android:scheme="openyolo"
                     android:host="email" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".provider.HintActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.hint"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialConfirmationActivity"
                   android:theme="@style/AppTheme.Dialog"
                   android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveAfterUnlockActivity"
                   android:theme="@style/AppTheme.NoUi"
                   android:excludeFromRecents="true" />
 
         <activity
             android:name=".provider.AutoSignInActivity"
             android:theme="@style/AutoSignInTheme"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".provider.CredentialPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".NeverSaveListActivity"
             android:theme="@style/AppTheme"/>
             android:exported="false" />
 
         <service
             android:name=".storage.CredentialStorageService"
             android:label="@string/credential_storage_service_label"
             android:enabled="true"
             android:exported="false"
             android:permission="org.openyolo.demoprovider.STORAGE"/>
 
         <receiver
             android:name=".provider.CredentialQueryReceiver"
             android:exported="true"
             android:enabled="true"
             tools:ignore="ExportedReceiver">
             <intent-filter>
                 <action android:name="org.openyolo.credential" />
                 <category android:name="com.google.bbq.QUERY" />
             </intent-filter>
         </receiver>
     </application>
 </manifest>
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
index 38e201e..ae6fe63 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
@@ -29,92 +29,102 @@ import java.io.IOException;
 import org.openyolo.demoprovider.barbican.R;
-import org.openyolo.protocol.Protobufs.Credential;
-import org.openyolo.spi.RetrieveIntentResultUtil;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.Protobufs;
 
 /**
  * Displays a brief, "snackbar"-like notification to the user indicating that a credential
  * is being returned to a requesting app.
  */
 public class AutoSignInActivity extends AppCompatActivity {
 
     private static final long DISPLAY_TIME_MS = 2000;
 
     private static final String EXTRA_CREDENTIAL = "credential";
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.credential_primary)
     TextView mCredentialPrimary;
 
     @BindView(R.id.credential_secondary)
     TextView mCredentialSecondary;
 
     /**
      * Creates an intent to display this activity with the specified credential.
      */
     public static Intent createIntent(Context context, Credential credential) {
+        return createIntent(context, credential.toProtobuf());
+    }
+
+    /**
+     * Creates an intent to display this activity with the specified credential, in protobuf form.
+     */
+    public static Intent createIntent(Context context, Protobufs.Credential credential) {
         Intent intent = new Intent(context, AutoSignInActivity.class);
         intent.putExtra(EXTRA_CREDENTIAL, credential.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.auto_sign_in_layout);
         positionWindow();
         ButterKnife.bind(this);
 
         Credential credential = getCredential();
         if (credential.getDisplayName() != null) {
             mCredentialPrimary.setText(credential.getDisplayName());
-            mCredentialSecondary.setText(credential.getId());
+            mCredentialSecondary.setText(credential.getIdentifier());
         } else {
-            mCredentialPrimary.setText(credential.getId());
+            mCredentialPrimary.setText(credential.getIdentifier());
             mCredentialSecondary.setVisibility(View.GONE);
         }
 
         mRootView.postDelayed(new ReturnCredentialTask(), DISPLAY_TIME_MS);
     }
 
     /**
      * Ensures the activity's window fills the full "visible" section of the screen, excluding
      * the status bar. This is a workaround for a size bug when using
      * {@code windowMinWidthMajor / windowMinWidthMinor} that can leave the windows a few pixels
      * off the correct size.
      */
     private void positionWindow() {
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = getResources().getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
     }
 
-
     private Credential getCredential() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
-            return Credential.parseFrom(credentialBytes);
+            return Credential.fromProtoBytes(credentialBytes);
         } catch (IOException e) {
             throw new IllegalStateException("Unable to decode credential");
         }
     }
 
     private class ReturnCredentialTask implements Runnable {
         @Override
         public void run() {
-            Intent responseData = RetrieveIntentResultUtil.createResponseData(getCredential());
-            setResult(RESULT_OK, responseData);
+            CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
+                    CredentialRetrieveResult.RESULT_SUCCESS)
+                    .setCredential(getCredential())
+                    .build();
+            setResult(result.getResultCode(), result.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index 42db1ec..f858788 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -41,150 +41,158 @@ import org.openyolo.demoprovider.barbican.R;
 import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.CredentialRetrieveResult;
 import org.openyolo.protocol.Protobufs.Credential;
 import org.openyolo.protocol.Protobufs.CredentialList;
-import org.openyolo.spi.RetrieveIntentResultUtil;
 
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(Context context, List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
         intent.putExtra(EXTRA_CREDENTIALS,
                 CredentialList.newBuilder()
                         .addAllCredentials(credentials)
                         .build()
                         .toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
-            setResult(RESULT_CANCELED);
-            finish();
+            setResultAndFinish(
+                    new CredentialRetrieveResult.Builder(
+                            CredentialRetrieveResult.RESULT_REJECTED_BY_USER)
+                            .build());
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
+    private void setResultAndFinish(CredentialRetrieveResult result) {
+        setResult(result.getResultCode(), result.toResultDataIntent());
+        finish();
+    }
+
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Credential> credentials =
                     new ArrayList<>(CredentialList.parseFrom(credentialBytes).getCredentialsList());
             Collections.sort(credentials, CredentialQualityScore.PROTO_QUALITY_SORT);
             return credentials;
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new CredentialViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(CredentialViewHolder holder, int position) {
             holder.bind(mCredentials.get(position));
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
     }
 
     private final class CredentialViewHolder extends RecyclerView.ViewHolder {
 
         private ImageView mProfileIcon;
         private TextView mPrimaryLabel;
         private TextView mSecondaryLabel;
 
         CredentialViewHolder(View itemView) {
             super(itemView);
 
             mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
             mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
             mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
         }
 
         void bind(final Credential credential) {
 
             int iconId;
             if (AuthenticationMethods.EMAIL.toString().equals(credential.getAuthMethod())) {
                 iconId = R.drawable.email;
             } else if (AuthenticationMethods.PHONE.toString().equals(credential.getAuthMethod())) {
                 iconId = R.drawable.phone;
             } else {
                 iconId = R.drawable.person;
             }
 
             if (credential.getDisplayPictureUri() != null) {
                 Uri displayPictureUri = Uri.parse(credential.getDisplayPictureUri());
                 Glide.with(CredentialPickerActivity.this)
                         .load(displayPictureUri)
                         .fitCenter()
                         .fallback(iconId)
                         .into(mProfileIcon);
             } else {
                 mProfileIcon.setImageResource(iconId);
             }
 
             if (credential.getDisplayName() != null) {
                 mPrimaryLabel.setText(credential.getDisplayName());
                 mSecondaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.VISIBLE);
             } else {
                 mPrimaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.GONE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
-                    Intent responseData =
-                            RetrieveIntentResultUtil.createResponseData(credential);
-                    setResult(RESULT_OK, responseData);
-                    finish();
+                    setResultAndFinish(
+                            new CredentialRetrieveResult.Builder(
+                                    CredentialRetrieveResult.RESULT_SUCCESS)
+                                    .setCredentialFromProto(credential)
+                                    .build());
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
index 7170002..3be6944 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
@@ -22,3 +22,3 @@ import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import com.google.protobuf.ByteString;
+
 import java.io.IOException;
@@ -28,4 +28,4 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorage;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
-import org.openyolo.protocol.RetrieveRequest;
 import org.openyolo.protocol.internal.IntentUtil;
@@ -34,65 +34,66 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Implements the OpenYOLO credential query receiver. This receiver is able to determine whether
  * a credential exists for the claimed set of authentication domains without unlocking the
  * password store.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull final Context context,
             @NonNull final BroadcastQuery query,
-            @NonNull RetrieveRequest request,
+            @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // NOTE: in a more complete implementation, this is where we would expand the set of
         // authentication domains listed in requestorDomains to all equivalent authentication
         // domains (such as affiliated apps and sites). This potentially larger list would then be
         // matched against the requested set of domains.
 
         Log.i(LOG_TAG, "Processing query for " + query.getRequestingApp());
 
         CredentialStorage storage;
         try {
             storage = new CredentialStorage(context);
         }  catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to open credential storage", ex);
             responseSender.sendResponse(query, null);
             return;
         }
 
         boolean credentialsFound = false;
         byte[] responseBytes = null;
 
         Iterator<AuthenticationDomain> authDomainIter = requestorDomains.iterator();
         while (!credentialsFound && authDomainIter.hasNext()) {
             credentialsFound = storage.hasCredentialFor(authDomainIter.next().toString());
         }
 
         Log.d(LOG_TAG, "Credentials found for "
                 + query.getRequestingApp() + ": "
                 + credentialsFound);
 
         if (credentialsFound) {
-            Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context);
-            CredentialRetrieveBbqResponse response = CredentialRetrieveBbqResponse.newBuilder()
-                    .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
-                    .build();
+            Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context, request);
+            CredentialRetrieveBbqResponse response =
+                    CredentialRetrieveBbqResponse.newBuilder()
+                            .setRetrieveIntent(IntentUtil.toByteString(retrieveIntent))
+                            .build();
             responseBytes = response.toByteArray();
         }
 
         responseSender.sendResponse(query, responseBytes);
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index 6f100c1..e4ae184 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -27,89 +27,112 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
 import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.ProtocolConstants;
 
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
 public class RetrieveCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "RetrieveCredential";
     private CredentialStorageClient mClient;
+    private CredentialRetrieveRequest mRequest;
 
     /**
      * Creates the intent to handle releasing a credential to the calling app.
      */
-    public static Intent createIntent(Context context) {
-        return new Intent(context, RetrieveCredentialActivity.class);
+    public static Intent createIntent(Context context, CredentialRetrieveRequest request) {
+        // the format of this intent needs to be compatible with a "direct invocation" intent,
+        // based on the spec (Section 4.3.1).
+        Intent intent = new Intent(context, RetrieveCredentialActivity.class);
+        intent.setAction(ProtocolConstants.RETRIEVE_CREDENTIAL_ACTION);
+        intent.addCategory(ProtocolConstants.OPENYOLO_CATEGORY);
+        intent.putExtra(
+                ProtocolConstants.EXTRA_RETRIEVE_REQUEST,
+                request.toProtocolBuffer().toByteArray());
+        return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
-            setResult(RESULT_CANCELED);
-            finish();
+            setResultAndFinish(CredentialRetrieveResult.REJECTED_BY_PROVIDER);
+            return;
+        }
+
+        try {
+            mRequest = CredentialRetrieveRequest.fromRequestIntent(getIntent());
+        } catch (IOException e) {
+            setResultAndFinish(CredentialRetrieveResult.REJECTED_BY_PROVIDER);
         }
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
         if (!client.isUnlocked()) {
             Intent retrieveAfterUnlockIntent =
-                    RetrieveCredentialActivity.createIntent(this);
+                    RetrieveCredentialActivity.createIntent(this, mRequest);
             retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
             Intent unlockIntent =
                     UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
             unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(unlockIntent);
             finish();
         } else {
             // TODO: we actually need the full set of requested domains from the original request,
             // not just those based on the package name.
 
             List<AuthenticationDomain> authDomains =
                     AuthenticationDomain.listForPackage(this, getCallingPackage());
 
             List<Credential> credentials;
             try {
                 credentials = client.listCredentials(authDomains);
             } catch (IOException ex) {
                 Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
                 finish();
                 return;
             }
 
             if (credentials.size() == 1) {
                 Intent autoSignInIntent =
                         AutoSignInActivity.createIntent(this, credentials.get(0));
                 autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(autoSignInIntent);
             } else {
                 Intent pickerIntent =
                         CredentialPickerActivity.createIntent(this, credentials);
                 pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                 startActivity(pickerIntent);
             }
             finish();
         }
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
+
+    private void setResultAndFinish(CredentialRetrieveResult result) {
+        setResult(result.getResultCode(), result.toResultDataIntent());
+        finish();
+    }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
index d9a7d3a..9e1377a 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -26,4 +26,4 @@ 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.RetrieveRequest;
 import org.openyolo.protocol.internal.IntentUtil;
@@ -32,46 +32,46 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
  * we respond to all requests with an intent as long as the
  * {@link org.openyolo.protocol.AuthenticationMethods#EMAIL email} authentication method is
  * supported.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
-            @NonNull RetrieveRequest request,
+            @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         Log.i(LOG_TAG, "Processing retrieve query from claimed caller: "
                 + query.getRequestingApp());
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // Ensure the caller supports the email authentication method
         if (!request.getAuthenticationMethods().contains(AuthenticationMethods.EMAIL)) {
             responseSender.sendResponse(query,  null /* response */);
             return;
         }
 
         Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
         CredentialRetrieveBbqResponse response = CredentialRetrieveBbqResponse.newBuilder()
                 .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
                 .build();
 
         Log.i(LOG_TAG, "Accepting credential request for claimed caller: "
                 + query.getRequestingApp());
         responseSender.sendResponse(query, response.toByteArray());
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
index fc5906d..bf0b1ae 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -29,71 +29,75 @@ import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
-import org.openyolo.spi.RetrieveIntentResultUtil;
+import org.openyolo.protocol.CredentialRetrieveResult;
 
 /**
  * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
  */
 public class RetrieveActivity extends AppCompatActivity {
 
     private static final int PIN_SIZE = 6;
 
     private static final String LOG_TAG = "TrapdoorRetrieve";
 
     private AuthenticationDomain mDomain;
 
     /**
      * Creates an Intent to start this activity.
      */
     public static Intent createIntent(Context context) {
         return new Intent(context, RetrieveActivity.class);
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
             setResult(RESULT_CANCELED);
             finish();
             return;
         }
 
         mDomain = new TreeSet<>(
                 AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
         Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
 
         setContentView(R.layout.dialog_layout);
         ((PinEntryView)findViewById(R.id.pin_entry_field))
                 .addTextChangedListener(new PinChangedWatcher());
     }
 
     private class PinChangedWatcher implements TextWatcher {
         @Override
         public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
 
         @Override
         public void onTextChanged(CharSequence seq, int start, int before, int count) {}
 
         @Override
         public void afterTextChanged(Editable pin) {
             if (pin.length() != PIN_SIZE) {
                 return;
             }
             String userName = UserDataStore.getUserName(RetrieveActivity.this);
             String password = PasswordGenerator.generatePassword(
                     userName,
                     pin.toString(),
                     mDomain.toString());
 
             Credential credential = new Credential.Builder(
                     UserDataStore.getUserName(RetrieveActivity.this),
                     AuthenticationMethods.EMAIL,
                     mDomain)
                     .setPassword(password)
                     .build();
 
-            setResult(RESULT_OK, RetrieveIntentResultUtil.createResponseData(credential));
+            CredentialRetrieveResult result = new CredentialRetrieveResult.Builder(
+                    CredentialRetrieveResult.RESULT_SUCCESS)
+                    .setCredential(credential)
+                    .build();
+            setResult(result.getResultCode(), result.toResultDataIntent());
             finish();
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/RetrieveRequest.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
similarity index 75%
rename from protocol/java/org/openyolo/protocol/RetrieveRequest.java
rename to protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
index 6457d57..c999ab2 100644
--- a/protocol/java/org/openyolo/protocol/RetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveRequest.java
@@ -28,2 +28,3 @@ import static org.valid4j.Validation.validate;
 
+import android.content.Intent;
 import android.os.Parcel;
@@ -45,248 +46,290 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
-public class RetrieveRequest implements Parcelable {
+public class CredentialRetrieveRequest implements Parcelable {
 
     /**
-     * Parcelable reader for {@link RetrieveRequest} instances.
+     * Parcelable reader for {@link CredentialRetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
-    public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
+    public static final Creator<CredentialRetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
+    /**
+     * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
+     */
     @NonNull
-    private final Set<AuthenticationMethod> mAuthMethods;
+    public static CredentialRetrieveRequest forAuthenticationMethods(
+            @NonNull Set<AuthenticationMethod> authenticationMethods) {
+        return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
+    }
 
+    /**
+     * Creates a {@link CredentialRetrieveRequest} from the given authentication methods.
+     */
     @NonNull
-    private final Map<String, byte[]> mAdditionalProps;
+    public static CredentialRetrieveRequest forAuthenticationMethods(
+            @NonNull AuthenticationMethod... authenticationMethods) {
+        return new CredentialRetrieveRequest.Builder(authenticationMethods).build();
+    }
 
-    private RetrieveRequest(
-            @NonNull Set<AuthenticationMethod> authMethods,
-            @NonNull Map<String, byte[]> additionalParams) {
-        mAuthMethods = authMethods;
-        mAdditionalProps = additionalParams;
+    /**
+     * Creats a {@link CredentialRetrieveRequest} from its protocol buffer equivalent.
+     */
+    @NonNull
+    public static CredentialRetrieveRequest fromProtobuf(
+            @NonNull Protobufs.CredentialRetrieveRequest proto) {
+        return new CredentialRetrieveRequest.Builder(proto).build();
     }
 
     /**
-     * Creates a {@link RetrieveRequest} from the given authentication methods.
+     * Creates a {@link CredentialRetrieveRequest} from its protocol buffer byte array equivalent.
+     * @throws IOException if the request could not be parsed and validated.
      */
-    public static RetrieveRequest forAuthenticationMethods(
-            @NonNull Set<AuthenticationMethod> authenticationMethods) {
-        return new RetrieveRequest.Builder(authenticationMethods).build();
+    @NonNull
+    public static CredentialRetrieveRequest fromProtobufBytes(
+            @NonNull byte[] protoBytes)
+            throws IOException {
+        return fromProtobuf(Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes));
     }
 
     /**
-     * Creates a {@link RetrieveRequest} from the given authentication methods.
+     * Extracts a {@link CredentialRetrieveRequest} from the intent extra that is used to carry
+     * a request from the client to the provider activity.
+     *
+     * @throws IOException if the intent does not contain a retrieve request, or the contained
+     *     request could not be parsed and validated.
      */
-    public static RetrieveRequest forAuthenticationMethods(
-            @NonNull AuthenticationMethod... authenticationMethods) {
-        return new RetrieveRequest.Builder(authenticationMethods).build();
+    @NonNull
+    public static CredentialRetrieveRequest fromRequestIntent(
+            @NonNull Intent requestIntent)
+            throws IOException {
+        if (!requestIntent.hasExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST)) {
+            throw new IOException("credential retrieve request missing in intent data");
+        }
+
+        return fromProtobufBytes(
+                requestIntent.getByteArrayExtra(ProtocolConstants.EXTRA_RETRIEVE_REQUEST));
+    }
+
+    @NonNull
+    private final Set<AuthenticationMethod> mAuthMethods;
+
+    @NonNull
+    private final Map<String, byte[]> mAdditionalProps;
+
+    private CredentialRetrieveRequest(
+            @NonNull Set<AuthenticationMethod> authMethods,
+            @NonNull Map<String, byte[]> additionalParams) {
+        mAuthMethods = authMethods;
+        mAdditionalProps = additionalParams;
     }
 
     /**
      * The set of authentication methods that the requestor supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         if (mAdditionalProps.containsKey(key)) {
             return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         return mAdditionalProps.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
-     * Creates {@link RetrieveRequest} instances.
+     * Creates {@link CredentialRetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
         public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
             validate(requestProto, notNullValue(), IllegalArgumentException.class);
 
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
-         * @see RetrieveRequest#getAdditionalPropertyAsString(String)
+         * @see CredentialRetrieveRequest#getAdditionalPropertyAsString(String)
          */
         public Builder addAdditionalProperty(
                 @NonNull String name,
                 @NonNull String value) {
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalProperty(String name, byte[] value) {
             validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
-         * Creates a {@link RetrieveRequest} using the properties set on the builder.
+         * Creates a {@link CredentialRetrieveRequest} using the properties set on the builder.
          */
         @NonNull
-        public RetrieveRequest build() {
-            return new RetrieveRequest(
+        public CredentialRetrieveRequest build() {
+            return new CredentialRetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
-    private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
+    private static final class RetrieveRequestCreator
+            implements Creator<CredentialRetrieveRequest> {
 
         @Override
-        public RetrieveRequest createFromParcel(Parcel in) {
+        public CredentialRetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
-                return new RetrieveRequest.Builder(
+                return new CredentialRetrieveRequest.Builder(
                         Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
-        public RetrieveRequest[] newArray(int size) {
-            return new RetrieveRequest[size];
+        public CredentialRetrieveRequest[] newArray(int size) {
+            return new CredentialRetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
new file mode 100644
index 0000000..7a259fd
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/CredentialRetrieveResult.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.valid4j.Assertive.require;
+
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+
+/**
+ * Result data which is sent in response to a credential retrieve request. Contains a result code,
+ * indicating whether the request was successful or not, an optional returned credential, and
+ * an optional set of additional, non-standard result properties.
+ */
+public final class CredentialRetrieveResult {
+
+    /**
+     * Indicates that the provider returned a response that could not be interpreted.
+     */
+    public static final int RESULT_UNKNOWN =
+            Protobufs.CredentialRetrieveResult.ResultCode.UNSPECIFIED_VALUE;
+
+    /**
+     * Indicates that the credential request completed without any issues.
+     */
+    public static final int RESULT_SUCCESS =
+            Protobufs.CredentialRetrieveResult.ResultCode.SUCCESS_VALUE;
+
+    /**
+     * Indicates that the credential request was denied by the provider.
+     */
+    public static final int RESULT_REJECTED_BY_PROVIDER =
+            Protobufs.CredentialRetrieveResult.ResultCode.REJECTED_BY_PROVIDER_VALUE;
+
+    /**
+     * Indicates that the credential request was defined by the user.
+     */
+    public static final int RESULT_REJECTED_BY_USER =
+            Protobufs.CredentialRetrieveResult.ResultCode.REJECTED_BY_USER_VALUE;
+
+    /**
+     * Indicates that the credential request was rejected by the provider.
+     */
+    public static final CredentialRetrieveResult REJECTED_BY_PROVIDER =
+            new CredentialRetrieveResult.Builder(RESULT_REJECTED_BY_PROVIDER).build();
+
+    /**
+     * Indicates that the credential request was rejected by the user.
+     */
+    public static final CredentialRetrieveResult REJECTED_BY_USER =
+            new CredentialRetrieveResult.Builder(RESULT_REJECTED_BY_USER).build();
+
+    /**
+     * Creates a credential retrieve request from its protocol buffer byte equivalent.
+     * @throws IOException if the request could not be parsed or validated.
+     */
+    public static CredentialRetrieveResult fromProtobufBytes(byte[] protobufBytes)
+            throws IOException {
+        return fromProtobuf(Protobufs.CredentialRetrieveResult.parseFrom(protobufBytes));
+    }
+
+    /**
+     * Creates a credential retrieve request from its protocol buffer equivalent.
+     */
+    public static CredentialRetrieveResult fromProtobuf(Protobufs.CredentialRetrieveResult proto) {
+        return new CredentialRetrieveResult.Builder(proto).build();
+    }
+
+    private final int mResultCode;
+
+    @Nullable
+    private final Credential mCredential;
+
+    @NonNull
+    private Map<String, ByteString> mAdditionalProps;
+
+    private CredentialRetrieveResult(
+            int resultCode,
+            Credential credential,
+            Map<String, ByteString> additionalProps) {
+        mResultCode = resultCode;
+        mCredential = credential;
+        mAdditionalProps = additionalProps;
+    }
+
+    /**
+     * The result code for the credential retrieve operation.
+     */
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    /**
+     * The credential returned by the credential provider, if available.
+     */
+    @Nullable
+    public Credential getCredential() {
+        return mCredential;
+    }
+
+    /**
+     * The additional, non-standard properties returned by the credential provider, if available.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProps() {
+        return CollectionConverter.convertMapValues(
+                mAdditionalProps,
+                ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
+    }
+
+    /**
+     * Creates a protocol buffer representation of the credential retrieve result, for transmission
+     * or storage.
+     */
+    public Protobufs.CredentialRetrieveResult toProtobuf() {
+        Protobufs.CredentialRetrieveResult.Builder builder =
+                Protobufs.CredentialRetrieveResult.newBuilder()
+                        .setResultCodeValue(mResultCode)
+                        .putAllAdditionalProps(mAdditionalProps);
+
+        if (mCredential != null) {
+            builder.setCredential(mCredential.toProtobuf());
+        }
+
+        return builder.build();
+    }
+
+    /**
+     * Creates an {@link Intent} containing this credential retrieve result, that a provider should
+     * return as its activity result.
+     */
+    public Intent toResultDataIntent() {
+        Intent intent = new Intent();
+        intent.putExtra(
+                ProtocolConstants.EXTRA_RETRIEVE_RESULT,
+                toProtobuf().toByteArray());
+        return intent;
+    }
+
+    /**
+     * Creates validated {@link CredentialRetrieveResult} instances.
+     */
+    public static final class Builder {
+
+        private int mResultCode;
+        private Credential mCredential;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
+
+        /**
+         * Starts the process of describing a credential retrieve result, and includes the
+         * mandatory status code.
+         */
+        public Builder(int resultCode) {
+            setResultCode(resultCode);
+        }
+
+        /**
+         * Seeds a credential retrieval result from its protocol buffer equivalent.
+         */
+        public Builder(Protobufs.CredentialRetrieveResult proto) {
+            setResultCode(proto.getResultCodeValue());
+            setCredentialFromProto(proto.getCredential());
+            setAdditionalPropertiesFromProto(proto.getAdditionalPropsMap());
+        }
+
+        /**
+         * Specifies the result code. It is recommended to use one of the standard values, though
+         * any value may be used.
+         *
+         * @see CredentialRetrieveResult#RESULT_SUCCESS
+         * @see CredentialRetrieveResult#RESULT_REJECTED_BY_PROVIDER
+         * @see CredentialRetrieveResult#RESULT_REJECTED_BY_USER
+         * @see CredentialRetrieveResult#RESULT_UNKNOWN
+         */
+        public Builder setResultCode(int resultCode) {
+            mResultCode = resultCode;
+            return this;
+        }
+
+        /**
+         * Specifies the credential being returned as part of this result. Can be null.
+         */
+        public Builder setCredential(@Nullable Credential credential) {
+            mCredential = credential;
+            return this;
+        }
+
+        /**
+         * Specifies the credential being returned as part of this result, in protocol buffer
+         * form. Can be null.
+         */
+        public Builder setCredentialFromProto(@Nullable Protobufs.Credential credential) {
+            mCredential = credential != null ? Credential.fromProtobuf(credential) : null;
+            return this;
+        }
+
+        /**
+         * Specifies the set of additional, non-standard properties to return as part of this
+         * result. The keys and values of the provided map must not be null. The keys must not
+         * be empty.
+         */
+        public Builder setAdditionalProperties(Map<String, byte[]> additionalProperties) {
+            require(additionalProperties, notNullValue());
+            require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
+            require(additionalProperties.values(), everyItem(notNullValue()));
+
+            mAdditionalProps =
+                    CollectionConverter.convertMapValues(
+                            additionalProperties,
+                            ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
+            return this;
+        }
+
+        Builder setAdditionalPropertiesFromProto(Map<String, ByteString> additionalProperties) {
+            require(additionalProperties, notNullValue());
+            require(additionalProperties.keySet(), everyItem(notNullOrEmptyString()));
+            require(additionalProperties.values(), everyItem(notNullValue()));
+
+            mAdditionalProps = additionalProperties;
+            return this;
+        }
+
+        /**
+         * Finalizes the creation of the credential retrieval result.
+         */
+        public CredentialRetrieveResult build() {
+            return new CredentialRetrieveResult(mResultCode, mCredential, mAdditionalProps);
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
index 8273eb9..8098649 100644
--- a/protocol/java/org/openyolo/protocol/ProtocolConstants.java
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -17,39 +17,55 @@ package org.openyolo.protocol;
 /**
  * Defines key constants that are used to identify data carried in intents.
  */
 public final class ProtocolConstants {
 
     /**
      * The data type used for credential queries using the BBQ protocol.
      */
     public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
 
     /**
      * The extra value key used to store the credential in a retrieve intent response.
      */
     public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
 
+    /**
+     * The extra value key used to carry a credential retrieve request.
+     */
+    public static final String EXTRA_RETRIEVE_REQUEST = "org.openyolo.credential.retrieve.request";
+
+    /**
+     * The extra value key used to carry a credential retrieve result.
+     */
+    public static final String EXTRA_RETRIEVE_RESULT = "org.openyolo.credential.retrieve.result";
+
     /**
      * The extra key value used to carry a hint request to a credential provider.
      */
     public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
 
     /**
      * The category used for all OpenYOLO-related intents.
      */
     public static final String OPENYOLO_CATEGORY = "org.openyolo";
 
+    /**
+     * The action used for credential retrieval request intents.
+     */
+    public static final String RETRIEVE_CREDENTIAL_ACTION = "org.openyolo.credential.retrieve";
+
     /**
      * The action used for hint intents.
      */
     public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
 
     /**
      * The action used for save intents.
      */
     public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
 
+
     private ProtocolConstants() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/RetrieveResult.java b/protocol/java/org/openyolo/protocol/RetrieveBbqResponse.java
similarity index 88%
rename from protocol/java/org/openyolo/protocol/RetrieveResult.java
rename to protocol/java/org/openyolo/protocol/RetrieveBbqResponse.java
index 0337ed2..497d1bf 100644
--- a/protocol/java/org/openyolo/protocol/RetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/RetrieveBbqResponse.java
@@ -33,184 +33,184 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.IntentUtil;
 
 /**
- * A response to a {@link RetrieveRequest credential retrieve request}.
+ * A response to a {@link CredentialRetrieveRequest credential retrieve request}.
  */
-public class RetrieveResult implements Parcelable {
+public class RetrieveBbqResponse implements Parcelable {
 
     /**
-     * Parcelable reader for {@link RetrieveResult} instances.
+     * Parcelable reader for {@link RetrieveBbqResponse} instances.
      * @see android.os.Parcelable
      */
-    public static final Creator<RetrieveResult> CREATOR = new RetrieveResultCreator();
+    public static final Creator<RetrieveBbqResponse> CREATOR = new RetrieveResultCreator();
 
     @Nullable
     private final Intent mRetrieveIntent;
 
     @NonNull
     private final Map<String, CredentialRetrieveBbqResponse> mResponses;
 
-    private RetrieveResult(
+    private RetrieveBbqResponse(
             @Nullable Intent retrieveIntent,
             @NonNull Map<String, CredentialRetrieveBbqResponse> responses) {
         mRetrieveIntent = retrieveIntent;
         mResponses = responses;
     }
 
     /**
      * An intent that can be used to retrieve a credential for the calling app. If no credentials
      * are available, this will be {@code null}. User input may or may not be required to retrieve
      * the credential, at the discretion of the credential provider. The retrieve intent
      * should be fired when the app is ready to retrieve the credential - typically immediately
      * after the retrieve result is received.
      */
     @Nullable
     public Intent getRetrieveIntent() {
         return mRetrieveIntent;
     }
 
     /**
      * The package names of responding credential providers that indicated they may have a usable
      * credential.
      */
     @NonNull
     public Set<String> getResponderPackageNames() {
         return mResponses.keySet();
     }
 
     /**
      * Retrieves the intent for the specified responder package name, if available.
      */
     @NonNull
     public Intent getRetrieveIntentForResponder(@NonNull String responderPackageName) {
         require(responderPackageName, notNullValue());
         CredentialRetrieveBbqResponse response = mResponses.get(responderPackageName);
         if (response == null) {
             throw new IllegalArgumentException(responderPackageName + " is not a responder");
         }
 
         return IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
     }
 
     /**
      * Retrieves the additional, non-standard response parameters for the specified responder
      * package name, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalPropsForResponder(String responderPackageName) {
         CredentialRetrieveBbqResponse response = mResponses.get(responderPackageName);
         if (response == null) {
             throw new IllegalArgumentException(responderPackageName + " is not a responder");
         }
 
         return CollectionConverter.convertMapValues(
                 response.getAdditionalPropsMap(),
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
-     * Creates {@link RetrieveResult} instances.
+     * Creates {@link RetrieveBbqResponse} instances.
      */
     public static final class Builder {
 
         @Nullable
         private Intent mIntent;
 
         @NonNull
         private Map<String, CredentialRetrieveBbqResponse> mProtoResponses;
 
         /**
          * Starts the process of describing a credential retrieve result.
          */
         public Builder() {
             mIntent = null;
             mProtoResponses = Collections.emptyMap();
         }
 
         /**
          * Specifies the map of protocol buffer responses received for the credential request,
          * keyed by the package name of the responder.
          */
         @NonNull
         public Builder setProtoResponses(
                 @NonNull Map<String, CredentialRetrieveBbqResponse> protoResponses) {
             require(protoResponses, notNullValue());
             for (CredentialRetrieveBbqResponse value : protoResponses.values()) {
                 require(value, notNullValue());
             }
             mProtoResponses = protoResponses;
             return this;
         }
 
         /**
          * Specifies the retrieve intent, that can be used to retrieve existing credentials from
          * the provider, if available.
          */
         @NonNull
         public Builder setRetrieveIntent(@Nullable Intent intent) {
             mIntent = intent;
             return this;
         }
 
         /**
-         * Creates a {@link RetrieveResult} with the properties described to the builder.
+         * Creates a {@link RetrieveBbqResponse} with the properties described to the builder.
          */
         @NonNull
-        public RetrieveResult build() {
-            return new RetrieveResult(mIntent, mProtoResponses);
+        public RetrieveBbqResponse build() {
+            return new RetrieveBbqResponse(mIntent, mProtoResponses);
         }
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeParcelable(mRetrieveIntent, 0);
         dest.writeInt(mResponses.size());
 
         for (String key : mResponses.keySet()) {
             byte[] responseBytes = mResponses.get(key).toByteArray();
             dest.writeString(key);
             dest.writeInt(responseBytes.length);
             dest.writeByteArray(responseBytes);
         }
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
-    static final class RetrieveResultCreator implements Creator<RetrieveResult> {
+    static final class RetrieveResultCreator implements Creator<RetrieveBbqResponse> {
         @Override
-        public RetrieveResult createFromParcel(Parcel in) {
+        public RetrieveBbqResponse createFromParcel(Parcel in) {
             Intent retrieveIntent = in.readParcelable(Intent.class.getClassLoader());
             int numResponses = in.readInt();
 
             Map<String, CredentialRetrieveBbqResponse> responses = new HashMap<>(numResponses);
             for (int i = 0; i < numResponses; i++) {
                 String key = in.readString();
                 int responseSize = in.readInt();
                 byte[] responseBytes = new byte[responseSize];
                 in.readByteArray(responseBytes);
 
                 CredentialRetrieveBbqResponse response;
                 try {
                     response = CredentialRetrieveBbqResponse.parseFrom(responseBytes);
                 } catch (InvalidProtocolBufferException ex) {
                     throw new IllegalArgumentException("Unable to parse response proto");
                 }
 
                 responses.put(key, response);
             }
 
-            return new RetrieveResult.Builder()
+            return new RetrieveBbqResponse.Builder()
                     .setRetrieveIntent(retrieveIntent)
                     .setProtoResponses(responses)
                     .build();
         }
 
         @Override
-        public RetrieveResult[] newArray(int size) {
-            return new RetrieveResult[size];
+        public RetrieveBbqResponse[] newArray(int size) {
+            return new RetrieveBbqResponse[size];
         }
     }
 
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/IntentUtil.java b/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
index f61b51f..89008d6 100644
--- a/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
+++ b/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
@@ -23,43 +23,53 @@ import android.os.Parcel;
 import android.support.annotation.NonNull;
 
+import com.google.protobuf.ByteString;
+
 /**
  * Utilities for manipulating intents for use in protocol buffers.
  */
 public final class IntentUtil {
 
     private IntentUtil() {
         throw new IllegalStateException("not intended to be constructed");
     }
 
     /**
      * Serializes the provided intent to a byte array.
      */
     @NonNull
     public static byte[] toBytes(@NonNull Intent intent) {
         require(intent, notNullValue());
 
         Parcel parcel = Parcel.obtain();
         parcel.writeParcelable(intent, 0);
         byte[] intentBytes = parcel.marshall();
         parcel.recycle();
 
         return intentBytes;
     }
 
+    /**
+     * Serializes the provided intent to a ByteString, for use with a protocol buffer.
+     */
+    public static ByteString toByteString(@NonNull Intent intent) {
+        require(intent, notNullValue());
+        return ByteString.copyFrom(toBytes(intent));
+    }
+
     /**
      * Deserializes an intent from the provided bytes array.
      */
     @NonNull
     public static Intent fromBytes(@NonNull byte[] intentBytes) {
         require(intentBytes, notNullValue());
 
         Parcel parcel = Parcel.obtain();
         parcel.unmarshall(intentBytes, 0, intentBytes.length);
         parcel.setDataPosition(0);
         Intent intent = parcel.readParcelable(IntentUtil.class.getClassLoader());
         parcel.recycle();
 
         ensure(intent, notNullValue());
         return intent;
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
similarity index 86%
rename from protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
rename to protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
index 16c6a6c..222e34d 100644
--- a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialRetrieveRequestTest.java
@@ -21,3 +21,2 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
-import android.net.Uri;
 import android.os.Parcel;
@@ -34,128 +33,128 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
 
 /**
- * Battery of tests for RetrieveRequest
+ * Battery of tests for CredentialRetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
-public class RetrieveRequestTest {
+public class CredentialRetrieveRequestTest {
 
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
-    private RetrieveRequest request;
+    private CredentialRetrieveRequest request;
 
     @Before
     public void setUp() {
-        request = new RetrieveRequest.Builder(AuthenticationMethods.EMAIL)
+        request = new CredentialRetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("a", "b")
                 .addAdditionalProperty("c", testBytes)
                 .build();
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
-            RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
+            CredentialRetrieveRequest deserialized = CredentialRetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
                     deserialized.getAdditionalProperties(),
                     request.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
-        new RetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
+        new CredentialRetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
-        new RetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
+        new CredentialRetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
-        RetrieveRequest request = RetrieveRequest
+        CredentialRetrieveRequest request = CredentialRetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
-        RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
+        CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testGetAdditionalProperties() {
         assertThat(request.getAdditionalProperties()).isNotNull();
         assertThat(request.getAdditionalProperties()).hasSize(2);
         assertThat(request.getAdditionalPropertyAsString("a")).isEqualTo("b");
         assertThat(request.getAdditionalProperty("c")).isEqualTo(testBytes);
     }
 
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
         Protobufs.CredentialRetrieveRequest.parseFrom((byte[]) null);
     }
 
     @Test
     public void testToProtocolBuffer_includesClientVersion() {
         String vendor = "test";
         int major = 1;
         int minor = 2;
         int patch = 3;
         ClientVersionUtil.setClientVersion(
                 Protobufs.ClientVersion.newBuilder()
                         .setVendor(vendor)
                         .setMajor(major)
                         .setMinor(minor)
                         .setPatch(patch)
                         .build());
 
         try {
-            RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(
+            CredentialRetrieveRequest request = CredentialRetrieveRequest.forAuthenticationMethods(
                     AuthenticationMethods.EMAIL);
             Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
             assertThat(proto.hasClientVersion());
             assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
             assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
             assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
             assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
         } finally {
             ClientVersionUtil.setClientVersion(null);
         }
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
index 4694dda..c8f2c9a 100644
--- a/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
@@ -30,4 +30,2 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.RetrieveResult;
 import org.openyolo.protocol.internal.IntentUtil;
@@ -38,75 +36,75 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for the RetrieveIntent class
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveResultTest {
 
-    private RetrieveResult underTest;
+    private RetrieveBbqResponse underTest;
 
     @Before
     public void setUp() throws Exception {
         Intent fromIntent = new Intent("com.openyolo.ACTION");
         fromIntent.setPackage("com.openyolo");
         byte[] fromBytes = IntentUtil.toBytes(fromIntent);
         Intent retrieveIntent= IntentUtil.fromBytes(fromBytes);
 
         Map<String, Protobufs.CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
 
-        underTest = new RetrieveResult.Builder()
+        underTest = new RetrieveBbqResponse.Builder()
                 .setProtoResponses(protoResponses)
                 .setRetrieveIntent(retrieveIntent)
                 .build();
     }
 
     @Test
     public void testGetRetrieveIntent(){
         Intent intent = underTest.getRetrieveIntent();
         assertNotNull(intent);
     }
 
     @Test
     public void testGetResponderPackageNames(){
         Set<String> responders = underTest.getResponderPackageNames();
         assertNotNull(responders);
     }
 
     @Test(expected = RequireViolation.class)
     public void testGetRetrieveIntentForResponder_null(){
         underTest.getRetrieveIntentForResponder(null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testGetRetrieveIntentForResponder_illegal(){
         underTest.getRetrieveIntentForResponder("BLahblah");
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         underTest.writeToParcel(p, 0);
         p.setDataPosition(0);
 
-        RetrieveResult result = RetrieveResult.CREATOR.createFromParcel(p);
+        RetrieveBbqResponse result = RetrieveBbqResponse.CREATOR.createFromParcel(p);
         checkIntentsEquivalent(underTest.getRetrieveIntent(), result.getRetrieveIntent());
         assertThat(result.getResponderPackageNames())
                 .isEqualTo(underTest.getResponderPackageNames());
 
         for (String responder : result.getResponderPackageNames()) {
             checkIntentsEquivalent(
                     underTest.getRetrieveIntentForResponder(responder),
                     result.getRetrieveIntentForResponder(responder));
 
             assertThat(result.getAdditionalPropsForResponder(responder))
                     .isEqualTo(underTest.getAdditionalPropsForResponder(responder));
         }
     }
 
     private void checkIntentsEquivalent(Intent expected, Intent actual) {
         // NOTE: we don't check the full intent, just the basic properties
         assertThat(actual.getPackage())
                 .isEqualTo(expected.getPackage());
         assertThat(actual.getAction())
                 .isEqualTo(expected.getAction());
     }
 }
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index 8adf913..8a6e98f 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -38,2 +38,21 @@ message CredentialRetrieveBbqResponse {
 
+message CredentialRetrieveBbqResponseList {
+    repeated CredentialRetrieveBbqResponse responses = 1;
+}
+
+message CredentialRetrieveResult {
+    enum ResultCode {
+        UNSPECIFIED = 0;
+        SUCCESS = 1;
+        REJECTED_BY_PROVIDER = 2;
+        REJECTED_BY_USER = 3;
+    }
+
+    // required
+    ResultCode resultCode = 1;
+
+    Credential credential = 2;
+    map<string, bytes> additionalProps = 3;
+}
+
 message HintRetrieveRequest {
diff --git a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
index 430f116..3d26146 100644
--- a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
+++ b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
@@ -26,62 +26,62 @@ import java.util.Set;
 import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveRequest;
-import org.openyolo.protocol.RetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.Protobufs;
 
 /**
  * Partial implementation of an OpenYOLO request receiver, that should be extended by providers.
  * This implementation handles some basic validation and decoding of the request before
  * handing the request to
- * {@link #processCredentialRequest(Context, BroadcastQuery, RetrieveRequest, Set)}.
+ * {@link #processCredentialRequest(Context, BroadcastQuery, CredentialRetrieveRequest, Set)}.
  */
 public abstract class BaseCredentialQueryReceiver extends BaseBroadcastQueryReceiver {
 
     /**
      * Creates a receiver that will log errors to the specified log tag.
      */
     public BaseCredentialQueryReceiver(String logTag) {
         super(logTag);
     }
 
     @Override
     protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
-        CredentialRetrieveRequest requestProto;
+        Protobufs.CredentialRetrieveRequest requestProto;
 
         try {
-            requestProto = CredentialRetrieveRequest.parseFrom(query.getQueryMessage());
+            requestProto = Protobufs.CredentialRetrieveRequest.parseFrom(query.getQueryMessage());
         } catch (NullPointerException | IOException ex) {
             Log.w(mLogTag, "Failed to parse credential request message", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
-        RetrieveRequest request;
+        CredentialRetrieveRequest request;
         try {
-            request = new RetrieveRequest.Builder(requestProto).build();
+            request = new CredentialRetrieveRequest.Builder(requestProto).build();
         } catch (NullPointerException | IllegalArgumentException ex) {
             Log.w(mLogTag, "Credential request message failed field validation", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         // TODO: validate claimed authentication domains
         Set<AuthenticationDomain> requestorDomains =
                 new HashSet<>(AuthenticationDomain.listForPackage(
                     context,
                     query.getRequestingApp()));
 
         // Ensure the authentication domain of the requesting app can be determined
         if (requestorDomains.isEmpty()) {
             Log.w(mLogTag, "Unable to determine the authentication domain of the requesting app");
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         processCredentialRequest(context, query, request, requestorDomains);
     }
 
     protected abstract void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
-            @NonNull RetrieveRequest request,
+            @NonNull CredentialRetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains);
 }
diff --git a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
deleted file mode 100644
index 75e5b40..0000000
--- a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.spi;
-
-import android.content.Intent;
-import android.support.annotation.Nullable;
-
-import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.ProtocolConstants;
-
-/**
- * Utility methods for expressing and manipulating the result of a credential retrieve intent.
- */
-public final class RetrieveIntentResultUtil {
-
-    /**
-     * Creates an {@link android.content.Intent} wrapper for the result of a credential retrieve
-     * intent.
-     */
-    public static Intent createResponseData(@Nullable Credential credential) {
-        return createResponseData(
-                credential != null ? credential.toProtobuf() : null);
-    }
-
-    /**
-     * Creates an {@link android.content.Intent} wrapper for the result of a credential retrieve
-     * intent.
-     */
-    public static Intent createResponseData(@Nullable Protobufs.Credential credential) {
-        Intent responseData = new Intent();
-        if (credential != null) {
-            responseData.putExtra(ProtocolConstants.EXTRA_CREDENTIAL, credential.toByteArray());
-        }
-        return responseData;
-    }
-}
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
index ccd419a..eb64e86 100644
--- a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -43,5 +43,4 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.AuthenticationMethod;
+import org.openyolo.protocol.CredentialRetrieveRequest;
 import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveRequest;
-import org.openyolo.protocol.RetrieveRequest;
 import org.robolectric.RobolectricTestRunner;
@@ -50,154 +49,154 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link BaseCredentialQueryReceiver}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE,
         shadows = {
                 ShadowQueryResponseSender.class,
                 ShadowAuthenticationDomain.class
         })
 public class BaseCredentialQueryReceiverTest {
 
     private BaseCredentialQueryReceiver credentialQueryReceiver;
 
     @Mock
     Context mockContext;
 
     private static final String CALLING_PACKAGE_NAME = "org.openyolo.supercoolapp";
 
     private static final BroadcastQuery QUERY_WITH_NULL_MESSAGE =
             makeQueryFromRequest(null /* request */);
 
     private static final BroadcastQuery QUERY_WITH_INVALID_REQUEST =
             makeQueryFromRequest(makeInvalidCredentialRetrieveRequest());
 
     private static final BroadcastQuery QUERY_WITH_VALID_REQUEST =
             makeQueryFromRequest(makeValidCredentialRetrieveRequest());
 
     private static final List<AuthenticationDomain> VALID_AUTHENTICATION_DOMAINS =
             makeValidAuthenticationDomains();
 
 
     private static BroadcastQuery makeQueryFromRequest(
-            @Nullable CredentialRetrieveRequest request) {
+            @Nullable Protobufs.CredentialRetrieveRequest request) {
         BroadcastQuery.Builder builder = BroadcastQuery.newBuilder()
                 .setRequestingApp(CALLING_PACKAGE_NAME)
                 .setDataType("blah")
                 .setRequestId(101L)
                 .setResponseId(102L);
 
         if (request != null) {
             builder.setQueryMessage(ByteString.copyFrom(request.toByteArray()));
         }
 
         return builder.build();
     }
 
     private static List<AuthenticationDomain> makeValidAuthenticationDomains() {
         List<AuthenticationDomain> authenticationDomains = new ArrayList<>();
         authenticationDomains.add(mock(AuthenticationDomain.class));
 
         return authenticationDomains;
     }
 
-    private static CredentialRetrieveRequest makeInvalidCredentialRetrieveRequest() {
+    private static Protobufs.CredentialRetrieveRequest makeInvalidCredentialRetrieveRequest() {
         // Invalid because it does not specify a non-empty set of authentication method
-        return CredentialRetrieveRequest.newBuilder().build();
+        return Protobufs.CredentialRetrieveRequest.newBuilder().build();
     }
 
-    private static CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
-        return CredentialRetrieveRequest.newBuilder()
+    private static Protobufs.CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
+        return Protobufs.CredentialRetrieveRequest.newBuilder()
             .addAuthMethods(new AuthenticationMethod("custom://one").toProtobuf())
             .addAuthMethods(new AuthenticationMethod("custom://two").toProtobuf())
             .build();
     }
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         ShadowQueryResponseSender.intializeForTest();
 
         credentialQueryReceiver = spy(
                 new BaseCredentialQueryReceiver("TestCredentialQueryReceiver") {
                     @Override
                     protected void processCredentialRequest(
                             @NonNull Context context,
                             @NonNull BroadcastQuery query,
-                            @NonNull RetrieveRequest request,
+                            @NonNull CredentialRetrieveRequest request,
                             @NonNull Set<AuthenticationDomain> requestorDomains) {
                         // Do nothing
                     }
                 });
 
         ShadowAuthenticationDomain.setListForPackageResponse(VALID_AUTHENTICATION_DOMAINS);
     }
 
     @Test
     public void processQuery_withNullQuery_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_NULL_MESSAGE);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withInvalidRequest_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_INVALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withValidRequest_processesRequest() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasCalled();
         verifyQueryResponseIsNotSent();
     }
 
     @Test
     public void processQuery_withValidRequestAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
             throws Exception {
         ShadowAuthenticationDomain.setListForPackageResponse(
                 Collections.<AuthenticationDomain>emptyList());
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     private void verifyQueryResponseIsNotSent() {
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(0))
                 .sendResponse((BroadcastQuery) any(), (byte[]) any());
     }
 
     private void verifyQueryResponseIsSentWith(@Nullable byte[] response) {
         if (null == response) {
             verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                     .sendResponse((BroadcastQuery) any(), (byte[]) isNull());
             return;
         }
 
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                 .sendResponse((BroadcastQuery) any(), eq(response));
     }
 
     private void verifyProcessCredentialRequestWasCalled() {
         verify(credentialQueryReceiver, times(1))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
-                        (RetrieveRequest) any(),
+                        (CredentialRetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 
     private void verifyProcessCredentialRequestWasNotCalled() {
         verify(credentialQueryReceiver, times(0))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
-                        (RetrieveRequest) any(),
+                        (CredentialRetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
deleted file mode 100644
index 967f9b9..0000000
--- a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.spi;
-
-import android.content.Intent;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.ProtocolConstants;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.Assert.assertNull;
-import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
-
-/**
- * Battery of tests for RetrieveIntentResultUtil
- */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public class RetrieveIntentResultUtilTest {
-    public static final String EMAIL_ID = "alice@example.com";
-
-    @Test
-    public void testCreateResponseData() throws Exception {
-        Credential cr = new Credential.Builder(
-                EMAIL_ID,
-                EMAIL,
-                new AuthenticationDomain("https://www.example.com"))
-                .build();
-        Intent response = RetrieveIntentResultUtil.createResponseData(cr.toProtobuf());
-
-        assertThat(response.hasExtra(ProtocolConstants.EXTRA_CREDENTIAL)).isTrue();
-        byte[] bytes = response.getExtras().getByteArray(ProtocolConstants.EXTRA_CREDENTIAL);
-        Credential credential = Credential.fromProtoBytes(bytes);
-        assertThat(credential.getIdentifier()).isEqualTo(EMAIL_ID);
-        assertThat(credential.getAuthenticationMethod()).isEqualTo(EMAIL);
-    }
-
-    @Test
-    public void testCreateResponseData_withNull() throws Exception {
-        Intent response = RetrieveIntentResultUtil.createResponseData((Credential) null);
-        assertNull(response.getExtras());
-    }
-}
\ No newline at end of file
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 4c099f4..6bcb1ca 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -38,105 +38,105 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_method_text_input)
     EditText mAuthenticationMethodInput;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
-            Credential credential = mApi.getCredentialFromActivityResult(data);
+            Credential credential = mApi.getHintRetrieveResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         String authMethodStr = mAuthenticationMethodInput.getText().toString();
         AuthenticationMethod authMethod;
         try {
             authMethod = new AuthenticationMethod(authMethodStr);
         } catch (RequireViolation ex) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
 
         HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethod);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void onEmailAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index f6b59ed..12e61aa 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -16,5 +16,2 @@ package org.openyolo.testapp;
 
-import static android.app.Activity.RESULT_CANCELED;
-import static android.app.Activity.RESULT_OK;
-
 import android.content.ActivityNotFoundException;
@@ -35,121 +32,125 @@ import org.openyolo.api.RetrieveCallback;
 import org.openyolo.protocol.AuthenticationMethod;
-import org.openyolo.protocol.Credential;
-import org.openyolo.protocol.RetrieveRequest;
-import org.openyolo.protocol.RetrieveResult;
+import org.openyolo.protocol.CredentialRetrieveRequest;
+import org.openyolo.protocol.CredentialRetrieveResult;
+import org.openyolo.protocol.RetrieveBbqResponse;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
-        if (resultCode == RESULT_OK) {
-            Credential credential = mApi.getCredentialFromActivityResult(data);
-            if (credential == null) {
-                showSnackbar(R.string.no_credential_returned);
-            } else {
-                mCredentialView.setFieldsFromCredential(credential);
-            }
-        } else if (resultCode == RESULT_CANCELED) {
-            showSnackbar(R.string.retrieve_cancelled);
+        CredentialRetrieveResult result = mApi.getCredentialRetrieveResult(data);
+        if (result.getCredential() != null) {
+            mCredentialView.setFieldsFromCredential(result.getCredential());
+            return;
+        }
+
+
+        int retrieveResultCode = result.getResultCode();
+        if (retrieveResultCode == CredentialRetrieveResult.RESULT_REJECTED_BY_USER) {
+            showSnackbar(R.string.credential_retrieve_user_rejected);
+        } else if (retrieveResultCode == CredentialRetrieveResult.RESULT_REJECTED_BY_PROVIDER) {
+            showSnackbar(R.string.credential_retrieve_provider_rejected);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
-        RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
+        CredentialRetrieveRequest request =
+                CredentialRetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
-        private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
+        private final AtomicReference<RetrieveBbqResponse> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
-        public void onComplete(RetrieveResult result, Throwable error) {
+        public void onComplete(RetrieveBbqResponse result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
-            RetrieveResult result = mResult.get();
+            RetrieveBbqResponse result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 8de7fec..0a5d1ee 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,57 +1,59 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
     <string name="no_credentials">No credentials available</string>
-    <string name="retrieve_cancelled">Credential retrieve cancelled</string>
+    <string name="credential_retrieve_user_rejected">Credential retrieve canceled by user</string>
+    <string name="credential_retrieve_provider_rejected">Credential retrieve rejected by provider</string>
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_cancelled">Hint retrieve cancelled</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
     <string name="no_credential_returned">No credential returned</string>
+
 </resources>

commit 9f1df3bbcac88359cdd7739a40e1ec43e41e5a9c
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Wed May 3 11:25:46 2017 -0700

    Add appendix to license file, for proper github identification

diff --git a/LICENSE b/LICENSE
index d9a10c0..8f71f43 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,176 +1,202 @@
                                  Apache License
                            Version 2.0, January 2004
                         http://www.apache.org/licenses/
 
    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 
    1. Definitions.
 
       "License" shall mean the terms and conditions for use, reproduction,
       and distribution as defined by Sections 1 through 9 of this document.
 
       "Licensor" shall mean the copyright owner or entity authorized by
       the copyright owner that is granting the License.
 
       "Legal Entity" shall mean the union of the acting entity and all
       other entities that control, are controlled by, or are under common
       control with that entity. For the purposes of this definition,
       "control" means (i) the power, direct or indirect, to cause the
       direction or management of such entity, whether by contract or
       otherwise, or (ii) ownership of fifty percent (50%) or more of the
       outstanding shares, or (iii) beneficial ownership of such entity.
 
       "You" (or "Your") shall mean an individual or Legal Entity
       exercising permissions granted by this License.
 
       "Source" form shall mean the preferred form for making modifications,
       including but not limited to software source code, documentation
       source, and configuration files.
 
       "Object" form shall mean any form resulting from mechanical
       transformation or translation of a Source form, including but
       not limited to compiled object code, generated documentation,
       and conversions to other media types.
 
       "Work" shall mean the work of authorship, whether in Source or
       Object form, made available under the License, as indicated by a
       copyright notice that is included in or attached to the work
       (an example is provided in the Appendix below).
 
       "Derivative Works" shall mean any work, whether in Source or Object
       form, that is based on (or derived from) the Work and for which the
       editorial revisions, annotations, elaborations, or other modifications
       represent, as a whole, an original work of authorship. For the purposes
       of this License, Derivative Works shall not include works that remain
       separable from, or merely link (or bind by name) to the interfaces of,
       the Work and Derivative Works thereof.
 
       "Contribution" shall mean any work of authorship, including
       the original version of the Work and any modifications or additions
       to that Work or Derivative Works thereof, that is intentionally
       submitted to Licensor for inclusion in the Work by the copyright owner
       or by an individual or Legal Entity authorized to submit on behalf of
       the copyright owner. For the purposes of this definition, "submitted"
       means any form of electronic, verbal, or written communication sent
       to the Licensor or its representatives, including but not limited to
       communication on electronic mailing lists, source code control systems,
       and issue tracking systems that are managed by, or on behalf of, the
       Licensor for the purpose of discussing and improving the Work, but
       excluding communication that is conspicuously marked or otherwise
       designated in writing by the copyright owner as "Not a Contribution."
 
       "Contributor" shall mean Licensor and any individual or Legal Entity
       on behalf of whom a Contribution has been received by Licensor and
       subsequently incorporated within the Work.
 
    2. Grant of Copyright License. Subject to the terms and conditions of
       this License, each Contributor hereby grants to You a perpetual,
       worldwide, non-exclusive, no-charge, royalty-free, irrevocable
       copyright license to reproduce, prepare Derivative Works of,
       publicly display, publicly perform, sublicense, and distribute the
       Work and such Derivative Works in Source or Object form.
 
    3. Grant of Patent License. Subject to the terms and conditions of
       this License, each Contributor hereby grants to You a perpetual,
       worldwide, non-exclusive, no-charge, royalty-free, irrevocable
       (except as stated in this section) patent license to make, have made,
       use, offer to sell, sell, import, and otherwise transfer the Work,
       where such license applies only to those patent claims licensable
       by such Contributor that are necessarily infringed by their
       Contribution(s) alone or by combination of their Contribution(s)
       with the Work to which such Contribution(s) was submitted. If You
       institute patent litigation against any entity (including a
       cross-claim or counterclaim in a lawsuit) alleging that the Work
       or a Contribution incorporated within the Work constitutes direct
       or contributory patent infringement, then any patent licenses
       granted to You under this License for that Work shall terminate
       as of the date such litigation is filed.
 
    4. Redistribution. You may reproduce and distribute copies of the
       Work or Derivative Works thereof in any medium, with or without
       modifications, and in Source or Object form, provided that You
       meet the following conditions:
 
       (a) You must give any other recipients of the Work or
           Derivative Works a copy of this License; and
 
       (b) You must cause any modified files to carry prominent notices
           stating that You changed the files; and
 
       (c) You must retain, in the Source form of any Derivative Works
           that You distribute, all copyright, patent, trademark, and
           attribution notices from the Source form of the Work,
           excluding those notices that do not pertain to any part of
           the Derivative Works; and
 
       (d) If the Work includes a "NOTICE" text file as part of its
           distribution, then any Derivative Works that You distribute must
           include a readable copy of the attribution notices contained
           within such NOTICE file, excluding those notices that do not
           pertain to any part of the Derivative Works, in at least one
           of the following places: within a NOTICE text file distributed
           as part of the Derivative Works; within the Source form or
           documentation, if provided along with the Derivative Works; or,
           within a display generated by the Derivative Works, if and
           wherever such third-party notices normally appear. The contents
           of the NOTICE file are for informational purposes only and
           do not modify the License. You may add Your own attribution
           notices within Derivative Works that You distribute, alongside
           or as an addendum to the NOTICE text from the Work, provided
           that such additional attribution notices cannot be construed
           as modifying the License.
 
       You may add Your own copyright statement to Your modifications and
       may provide additional or different license terms and conditions
       for use, reproduction, or distribution of Your modifications, or
       for any such Derivative Works as a whole, provided Your use,
       reproduction, and distribution of the Work otherwise complies with
       the conditions stated in this License.
 
    5. Submission of Contributions. Unless You explicitly state otherwise,
       any Contribution intentionally submitted for inclusion in the Work
       by You to the Licensor shall be under the terms and conditions of
       this License, without any additional terms or conditions.
       Notwithstanding the above, nothing herein shall supersede or modify
       the terms of any separate license agreement you may have executed
       with Licensor regarding such Contributions.
 
    6. Trademarks. This License does not grant permission to use the trade
       names, trademarks, service marks, or product names of the Licensor,
       except as required for reasonable and customary use in describing the
       origin of the Work and reproducing the content of the NOTICE file.
 
    7. Disclaimer of Warranty. Unless required by applicable law or
       agreed to in writing, Licensor provides the Work (and each
       Contributor provides its Contributions) on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
       implied, including, without limitation, any warranties or conditions
       of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
       PARTICULAR PURPOSE. You are solely responsible for determining the
       appropriateness of using or redistributing the Work and assume any
       risks associated with Your exercise of permissions under this License.
 
    8. Limitation of Liability. In no event and under no legal theory,
       whether in tort (including negligence), contract, or otherwise,
       unless required by applicable law (such as deliberate and grossly
       negligent acts) or agreed to in writing, shall any Contributor be
       liable to You for damages, including any direct, indirect, special,
       incidental, or consequential damages of any character arising as a
       result of this License or out of the use or inability to use the
       Work (including but not limited to damages for loss of goodwill,
       work stoppage, computer failure or malfunction, or any and all
       other commercial damages or losses), even if such Contributor
       has been advised of the possibility of such damages.
 
    9. Accepting Warranty or Additional Liability. While redistributing
       the Work or Derivative Works thereof, You may choose to offer,
       and charge a fee for, acceptance of support, warranty, indemnity,
       or other liability obligations and/or rights consistent with this
       License. However, in accepting such obligations, You may act only
       on Your own behalf and on Your sole responsibility, not on behalf
       of any other Contributor, and only if You agree to indemnify,
       defend, and hold each Contributor harmless for any liability
       incurred by, or claims asserted against, such Contributor by reason
       of your accepting any such warranty or additional liability.
 
    END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

commit a8e573a7df267463e5d272d0046e2cc071820bc9
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu Apr 27 17:25:29 2017 -0700

    Introduce ClientVersion to request protos
    
    The version is taken from new BuildConfig properties, that are in
    turn generated from the closest git tag to the current commit.

diff --git a/api/build.gradle b/api/build.gradle
index 68e8d94..8586db6 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -4,7 +4,11 @@ apply from:'../config/android-common.gradle'
 android {
     defaultConfig {
         vectorDrawables.useSupportLibrary = true
         consumerProguardFiles 'proguard-rules.txt'
         project.archivesBaseName = 'openyolo-api'
+
+        buildConfigField('String', 'clientVersionMajor', rootProject.ext.versionMajor)
+        buildConfigField('String', 'clientVersionMinor', rootProject.ext.versionMinor)
+        buildConfigField('String', 'clientVersionPatch', rootProject.ext.versionPatch)
     }
 }
diff --git a/bbq/build.gradle b/bbq/build.gradle
index 48a53c3..05bb0f9 100644
--- a/bbq/build.gradle
+++ b/bbq/build.gradle
@@ -6,3 +6,11 @@ apply from:'../config/third-party.gradle'
 
-android.defaultConfig.project.archivesBaseName = 'bbq'
+android {
+    defaultConfig {
+        project.archivesBaseName = 'bbq'
+
+        buildConfigField('String', 'bbqVersionMajor', rootProject.ext.versionMajor)
+        buildConfigField('String', 'bbqVersionMinor', rootProject.ext.versionMinor)
+        buildConfigField('String', 'bbqVersionPatch', rootProject.ext.versionPatch)
+    }
+}
 
diff --git a/bbq/java/com/google/bbq/BroadcastQueryClient.java b/bbq/java/com/google/bbq/BroadcastQueryClient.java
index f6960f0..8944d96 100644
--- a/bbq/java/com/google/bbq/BroadcastQueryClient.java
+++ b/bbq/java/com/google/bbq/BroadcastQueryClient.java
@@ -29,2 +29,3 @@ import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.Protobufs.BroadcastQueryResponse;
+import com.google.bbq.internal.ClientVersionUtil;
 import com.google.protobuf.ByteString;
@@ -48,316 +49,317 @@ import java.util.concurrent.atomic.AtomicReference;
 /**
  * Dispatches broadcast queries to available data providers.
  */
 public final class BroadcastQueryClient {
 
     /**
      * The default amount of time that this client will wait for responses from providers, before
      * ignoring them.
      */
     public static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2);
 
     private static final String LOG_TAG = "BroadcastQueryClient";
 
     private static final AtomicReference<BroadcastQueryClient> INSTANCE =
             new AtomicReference<>();
 
     @NonNull
     private final Context mContext;
 
     @NonNull
     private final SecureRandom mSecureRandom;
 
     @NonNull
     private final ConcurrentHashMap<Long, PendingQuery> mPendingQueries;
 
     @NonNull
     private final ScheduledExecutorService mExecutorService;
 
     @NonNull
     private final AtomicBoolean mDisposed;
 
     /**
      * Retrieves the global instance of the broadcast query client for the application
      * associated to the provided context.
      */
     @NonNull
     public static BroadcastQueryClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         BroadcastQueryClient client = new BroadcastQueryClient(applicationContext);
         if (!INSTANCE.compareAndSet(null, client)) {
             client.dispose();
             client = INSTANCE.get();
         }
 
         return client;
     }
 
     BroadcastQueryClient(@NonNull Context context) {
         mContext = context;
         mSecureRandom = new SecureRandom();
         mPendingQueries = new ConcurrentHashMap<>();
         mExecutorService = Executors.newSingleThreadScheduledExecutor();
         mDisposed = new AtomicBoolean(false);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified protocol buffer
      * message (if required). The response to this query will be provided to the specified callback.
      * A {@link #DEFAULT_TIMEOUT_MS default timeout} will be used.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable MessageLite queryMessage,
             @NonNull QueryCallback callback) {
         queryFor(dataType,
                 queryMessage,
                 DEFAULT_TIMEOUT_MS,
                 callback);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified protocol buffer
      * message (if required). The response to this query will be provided to the specified callback.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable MessageLite queryMessage,
             long timeoutInMs,
             @NonNull QueryCallback callback) {
         queryFor(dataType,
                 queryMessage != null ? queryMessage.toByteArray() : null,
                 timeoutInMs,
                 callback);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified message (if required).
      * The response to this query will be provided to the specified callback.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable byte[] queryMessage,
             long timeoutInMs,
             @NonNull QueryCallback callback) {
         require(!TextUtils.isEmpty(dataType), "dataType must not be null or empty");
         require(timeoutInMs > 0, "Timeout must be greater than zero");
         require(callback, notNullValue());
         require(!isDisposed(), "BroadcastQueryClient has been disposed");
 
         PendingQuery pq = new PendingQuery(
                 dataType,
                 queryMessage,
                 timeoutInMs,
                 callback);
 
         long queryId;
         do {
             queryId = mSecureRandom.nextLong();
         } while (mPendingQueries.putIfAbsent(queryId, pq) != null);
         pq.dispatch(queryId);
     }
 
     /**
      * Disposes all leakable resources associated with this client.
      */
     private void dispose() {
         if (!mDisposed.compareAndSet(false, true)) {
             return;
         }
 
         mExecutorService.shutdownNow();
         for (PendingQuery pq : mPendingQueries.values()) {
             mContext.unregisterReceiver(pq.mResponseReceiver);
         }
     }
 
     /**
      * Determines whether this client has been disposed, and therefore should no longer be used.
      */
     private boolean isDisposed() {
         return mDisposed.get();
     }
 
     private Intent createQueryIntent(
             PendingQuery pendingQuery,
             String responderPackage,
             long responseId) {
         Intent queryIntent = QueryUtil.createEmptyQueryIntent(pendingQuery.mDataType);
         queryIntent.setPackage(responderPackage);
         queryIntent.putExtra(QueryUtil.EXTRA_QUERY_MESSAGE,
                 BroadcastQuery.newBuilder()
+                        .setClientVersion(ClientVersionUtil.getClientVersion())
                         .setRequestingApp(mContext.getPackageName())
                         .setDataType(pendingQuery.mDataType)
                         .setRequestId(pendingQuery.mQueryId)
                         .setResponseId(responseId)
                         .setQueryMessage(pendingQuery.mQueryMessage != null
                                 ? ByteString.copyFrom(pendingQuery.mQueryMessage)
                                 : null)
                         .build()
                         .toByteArray());
         return queryIntent;
     }
 
     private final class PendingQuery {
         final String mDataType;
         final byte[] mQueryMessage;
         final Map<Long, String> mRespondersById;
         final CopyOnWriteArraySet<Long> mPendingResponses;
         final ConcurrentHashMap<String, QueryResponse> mResponses;
         final QueryCallback mQueryCallback;
         final long mTimeoutInMs;
 
         long mQueryId;
         ScheduledFuture<Void> mTimeoutFuture;
         BroadcastReceiver mResponseReceiver;
 
         PendingQuery(
                 String dataType,
                 byte[] queryMessage,
                 long timeoutInMs,
                 QueryCallback queryCallback) {
             mDataType = dataType;
             mQueryMessage = queryMessage;
             mTimeoutInMs = timeoutInMs;
 
             mRespondersById = buildRespondersById();
             mPendingResponses = new CopyOnWriteArraySet<>();
             for (long responderId : mRespondersById.keySet()) {
                 mPendingResponses.add(responderId);
             }
             mResponses = new ConcurrentHashMap<>();
             mQueryCallback = queryCallback;
         }
 
         Map<Long, String> buildRespondersById() {
             Set<String> responders = QueryUtil.getRespondersForDataType(mContext, mDataType);
             HashMap<Long, String> tempRespondersById = new HashMap<>();
             for (String responderPackage : responders) {
                 long responderId;
                 do {
                     responderId = mSecureRandom.nextLong();
                 } while (tempRespondersById.containsKey(responderId));
 
                 tempRespondersById.put(responderId, responderPackage);
             }
             return tempRespondersById;
         }
 
         void dispatch(long queryId) {
             mQueryId = queryId;
 
             if (mRespondersById.isEmpty()) {
                 complete();
                 return;
             }
 
             mResponseReceiver = new ResponseHandler(this);
             mContext.registerReceiver(mResponseReceiver, getResponseFilter());
 
             for (Map.Entry<Long, String> responderEntry : mRespondersById.entrySet()) {
                 long responseId = responderEntry.getKey();
                 String responderPackage = responderEntry.getValue();
                 mContext.sendBroadcast(createQueryIntent(this, responderPackage, responseId));
             }
 
             mTimeoutFuture = mExecutorService.schedule(
                     new QueryTimeoutHandler(this),
                     mTimeoutInMs,
                     TimeUnit.MILLISECONDS);
         }
 
         void complete() {
             if (!mPendingQueries.remove(mQueryId, this)) {
                 // response already delivered
                 return;
             }
 
             if (mTimeoutFuture != null) {
                 mTimeoutFuture.cancel(false);
             }
 
             if (mResponseReceiver != null) {
                 mContext.unregisterReceiver(mResponseReceiver);
             }
 
             mQueryCallback.onResponse(mQueryId, new ArrayList<>(mResponses.values()));
         }
 
         IntentFilter getResponseFilter() {
             IntentFilter filter = new IntentFilter();
             filter.addAction(QueryUtil.createResponseAction(mDataType, mQueryId));
             filter.addCategory(QueryUtil.BBQ_CATEGORY);
             return filter;
         }
     }
 
     /**
      * Forcibly completes a pending query when a timeout is reached.
      */
     private final class QueryTimeoutHandler implements Callable<Void> {
 
         final PendingQuery mPendingQuery;
 
         QueryTimeoutHandler(PendingQuery pendingQuery) {
             mPendingQuery = pendingQuery;
         }
 
         @Override
         public Void call() throws Exception {
             mPendingQuery.complete();
             return null;
         }
     }
 
     /**
      * Captures broadcast responses for queries.
      */
     private final class ResponseHandler extends BroadcastReceiver {
 
         final PendingQuery mPendingQuery;
 
         ResponseHandler(PendingQuery pendingQuery) {
             mPendingQuery = pendingQuery;
         }
 
         @Override
         public void onReceive(Context context, Intent intent) {
             byte[] responseBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
             if (responseBytes == null) {
                 Log.w(LOG_TAG, "Received query response without a defined message");
                 return;
             }
 
             BroadcastQueryResponse response;
             try {
                 response = BroadcastQueryResponse.parseFrom(responseBytes);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Unable to parse query response message");
                 return;
             }
 
             String responder = mPendingQuery.mRespondersById.get(response.getResponseId());
             if (responder == null) {
                 Log.w(LOG_TAG, "Received response from unknown responder");
                 return;
             }
 
             if (!mPendingQuery.mPendingResponses.remove(response.getResponseId())) {
                 Log.w(LOG_TAG, "Duplicate response received; ignoring");
                 return;
             }
 
             if (response.getResponseMessage() != null) {
                 QueryResponse queryResponse = new QueryResponse(
                         responder,
                         response.getResponseId(),
                         response.getResponseMessage().toByteArray());
                 mPendingQuery.mResponses.put(responder, queryResponse);
             }
 
             if (mPendingQuery.mPendingResponses.isEmpty()) {
                 mPendingQuery.complete();
             }
         }
     }
 }
diff --git a/bbq/java/com/google/bbq/internal/ClientVersionUtil.java b/bbq/java/com/google/bbq/internal/ClientVersionUtil.java
new file mode 100644
index 0000000..e074c65
--- /dev/null
+++ b/bbq/java/com/google/bbq/internal/ClientVersionUtil.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq.internal;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+
+import com.google.bbq.BuildConfig;
+import com.google.bbq.Protobufs;
+
+/**
+ * Holds the client version that is built from the static configuration.
+ */
+public final class ClientVersionUtil {
+
+    private static final String VENDOR = "openid.net";
+
+    @NonNull
+    private static final Protobufs.ClientVersion BUILD_CLIENT_VERSION =
+            Protobufs.ClientVersion.newBuilder()
+                    .setVendor(VENDOR)
+                    .setMajor(parseVersionPart(BuildConfig.bbqVersionMajor))
+                    .setMinor(parseVersionPart(BuildConfig.bbqVersionMinor))
+                    .setPatch(parseVersionPart(BuildConfig.bbqVersionPatch))
+                    .build();
+
+    private static Protobufs.ClientVersion sClientVersion;
+
+    /**
+     * Retrieve the client version, typically sourced from the static build information.
+     */
+    @NonNull
+    public static Protobufs.ClientVersion getClientVersion() {
+        Protobufs.ClientVersion clientVersion = sClientVersion;
+        if (clientVersion == null) {
+            clientVersion = BUILD_CLIENT_VERSION;
+            sClientVersion = clientVersion;
+        }
+
+        return clientVersion;
+    }
+
+    /**
+     * Overrides the client version, for testing purposes.
+     */
+    @VisibleForTesting
+    public static void setClientVersion(Protobufs.ClientVersion clientVersion) {
+        sClientVersion = clientVersion;
+    }
+
+    @VisibleForTesting
+    static int parseVersionPart(String versionPart) {
+        if (versionPart == null || versionPart.isEmpty()) {
+            return 0;
+        }
+
+        int versionNum;
+        try {
+            versionNum = Integer.parseInt(versionPart);
+        } catch (NumberFormatException ex) {
+            return 0;
+        }
+
+        if (versionNum < 0) {
+            return 0;
+        }
+
+        return versionNum;
+    }
+
+}
diff --git a/bbq/java/com/google/bbq/internal/package-info.java b/bbq/java/com/google/bbq/internal/package-info.java
new file mode 100644
index 0000000..2e9f1e1
--- /dev/null
+++ b/bbq/java/com/google/bbq/internal/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Data types and utility classes that are used internally by BBQ. _NOTE_: The contents of
+ * this package are _not_ part of the public API, and may change at any time.
+ */
+package com.google.bbq.internal;
diff --git a/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java b/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
index c85611a..4767d82 100644
--- a/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
+++ b/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
@@ -19,2 +19,3 @@ package com.google.bbq;
 
+import static org.assertj.core.api.Java6Assertions.assertThat;
 import static org.junit.Assert.fail;
@@ -33,2 +34,5 @@ import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+
+import com.google.bbq.internal.ClientVersionUtil;
+
 import java.security.SecureRandom;
@@ -36,4 +40,7 @@ import java.util.ArrayList;
 import java.util.List;
+
+import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
@@ -45,108 +52,146 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for BroadcastQueryClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class BroadcastQueryClientTest {
     @Mock
     private Context mockContext;
     @Mock
     private PackageManager mockPackageManager;
 
     private BroadcastQueryClient underTest;
     private ArrayList<ResolveInfo> mPackageinfos;
 
+    private Protobufs.ClientVersion testClientVersion;
+
+    @SuppressWarnings("WrongConstant")
     @org.junit.Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         when(mockContext.getPackageName()).thenReturn("com.example.app");
         underTest = new BroadcastQueryClient(mockContext);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
 
         ResolveInfo mockinfo1=new ResolveInfo();
         mockinfo1.activityInfo = new ActivityInfo();
         mockinfo1.activityInfo.packageName= "com.openyolo";
 
         ResolveInfo mockinfo2=new ResolveInfo();
         mockinfo2.activityInfo = new ActivityInfo();
         mockinfo2.activityInfo.packageName= "com.google";
 
         mPackageinfos = new ArrayList<>(2);
         mPackageinfos.add(mockinfo1);
         mPackageinfos.add(mockinfo2);
 
         when(mockPackageManager.queryBroadcastReceivers(any(Intent.class),
                 anyInt())).thenReturn(mPackageinfos);
+
+        testClientVersion = Protobufs.ClientVersion.newBuilder()
+                .setVendor("test")
+                .setMajor(1)
+                .setMinor(2)
+                .setPatch(3)
+                .build();
+
+        ClientVersionUtil.setClientVersion(testClientVersion);
+    }
+
+    @After
+    public void tearDown() {
+        ClientVersionUtil.setClientVersion(null);
     }
 
     @Test
     public void queryFor() throws Exception {
+
         String dataType = "datatype";
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = 500L;
         QueryCallback callback = new QueryCallback() {
             @Override
             public void onResponse(long queryId, List<QueryResponse> responses) {
                 //not expecting the callback as this is happening through broadcasts.
                 //if we get here, fail so it raises some eyebrows...
                 fail();
             }
         };
 
         underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
         verify(mockContext, times(1)).registerReceiver(any(BroadcastReceiver.class),
                 any(IntentFilter.class));
-        verify(mockContext, times(mPackageinfos.size())).sendBroadcast(any(Intent.class));
 
+        ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+        verify(mockContext, times(mPackageinfos.size())).sendBroadcast(intentCaptor.capture());
+
+        List<Intent> intents = intentCaptor.getAllValues();
+        assertThat(intents.size()).isEqualTo(2);
+
+        byte[] queryProtoBytes = intents.get(0).getByteArrayExtra(QueryUtil.EXTRA_QUERY_MESSAGE);
+        Protobufs.BroadcastQuery queryProto = Protobufs.BroadcastQuery.parseFrom(queryProtoBytes);
+
+        // check client version
+        assertThat(queryProto.hasClientVersion());
+        assertThat(queryProto.getClientVersion().getVendor())
+                .isEqualTo(testClientVersion.getVendor());
+        assertThat(queryProto.getClientVersion().getMajor())
+                .isEqualTo(testClientVersion.getMajor());
+        assertThat(queryProto.getClientVersion().getMinor())
+                .isEqualTo(testClientVersion.getMinor());
+        assertThat(queryProto.getClientVersion().getMinor())
+                .isEqualTo(testClientVersion.getMinor());
+
+        assertThat(queryProto.getDataType()).isEqualTo(dataType);
+        assertThat(queryProto.getQueryMessage().toByteArray()).isEqualTo(queryMessage);
     }
 
     @Test(expected = RequireViolation.class)
     public void queryFor_negative_timestamp() throws Exception {
         String dataType = "datatype";
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = -500L;
         QueryCallback callback = new QueryCallback() {
             @Override
             public void onResponse(long queryId, List<QueryResponse> responses) {
                 //not expecting the callback as this is happening through broadcasts.
                 //if we get here, fail so it raises some eyebrows...
                 fail();
             }
         };
 
         underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
     }
 
     @Test(expected = RequireViolation.class)
     public void queryFor_pushNullDatatype() throws Exception {
         String dataType = null;
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = 500L;
         QueryCallback callback = new QueryCallback() {
             @Override
             public void onResponse(long queryId, List<QueryResponse> responses) {
             }
         };
 
         underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
-
     }
 
     @Test(expected = RequireViolation.class)
     public void queryFor_pushNullCallback() throws Exception {
         String dataType = "datatype";
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = 500L;
         underTest.queryFor(dataType, queryMessage, timeoutInMs, null);
 
     }
 
 }
\ No newline at end of file
diff --git a/bbq/proto/bbq.proto b/bbq/proto/bbq.proto
index 7390a2a..d1763f7 100644
--- a/bbq/proto/bbq.proto
+++ b/bbq/proto/bbq.proto
@@ -24,19 +24,19 @@ option java_outer_classname = "Protobufs";
 message BroadcastQuery {
     // required - The BBQ client version.
-    ClientVersion version = 1;
+    ClientVersion clientVersion = 1;
 
     // required - the type of data to be discovered
     string dataType = 2;
 
     // required - the package name of the requesting app
     string requestingApp = 3;
 
     // required - a 64-bit random number for this request.
     sfixed64 requestId = 4;
 
     // required
     sfixed64 responseId = 5;
 
     bytes queryMessage = 6;
     map<string, bytes> additionalProps = 7;
 }
@@ -54,3 +54,13 @@ message BroadcastQueryResponse {
 message ClientVersion {
-    string version = 1;
-}
+    // required
+    string vendor = 1;
+
+    // required
+    uint32 major = 3;
+
+    // required
+    uint32 minor = 4;
+
+    // required
+    uint32 patch = 5;
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 1f84691..9c821d8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -20,17 +20,27 @@ buildscript {
 try {
     def grgit = org.ajoberstar.grgit.Grgit.open(dir: '.')
     def lastCommit = grgit.head()
 
     project.ext.versionNum = grgit.log(includes:['HEAD']).size()
     project.ext.versionDate = lastCommit.getDate()
     project.ext.versionName = grgit.describe()
+
+    def emptyValue = "\"\"";
     if (project.ext.versionName == null) {
         project.ext.versionName = "DEV"
+        project.ext.versionMajor = emptyValue
+        project.ext.versionMinor = emptyValue
+        project.ext.versionPatch = emptyValue
+    } else {
+        def parts = project.ext.versionName.split("[\\.-]")
+        project.ext.versionMajor = (parts.length > 0) ? parts[0] : emptyValue;
+        project.ext.versionMinor = (parts.length > 1) ? parts[1] : emptyValue;
+        project.ext.versionPatch = (parts.length > 2) ? parts[2] : emptyValue;
     }
 } catch (Exception ex) {
     logger.lifecycle(
         "unable to infer version information from git - using defaults")
     project.ext.versionNum = 0
     project.ext.versionDate = new Date()
     project.ext.versionName = 'DEV'
 }
diff --git a/protocol/build.gradle b/protocol/build.gradle
index 200c688..d5d53dd 100644
--- a/protocol/build.gradle
+++ b/protocol/build.gradle
@@ -5,3 +5,12 @@ apply from:'../config/protobuf.gradle'
 
-android.defaultConfig.project.archivesBaseName = 'data'
+android {
+    defaultConfig {
+        project.archivesBaseName = 'protocol'
+        consumerProguardFiles 'proguard-rules.txt'
+
+        buildConfigField('String', 'clientVersionMajor', rootProject.ext.versionMajor)
+        buildConfigField('String', 'clientVersionMinor', rootProject.ext.versionMinor)
+        buildConfigField('String', 'clientVersionPatch', rootProject.ext.versionPatch)
+    }
+}
 
diff --git a/protocol/java/org/openyolo/protocol/HintRequest.java b/protocol/java/org/openyolo/protocol/HintRequest.java
index a07439e..9275064 100644
--- a/protocol/java/org/openyolo/protocol/HintRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRequest.java
@@ -35,2 +35,3 @@ import org.openyolo.protocol.internal.AuthenticationMethodConverters;
 import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
 import org.openyolo.protocol.internal.CollectionConverter;
@@ -39,313 +40,314 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
 public class HintRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
     public static HintRequest forEmailAndPasswordAccount() {
         return new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws IOException if the hint request could not be decoded.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws IOException {
         if (hintRequestProtoBytes == null) {
             throw new IOException("Unable to decode hint request from null array");
         }
         return new HintRequest.Builder(
                 Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
                 .build();
     }
 
     private HintRequest(
             @NonNull Set<AuthenticationMethod> authMethods,
             @NonNull PasswordSpecification passwordSpec,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mPasswordSpec = passwordSpec;
         mAdditionalProperties = additionalParams;
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProperties;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8
      * encoded string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         require(key, notNullValue());
         if (mAdditionalProperties.containsKey(key)) {
             return new String(mAdditionalProperties.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         require(key, notNullValue());
         return mAdditionalProperties.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
+                .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                     CollectionConverter.convertMapValues(
                             mAdditionalProperties,
                             ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalProps = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          *
          * @see HintRequest#toProtocolBuffer()
          */
         public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setPasswordSpecification(
                     new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(
                 @NonNull AuthenticationMethod authMethod,
                 @NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
                 @NonNull AuthenticationMethod authMethod,
                 AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             require(authMethods, notNullValue());
             require(!authMethods.contains(null), "every authentication methods must be non-null");
             require(!authMethods.isEmpty(), "At least one authentication method must be specified");
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
             require(authenticationMethod, notNullValue());
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
             mAdditionalProps = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request with a string value, that
          * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
          * key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
             require(value, notNullValue());
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request, that will be encoded as
          * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
             mAdditionalProps.put(name, value);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             require(passwordSpec, notNullValue());
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRequest build() {
             return new HintRequest(
                     unmodifiableSet(mAuthMethods),
                     mPasswordSpec,
                     unmodifiableMap(mAdditionalProps));
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRequest> {
         @Override
         public HintRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new HintRequest.Builder(
                         Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRequest[] newArray(int size) {
             return new HintRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/RetrieveRequest.java b/protocol/java/org/openyolo/protocol/RetrieveRequest.java
index 838e5f3..6457d57 100644
--- a/protocol/java/org/openyolo/protocol/RetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/RetrieveRequest.java
@@ -40,2 +40,3 @@ import org.openyolo.protocol.internal.AuthenticationMethodConverters;
 import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.ClientVersionUtil;
 import org.openyolo.protocol.internal.CollectionConverter;
@@ -44,247 +45,248 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class RetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     @NonNull
     private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
     private RetrieveRequest(
             @NonNull Set<AuthenticationMethod> authMethods,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mAdditionalProps = additionalParams;
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(
             @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(
             @NonNull AuthenticationMethod... authenticationMethods) {
         return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * The set of authentication methods that the requestor supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         if (mAdditionalProps.containsKey(key)) {
             return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         return mAdditionalProps.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
+                .setClientVersion(ClientVersionUtil.getClientVersion())
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
                                 AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
      * Creates {@link RetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
         public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
             validate(requestProto, notNullValue(), IllegalArgumentException.class);
 
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
                             NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
          * @see RetrieveRequest#getAdditionalPropertyAsString(String)
          */
         public Builder addAdditionalProperty(
                 @NonNull String name,
                 @NonNull String value) {
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalProperty(String name, byte[] value) {
             validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link RetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public RetrieveRequest build() {
             return new RetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
     private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
 
         @Override
         public RetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new RetrieveRequest.Builder(
                         Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public RetrieveRequest[] newArray(int size) {
             return new RetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/ClientVersionUtil.java b/protocol/java/org/openyolo/protocol/internal/ClientVersionUtil.java
new file mode 100644
index 0000000..3aafe78
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/ClientVersionUtil.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+
+import org.openyolo.protocol.BuildConfig;
+import org.openyolo.protocol.Protobufs;
+
+/**
+ * Holds the client version that is built from the static configuration.
+ */
+public final class ClientVersionUtil {
+
+    private static final String VENDOR = "openid.net";
+
+    @NonNull
+    private static final Protobufs.ClientVersion BUILD_CLIENT_VERSION =
+            Protobufs.ClientVersion.newBuilder()
+                    .setVendor(VENDOR)
+                    .setMajor(parseVersionPart(BuildConfig.clientVersionMajor))
+                    .setMinor(parseVersionPart(BuildConfig.clientVersionMinor))
+                    .setPatch(parseVersionPart(BuildConfig.clientVersionPatch))
+                    .build();
+
+    private static Protobufs.ClientVersion sClientVersion;
+
+    /**
+     * Retrieve the client version, typically sourced from the static build information.
+     */
+    @NonNull
+    public static Protobufs.ClientVersion getClientVersion() {
+        Protobufs.ClientVersion clientVersion = sClientVersion;
+        if (clientVersion == null) {
+            clientVersion = BUILD_CLIENT_VERSION;
+            sClientVersion = clientVersion;
+        }
+
+        return clientVersion;
+    }
+
+    /**
+     * Overrides the client version, for testing purposes.
+     */
+    @VisibleForTesting
+    public static void setClientVersion(Protobufs.ClientVersion clientVersion) {
+        sClientVersion = clientVersion;
+    }
+
+    @VisibleForTesting
+    static int parseVersionPart(String versionPart) {
+        if (versionPart == null || versionPart.isEmpty()) {
+            return 0;
+        }
+
+        int versionNum;
+        try {
+            versionNum = Integer.parseInt(versionPart);
+        } catch (NumberFormatException ex) {
+            return 0;
+        }
+
+        if (versionNum < 0) {
+            return 0;
+        }
+
+        return versionNum;
+    }
+
+}
diff --git a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
index a92c9f4..4cc5b35 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
@@ -27,2 +27,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.internal.ClientVersionUtil;
 import org.robolectric.RobolectricTestRunner;
@@ -32,263 +33,290 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link HintRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRequest request = new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .addAdditionalProperty("a", new byte[] { 1, 2, 3})
                 .addAdditionalProperty("b", "hello")
                 .setPasswordSpecification(originalSpec)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
 
         assertThat(request.getAdditionalProperties())
                 .containsOnly(
                         entry("a", new byte[] {1, 2, 3}),
                         entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
 
         assertThat(request.getAdditionalProperty("a")).isEqualTo(new byte[] {1, 2, 3});
         assertThat(request.getAdditionalPropertyAsString("b")).isEqualTo("hello");
 
         assertThat(request.getAdditionalProperty("c")).isNull();
         assertThat(request.getAdditionalPropertyAsString("d")).isNull();
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRequest request = new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testForEmailAndPasswordAccount() {
         HintRequest request = HintRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
+    @Test
+    public void testToProtocolBuffer_includesClientVersion() {
+        String vendor = "test";
+        int major = 1;
+        int minor = 2;
+        int patch = 3;
+        ClientVersionUtil.setClientVersion(
+                Protobufs.ClientVersion.newBuilder()
+                        .setVendor(vendor)
+                        .setMajor(major)
+                        .setMinor(minor)
+                        .setPatch(patch)
+                        .build());
+
+        try {
+            HintRequest request = HintRequest.forEmailAndPasswordAccount();
+            Protobufs.HintRetrieveRequest proto = request.toProtocolBuffer();
+            assertThat(proto.hasClientVersion());
+            assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
+            assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
+            assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
+            assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
+        } finally {
+            ClientVersionUtil.setClientVersion(null);
+        }
+    }
+
     @Test
     public void testSerialize() {
         HintRequest request = new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRequest read = HintRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullRequestProto() {
         new HintRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullInVarargs() {
         new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.PHONE)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_emptySet() {
         new HintRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullMap() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(null)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullKey() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty(null, "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_emptyKey() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("", "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullByteArrayValue() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (byte[]) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullStringValue() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
index c128acd..16c6a6c 100644
--- a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
@@ -31,2 +31,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.internal.ClientVersionUtil;
 import org.robolectric.RobolectricTestRunner;
@@ -35,98 +36,126 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveRequestTest {
 
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
     private RetrieveRequest request;
 
     @Before
     public void setUp() {
         request = new RetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("a", "b")
                 .addAdditionalProperty("c", testBytes)
                 .build();
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
                     deserialized.getAdditionalProperties(),
                     request.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new RetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
         new RetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         RetrieveRequest request = RetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testGetAdditionalProperties() {
         assertThat(request.getAdditionalProperties()).isNotNull();
         assertThat(request.getAdditionalProperties()).hasSize(2);
         assertThat(request.getAdditionalPropertyAsString("a")).isEqualTo("b");
         assertThat(request.getAdditionalProperty("c")).isEqualTo(testBytes);
     }
 
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
         Protobufs.CredentialRetrieveRequest.parseFrom((byte[]) null);
     }
 
+    @Test
+    public void testToProtocolBuffer_includesClientVersion() {
+        String vendor = "test";
+        int major = 1;
+        int minor = 2;
+        int patch = 3;
+        ClientVersionUtil.setClientVersion(
+                Protobufs.ClientVersion.newBuilder()
+                        .setVendor(vendor)
+                        .setMajor(major)
+                        .setMinor(minor)
+                        .setPatch(patch)
+                        .build());
+
+        try {
+            RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(
+                    AuthenticationMethods.EMAIL);
+            Protobufs.CredentialRetrieveRequest proto = request.toProtocolBuffer();
+            assertThat(proto.hasClientVersion());
+            assertThat(proto.getClientVersion().getVendor()).isEqualTo(vendor);
+            assertThat(proto.getClientVersion().getMajor()).isEqualTo(major);
+            assertThat(proto.getClientVersion().getMinor()).isEqualTo(minor);
+            assertThat(proto.getClientVersion().getPatch()).isEqualTo(patch);
+        } finally {
+            ClientVersionUtil.setClientVersion(null);
+        }
+    }
+
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/internal/ClientVersionUtilTest.java b/protocol/javatests/org/openyolo/protocol/internal/ClientVersionUtilTest.java
new file mode 100644
index 0000000..69b52ce
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/internal/ClientVersionUtilTest.java
@@ -0,0 +1,40 @@
+package org.openyolo.protocol.internal;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ClientVersionUtilTest {
+
+    @Test
+    public void testParseVersionPart() {
+        assertThat(ClientVersionUtil.parseVersionPart("0")).isEqualTo(0);
+        assertThat(ClientVersionUtil.parseVersionPart("2")).isEqualTo(2);
+        assertThat(ClientVersionUtil.parseVersionPart("1024")).isEqualTo(1024);
+    }
+
+    @Test
+    public void testParseVersionPart_nullValue() {
+        assertThat(ClientVersionUtil.parseVersionPart(null)).isEqualTo(0);
+    }
+
+    @Test
+    public void testParseVersionPart_emptyValue() {
+        assertThat(ClientVersionUtil.parseVersionPart("")).isEqualTo(0);
+    }
+
+    @Test
+    public void testParseVersionPart_negativeValue() {
+        assertThat(ClientVersionUtil.parseVersionPart("-1")).isEqualTo(0);
+    }
+
+    @Test
+    public void testParseVersionPart_tooBigValue() {
+        assertThat(ClientVersionUtil.parseVersionPart("10000000000")).isEqualTo(0);
+    }
+}
diff --git a/protocol/proguard-rules.txt b/protocol/proguard-rules.txt
new file mode 100644
index 0000000..ca8d460
--- /dev/null
+++ b/protocol/proguard-rules.txt
@@ -0,0 +1,8 @@
+# valid4j use reflection to inject Providers and Policy
+-keep class org.valid4j.** { *; }
+
+# it is safe to ignore okio warnings
+-dontwarn okio.**
+
+# Hamcrest reflection
+-keep class org.hamcrest.** { *; }
\ No newline at end of file
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index 9b31b34..8adf913 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -24,7 +24,9 @@ option java_outer_classname = "Protobufs";
 message CredentialRetrieveRequest {
+    ClientVersion clientVersion = 1;
+
     // at least one authMethod required
-    repeated AuthenticationMethod authMethods = 1;
+    repeated AuthenticationMethod authMethods = 2;
 
     map<string, TokenRequestInfo> supportedTokenProviders = 3;
     map<string, bytes> additionalProps = 4;
 }
@@ -37,8 +39,10 @@ message CredentialRetrieveBbqResponse {
 message HintRetrieveRequest {
+    ClientVersion clientVersion = 1;
+
     // at least one authMethod required
-    repeated AuthenticationMethod authMethods = 1;
+    repeated AuthenticationMethod authMethods = 2;
 
-    PasswordSpecification passwordSpec = 2;
-    map<string, TokenRequestInfo> supportedTokenProviders = 3;
-    map<string, bytes> additionalProps = 4;
+    PasswordSpecification passwordSpec = 3;
+    map<string, TokenRequestInfo> supportedTokenProviders = 4;
+    map<string, bytes> additionalProps = 5;
 }
@@ -107 +111,15 @@ message TokenRequestInfo {
 }
+
+message ClientVersion {
+    // required
+    string vendor = 1;
+
+    // required
+    uint32 major = 2;
+
+    // required
+    uint32 minor = 3;
+
+    // required
+    uint32 patch = 4;
+}
\ No newline at end of file
diff --git a/spi/build.gradle b/spi/build.gradle
index 192fa00..05948d6 100644
--- a/spi/build.gradle
+++ b/spi/build.gradle
@@ -4,6 +4,10 @@ apply from:'../config/android-common.gradle'
 android {
     defaultConfig {
         project.archivesBaseName = 'openyolo-spi'
         consumerProguardFiles 'proguard-rules.txt'
+
+        buildConfigField('String', 'spiVersionMajor', rootProject.ext.versionMajor)
+        buildConfigField('String', 'spiVersionMinor', rootProject.ext.versionMinor)
+        buildConfigField('String', 'spiVersionPatch', rootProject.ext.versionPatch)
     }
 }

commit 73dd2e902c640e19838c88789094050ffa9632d2
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu Apr 27 14:11:31 2017 -0700

    Introduction of AuthenticationMethod/Domain model types and protos
    
    This is the first step in migrating to the protocol buffers in the
    the OpenYOLO for Android spec. Many more to come.

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 34edea0..54b89d1 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -27,3 +27,2 @@ import android.content.Intent;
 import android.content.pm.ResolveInfo;
-import android.net.Uri;
 import android.support.annotation.NonNull;
@@ -45,2 +44,3 @@ import org.openyolo.protocol.HintRequest;
 import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
 import org.openyolo.protocol.RetrieveRequest;
@@ -50,326 +50,317 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRequest request) {
-        List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION, null);
+        List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
         if (preferredProviderActivity != null) {
             return createHintIntent(preferredProviderActivity, encodedRequest);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final RetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
-                findProviders(SAVE_CREDENTIAL_ACTION, credentialToSave.getAuthenticationMethod());
+                findProviders(SAVE_CREDENTIAL_ACTION);
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
-        byte[] encodedCredential = credentialToSave.getProto().toByteArray();
+        byte[] encodedCredential = credentialToSave.toProtobuf().toByteArray();
 
         // if there is a preferred provider, directly invoke it.
         ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
         if (preferredSaveActivity != null) {
             return createSaveIntent(
                     preferredSaveActivity,
-                    credentialToSave.getAuthenticationMethod(),
                     encodedCredential);
         }
 
         // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             saveIntents.add(createSaveIntent(
                     providerActivity,
-                    credentialToSave.getAuthenticationMethod(),
                     encodedCredential));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
         Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
         hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
         return hintIntent;
     }
 
     private Intent createSaveIntent(
             ComponentName providerActivity,
-            Uri authenticationMethod,
             byte[] saveRequest) {
         Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
-        saveIntent.setData(authenticationMethod);
         saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
         return saveIntent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @Nullable
     public Credential getCredentialFromActivityResult(@Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, exiting (returning null)");
             return null;
         }
 
         if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
             Log.i(LOG_TAG, "credential data missing from response");
             return null;
         }
 
         byte[] credentialBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
         if (credentialBytes == null) {
             Log.i(LOG_TAG, "No credential found in response");
             return null;
         }
 
         Protobufs.Credential credentialProto;
         try {
             credentialProto = Protobufs.Credential.parseFrom(credentialBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "failed to decode credential from response data");
             return null;
         }
 
         try {
             return new Credential.Builder(credentialProto).build();
         } catch (IllegalArgumentException ex) {
             Log.e(LOG_TAG, "validation of received credential failed", ex);
             return null;
         }
     }
 
-    private List<ComponentName> findProviders(
-            @NonNull String action,
-            @Nullable Uri data) {
+    private List<ComponentName> findProviders(@NonNull String action) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
-        if (data != null) {
-            saveIntent.setData(data);
-        }
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     @Nullable
     private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
         // In the future, the user will be able to explicitly set their preferred provider in
         // their device settings. For now, we heuristically determine the preferred provider based
         // on the following rules:
 
         // 1. If there are any unknown providers on the device, there is no preferred provider.
         List<ComponentName> knownProviders = filterToKnownProviders(providers);
         if (knownProviders.size() != providers.size()) {
             return null;
         }
 
         // 2. If there are no known providers, then there is no preferred provider. Unknown
         // providers are not trusted for automatic usage.
         if (knownProviders.isEmpty()) {
             return null;
         }
 
         // 3. If there is exactly one provider on the device and it is known,
         // it is the preferred provider.
         if (knownProviders.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 3. If there are exactly two known providers on the device, and one of them is Google,
         // choose the other one.
         // This reflects the reality that Google is pre-installed on most devices, whereas a second
         // provider would likely have been explicitly installed by the user - it is likely that
         // their intent is to use this other provider.
         providers = filterOutGoogle(knownProviders);
         if (providers.size() == 1) {
             return knownProviders.get(0);
         }
 
         // 4. Otherwise, there is no preferred provider.
         return null;
     }
 
     private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
         KnownProviders knownProviders =
                 KnownProviders.getApplicationBoundInstance(mApplicationContext);
 
         ArrayList<ComponentName> filteredProviders = new ArrayList<>();
         for (ComponentName provider : providers) {
             if (knownProviders.isKnown(provider.getPackageName())) {
                 filteredProviders.add(provider);
             }
         }
 
         return filteredProviders;
     }
 
     private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
         Iterator<ComponentName> providerIter = providers.iterator();
         while (providerIter.hasNext()) {
             ComponentName provider = providerIter.next();
             if (provider.getPackageName().equals(
                     KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
                 providerIter.remove();
             }
         }
 
         return providers;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
-            Map<String, Protobufs.CredentialRetrieveResponse> protoResponses = new HashMap<>();
+            Map<String, CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
-                Protobufs.CredentialRetrieveResponse response;
+                Protobufs.CredentialRetrieveBbqResponse response;
                 try {
-                    response = Protobufs.CredentialRetrieveResponse.parseFrom(
+                    response = Protobufs.CredentialRetrieveBbqResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveResult.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index d274bd3..1868c30 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -50,289 +50,289 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
 
     private static final String EMAIL_ID = "alice@example.com";
     private static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
 
     private static final String DASHLANE =
             KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
 
     private static final String ONEPASSWORD =
             KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
 
     private static final String GOOGLE =
             KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
 
     private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
 
     private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
 
     @Mock
     private Context mockContext;
 
     @Mock
     private PackageManager mockPackageManager;
 
     @Mock
     private KnownProviders mockKnownProviders;
 
     private CredentialClient credentialClient;
     private Credential testCredential;
 
     private ArrayList<ResolveInfo> installedProviders;
 
     @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         installedProviders = new ArrayList<>();
 
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
 
         testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
 
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(installedProviders);
 
         KnownProviders.setApplicationBoundInstance(mockKnownProviders);
 
         credentialClient = new CredentialClient(mockContext);
         testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
     }
 
     @After
     public void tearDown() throws Exception {
         KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noProviders() throws Exception {
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
                 .thenReturn(Collections.<ResolveInfo>emptyList());
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         assertThat(hintIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetHintIntent_noKnownProviders() throws Exception {
         addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
         Intent hintIntent = credentialClient.getHintRetrieveIntent(
                 HintRequest.forEmailAndPasswordAccount());
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         assertThat(hintIntent).isNotNull();
         assertThat(hintIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void testGetSaveIntent_noProviders() throws Exception {
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNull();
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_singleKnownProvider() throws Exception {
         addKnownProviders(DASHLANE);
 
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_unknownProviderPresent() throws Exception {
         addKnownProviders(DASHLANE);
         addUnknownProviders(UNKNOWN_PROVIDER_1);
 
         // with an unknown provider, the heuristic determines is no preferred provider.
         // Therefore a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
         addKnownProviders(DASHLANE, GOOGLE);
 
         // due to the preferred provider selection heuristics, we expect that Dashlane will be
         // selected for direct invocation.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD);
 
         // as there are two known providers, and neither is Google, the preferred provider
         // heuristics should determine there are no preferred providers. Therefore, a provider
         // picker should be launched.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_threeKnownProviders() throws Exception {
         addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
 
         // with three known providers, the preferred provider heuristic determines there is no
         // preferred provider. Therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent_noKnownProviders() throws Exception {
         addUnknownProviders("com.example.superpassword", "com.example.locker");
 
         // With no known providers, the preferred provider heuristic will determine there is no
         // preferred provider. therefore, a provider picker should be displayed.
         Intent saveIntent = credentialClient.getSaveIntent(testCredential);
         assertThat(saveIntent).isNotNull();
         assertThat(saveIntent.getComponent().getClassName())
                 .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialFromActivityResult_noExtras() throws Exception {
         Intent intent = new Intent();
         Credential result = credentialClient.getCredentialFromActivityResult(intent);
         assertNull(result);
     }
 
     @Test
     public void getCredentialFromActivityResult_withExtras() throws Exception {
         Intent intent = new Intent();
-        byte[] array = testCredential.getProto().toByteArray();
+        byte[] array = testCredential.toProtobuf().toByteArray();
         intent.putExtra(EXTRA_CREDENTIAL, array);
         Credential result = credentialClient.getCredentialFromActivityResult(intent);
         assertEquals(result.getIdentifier(), "alice@example.com");
         assertEquals(result.getAuthenticationMethod(), AuthenticationMethods.EMAIL);
         assertEquals(result.getAuthenticationDomain(), AUTH_DOMAIN);
     }
 
     private ResolveInfo createResolveInfo(String packageName, String name) {
         ResolveInfo resolveInfo = new ResolveInfo();
         ActivityInfo activityInfo = new ActivityInfo();
         activityInfo.packageName = packageName;
         activityInfo.name =  name;
         resolveInfo.activityInfo = activityInfo;
 
         return resolveInfo;
     }
 
     private void addKnownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
         }
     }
 
     private void addUnknownProviders(String... packageNames) {
         for (String packageName : packageNames) {
             installedProviders.add(createResolveInfo(packageName, packageName));
             when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
         }
     }
 }
\ No newline at end of file
diff --git a/bbq/proto/bbq.proto b/bbq/proto/bbq.proto
index 47b4935..7390a2a 100644
--- a/bbq/proto/bbq.proto
+++ b/bbq/proto/bbq.proto
@@ -24,9 +24,19 @@ option java_outer_classname = "Protobufs";
 message BroadcastQuery {
-    string   dataType      = 1; // required
-    string   requestingApp = 2; // required
-    sfixed64 requestId     = 3; // required
-    sfixed64 responseId    = 4; // required
-    bytes    queryMessage  = 5;
+    // required - The BBQ client version.
+    ClientVersion version = 1;
 
-    map<string, bytes> additionalProps = 6;
+    // required - the type of data to be discovered
+    string dataType = 2;
+
+    // required - the package name of the requesting app
+    string requestingApp = 3;
+
+    // required - a 64-bit random number for this request.
+    sfixed64 requestId = 4;
+
+    // required
+    sfixed64 responseId = 5;
+
+    bytes queryMessage = 6;
+    map<string, bytes> additionalProps = 7;
 }
@@ -34,12 +44,13 @@ message BroadcastQuery {
 message BroadcastQueryResponse {
-    sfixed64 requestId       = 1; // required
-    sfixed64 responseId      = 2; // required
-    bytes    responseMessage = 3;
+    // required
+    sfixed64 requestId = 1;
+    // required
+    sfixed64 responseId = 2;
+    bytes responseMessage = 3;
 
     map<string, bytes> additionalProps = 4;
 }
 
-message Parameter {
-    string name  = 1; // required
-    bytes  value = 2;
+message ClientVersion {
+    string version = 1;
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
index 0ed84dc..d7b552f 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
@@ -48,256 +48,256 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.Credential;
 
 /**
  * Creates credentials from manual user input for storage.
  */
 public class CreateCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "CreateCredential";
 
     private static final int MIN_ID_LENGTH = 1;
     private static final int MIN_PASS_LENGTH = 1;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.headerToolbar)
     Toolbar mToolbar;
 
     @BindView(R.id.appBar)
     AppBarLayout mAppBar;
 
     @BindView(R.id.credential_authority)
     Spinner mCredentialAuthority;
 
     @BindView(R.id.credential_id)
     EditText mCredentialId;
 
     @BindView(R.id.credential_password)
     EditText mCredentialPassword;
 
     private MenuItem mDoneButton;
 
     private CredentialStorageClient mStorageClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.create_credential_layout);
         ButterKnife.bind(this);
         getSupportActionBar();
         setSupportActionBar(mToolbar);
         mToolbar.setNavigationIcon(R.drawable.back);
         mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 finish();
             }
         });
         mCredentialAuthority.setAdapter(new AppAdapter(getInstalledApps()));
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.menu_create, menu);
         mDoneButton = menu.findItem(R.id.action_done);
         onFieldsChanged();
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (super.onOptionsItemSelected(item)) {
             return true;
         }
 
         if (R.id.action_done == item.getItemId()) {
             App app = (App) mCredentialAuthority.getSelectedItem();
             String username = mCredentialId.getText().toString();
             String password = mCredentialPassword.getText().toString();
             new StoreCredentialTask(app.mPackageName, username, password).execute();
         }
 
         return false;
     }
 
     @OnItemSelected(R.id.credential_authority)
     @OnTextChanged({R.id.credential_id, R.id.credential_password})
     void onFieldsChanged() {
         boolean validCredential =
                 mCredentialAuthority.getSelectedItemPosition() != Spinner.INVALID_POSITION
                 && mCredentialId.length() >= MIN_ID_LENGTH
                 && mCredentialPassword.length() >= MIN_PASS_LENGTH;
 
         if (mDoneButton != null) {
             mDoneButton.setEnabled(validCredential);
         }
     }
 
     private List<App> getInstalledApps() {
         List<String> appPackageNames = InstalledAppsUtil.getInstalledAppsList(this);
         ArrayList<App> apps = new ArrayList<>();
         PackageManager pm = getPackageManager();
         for (String packageName : appPackageNames) {
             try {
                 ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                 String appName = pm.getApplicationLabel(info).toString();
                 Drawable appIcon = pm.getApplicationIcon(info);
                 apps.add(new App(packageName, appName, appIcon));
             } catch (PackageManager.NameNotFoundException e) {
                 // skip this app
             }
         }
 
         return apps;
     }
 
     private class StoreCredentialTask extends AsyncTask<Void, Void, Boolean> {
 
         final String mPackageName;
         final String mUsername;
         final String mPassword;
 
         StoreCredentialTask(String packageName, String username, String password) {
             mPackageName = packageName;
             mUsername = username;
             mPassword = password;
         }
 
         @Override
         protected Boolean doInBackground(Void... params) {
             AuthenticationDomain domain = AuthenticationDomain.listForPackage(
                     CreateCredentialActivity.this,
                     mPackageName)
                     .get(0);
 
-            Credential credential = Credential.newBuilder()
-                    .setId(mUsername)
-                    .setAuthDomain(domain.toString())
-                    .setAuthMethod(AuthenticationMethods.EMAIL.toString())
+            Credential credential = new Credential.Builder(
+                    mUsername,
+                    AuthenticationMethods.EMAIL,
+                    domain)
                     .setPassword(mPassword)
                     .build();
             try {
-                mStorageClient.upsertCredential(credential);
+                mStorageClient.upsertCredential(credential.toProtobuf());
                 return true;
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to upsert credential to database");
             }
             return null;
         }
 
         @Override
         protected void onPostExecute(Boolean success) {
             if (success) {
                 finish();
             } else {
                 Snackbar.make(
                         mRootView,
                         R.string.save_failed,
                         Snackbar.LENGTH_SHORT).show();
             }
         }
     }
 
     private class App implements Comparable<App> {
         @NonNull String mName;
         @NonNull String mPackageName;
         @Nullable Drawable mIcon;
 
         App(@NonNull String packageName, @NonNull String name, @Nullable Drawable icon) {
             mPackageName = packageName;
             mName = name;
             mIcon = icon;
         }
 
         @Override
         public int compareTo(@NonNull App app) {
             return mName.compareTo(app.mName);
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (!(obj instanceof App)) {
                 return false;
             }
 
             App other = (App) obj;
             return mPackageName.equals(other.mPackageName);
         }
 
         @Override
         public int hashCode() {
             return mPackageName.hashCode();
         }
     }
 
     private class AppAdapter extends BaseAdapter {
 
         private final List<App> mApps;
         private final LayoutInflater mInflater;
 
         AppAdapter(@NonNull List<App> apps) {
             mApps = apps;
             mInflater = LayoutInflater.from(CreateCredentialActivity.this);
         }
 
         @Override
         public int getCount() {
             return mApps.size();
         }
 
         @Override
         public Object getItem(int index) {
             return mApps.get(index);
         }
 
         @Override
         public long getItemId(int index) {
             return mApps.get(index).hashCode();
         }
 
         @Override
         public View getView(int index, View view, ViewGroup viewGroup) {
             App app = mApps.get(index);
             if (view == null) {
                 view = mInflater.inflate(R.layout.app_item, viewGroup, false);
             }
 
             ImageView iconView = (ImageView) view.findViewById(R.id.app_icon);
             if (app.mIcon != null) {
                 iconView.setImageDrawable(app.mIcon);
                 iconView.setVisibility(View.VISIBLE);
             } else {
                 iconView.setVisibility(View.INVISIBLE);
             }
 
             TextView nameView = (TextView) view.findViewById(R.id.app_name);
             nameView.setText(app.mName);
 
             return view;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
index 8568ae3..6572139 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
@@ -35,110 +35,111 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * RecyclerView adapter for displaying stored credentials.
  */
 class CredentialAdapter
         extends RecyclerView.Adapter<CredentialAdapter.ViewHolder> {
 
     private List<Credential> mCredentials;
     private CredentialStorageClient mClient;
 
     CredentialAdapter() {
         mCredentials = Collections.emptyList();
     }
 
     void setCredentials(List<Credential> credentials) {
         mCredentials = credentials;
         notifyDataSetChanged();
     }
 
     @Override
     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
         View credentialView = LayoutInflater.from(parent.getContext())
                 .inflate(R.layout.credential_view, parent, false);
 
         return new ViewHolder(credentialView);
     }
 
     @Override
     public void onBindViewHolder(ViewHolder holder, int position) {
         holder.bind(mCredentials.get(position));
     }
 
     @Override
     public int getItemCount() {
         return mCredentials.size();
     }
 
     void setCredentialStorageClient(CredentialStorageClient credentialStorageClient) {
         mClient = credentialStorageClient;
     }
 
     final class ViewHolder extends RecyclerView.ViewHolder {
 
         private TextView mAuthorityView;
         private ImageView mAuthorityIconView;
         private TextView mIdView;
 
         ViewHolder(View itemView) {
             super(itemView);
 
             mAuthorityView = (TextView) itemView.findViewById(R.id.credential_authority);
             mAuthorityIconView = (ImageView) itemView.findViewById(R.id.credential_authority_icon);
             mIdView = (TextView) itemView.findViewById(R.id.credential_id);
         }
 
         void bind(final Credential credential) {
-            String appLabel = credential.getAuthDomain();
+            String appLabel = credential.getAuthDomain().toString();
             Drawable appIcon = null;
 
-            AuthenticationDomain domain = new AuthenticationDomain(credential.getAuthDomain());
+            AuthenticationDomain domain =
+                    AuthenticationDomain.fromProtobuf(credential.getAuthDomain());
             if (domain.isAndroidAuthDomain()) {
                 String packageName = domain.getAndroidPackageName();
                 PackageManager pm = itemView.getContext().getPackageManager();
                 try {
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     appLabel = pm.getApplicationLabel(info).toString();
                     appIcon = pm.getApplicationIcon(info);
                 } catch (PackageManager.NameNotFoundException e) {
                     // will just show the raw info
                 }
             }
 
             mAuthorityView.setText(appLabel);
             mIdView.setText(credential.getId());
 
             if (appIcon != null) {
                 mAuthorityIconView.setImageDrawable(appIcon);
                 mAuthorityIconView.setVisibility(View.VISIBLE);
             } else {
                 mAuthorityIconView.setVisibility(View.INVISIBLE);
             }
 
             itemView.setOnLongClickListener(new View.OnLongClickListener() {
                 @Override
                 public boolean onLongClick(View view) {
                     AlertDialog dialog = new AlertDialog.Builder(itemView.getContext())
                             .setTitle(R.string.ask_delete_credential)
                             .setPositiveButton(R.string.openyolo_simple_yes,
                                     new DialogInterface.OnClickListener() {
                                         @Override
                                         public void onClick(DialogInterface dialogInterface,
                                                             int which) {
                                             try {
                                                 mClient.deleteCredential(credential);
                                                 mCredentials.remove(credential);
                                                 notifyDataSetChanged();
                                             } catch (IOException e) {
                                                 e.printStackTrace();
                                             }
                                         }
                                     })
                             .setNegativeButton(R.string.openyolo_simple_no, null)
                             .create();
 
                     dialog.show();
                     return true;
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
index 14b60eb..32f45ba 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
@@ -16,3 +16,2 @@ package org.openyolo.demoprovider.barbican;
 
-import android.net.Uri;
 import android.support.annotation.Nullable;
@@ -21,87 +20,123 @@ import java.util.Comparator;
 import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.Protobufs;
 
 /**
  * Derives quality scores for credentials and hints that can help to order lists of them based on
  * how useful they are to an application.
  */
 public class CredentialQualityScore {
 
     /**
      * A comparator which orders credentials in descending order of quality score, i.e. those with
      * the highest quality score first.
      */
     public static final Comparator<Credential> QUALITY_SORT = new CredentialQualityComparator();
 
+    /**
+     * A comparator which orders credential protocol buffers in descending order of quality score,
+     * i.e. those with the highest quality score first.
+     */
+    public static final Comparator<Protobufs.Credential> PROTO_QUALITY_SORT =
+            new CredentialProtoQualityComparator();
+
     /**
      * Generates the score for the user data in an account hint.
      */
     public static int getScore(AccountHint hint) {
         return getQualityScore(
-            hint.getIdentifier(),
-            hint.getAuthMethod(),
-            hint.getName(),
-            hint.getPictureUri());
+                hint.getIdentifier(),
+                new AuthenticationMethod(hint.getAuthMethod()),
+                hint.getName(),
+                hint.getPictureUri());
     }
 
     /**
-     * Generates the score for the user data in a credential.
+     * Generates the score for the user data in a credential protocol buffer.
      */
-    public static int getScore(Credential credential) {
+    public static int getScore(Protobufs.Credential credential) {
         return getQualityScore(
                 credential.getId(),
-                credential.getAuthMethod(),
+                AuthenticationMethod.fromProtobuf(credential.getAuthMethod()),
                 credential.getDisplayName(),
                 credential.getDisplayPictureUri());
     }
 
+    /**
+     * Generates the score for the user data in a credential.
+     */
+    public static int getScore(Credential credential) {
+        return getQualityScore(
+                credential.getIdentifier(),
+                credential.getAuthenticationMethod(),
+                credential.getDisplayName(),
+                credential.getDisplayPicture() != null
+                        ? credential.getDisplayPicture().toString()
+                        : null);
+    }
+
     private static int getQualityScore(
             @Nullable String id,
-            @Nullable String authMethod,
+            @Nullable AuthenticationMethod authMethod,
             @Nullable String name,
             @Nullable String pictureUri) {
 
         int score = 1;
 
         // email identifiers are recognisable and useful for ID token acquisition
-        if (AuthenticationMethods.EMAIL.toString().equals(authMethod)) {
-            score <<= 1;
-        }
-
-        // prefer federated authentication methods, which generally have an HTTPS scheme
-        if ("https".equals(Uri.parse(authMethod).getScheme())) {
+        if (AuthenticationMethods.EMAIL.equals(authMethod)) {
             score <<= 1;
         }
 
         // prefer credentials that have a human readable name
         if (!TextUtils.isEmpty(name)) {
             score <<= 1;
         }
 
         // prefer credentials that have a profile picture
-        if (!TextUtils.isEmpty(pictureUri)) {
+        if (pictureUri != null) {
             score <<= 1;
         }
 
         return score;
     }
 
     private static final class CredentialQualityComparator implements Comparator<Credential> {
 
         @Override
         public int compare(Credential c1, Credential c2) {
             int c1Score = getScore(c1);
             int c2Score = getScore(c2);
 
             // higher scores (more information) come first
             if (c1Score > c2Score) {
                 return -1;
             } else if (c1Score == c2Score) {
                 return 0;
             }
 
             return 1;
         }
     }
+
+    private static final class CredentialProtoQualityComparator
+            implements Comparator<Protobufs.Credential> {
+
+        @Override
+        public int compare(Protobufs.Credential c1, Protobufs.Credential c2) {
+            int c1Score = getScore(c1);
+            int c2Score = getScore(c2);
+
+            // higher scores (more information) come first
+            if (c1Score > c2Score) {
+                return -1;
+            } else if (c1Score == c2Score) {
+                return 0;
+            }
+
+            return 1;
+        }
+    }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index 7314954..42db1ec 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -46,145 +46,145 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(Context context, List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
         intent.putExtra(EXTRA_CREDENTIALS,
                 CredentialList.newBuilder()
                         .addAllCredentials(credentials)
                         .build()
                         .toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResult(RESULT_CANCELED);
             finish();
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Credential> credentials =
                     new ArrayList<>(CredentialList.parseFrom(credentialBytes).getCredentialsList());
-            Collections.sort(credentials, CredentialQualityScore.QUALITY_SORT);
+            Collections.sort(credentials, CredentialQualityScore.PROTO_QUALITY_SORT);
             return credentials;
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new CredentialViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(CredentialViewHolder holder, int position) {
             holder.bind(mCredentials.get(position));
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
     }
 
     private final class CredentialViewHolder extends RecyclerView.ViewHolder {
 
         private ImageView mProfileIcon;
         private TextView mPrimaryLabel;
         private TextView mSecondaryLabel;
 
         CredentialViewHolder(View itemView) {
             super(itemView);
 
             mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
             mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
             mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
         }
 
         void bind(final Credential credential) {
 
             int iconId;
             if (AuthenticationMethods.EMAIL.toString().equals(credential.getAuthMethod())) {
                 iconId = R.drawable.email;
             } else if (AuthenticationMethods.PHONE.toString().equals(credential.getAuthMethod())) {
                 iconId = R.drawable.phone;
             } else {
                 iconId = R.drawable.person;
             }
 
             if (credential.getDisplayPictureUri() != null) {
                 Uri displayPictureUri = Uri.parse(credential.getDisplayPictureUri());
                 Glide.with(CredentialPickerActivity.this)
                         .load(displayPictureUri)
                         .fitCenter()
                         .fallback(iconId)
                         .into(mProfileIcon);
             } else {
                 mProfileIcon.setImageResource(iconId);
             }
 
             if (credential.getDisplayName() != null) {
                 mPrimaryLabel.setText(credential.getDisplayName());
                 mSecondaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.VISIBLE);
             } else {
                 mPrimaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.GONE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     Intent responseData =
                             RetrieveIntentResultUtil.createResponseData(credential);
                     setResult(RESULT_OK, responseData);
                     finish();
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
index ef9db2c..7170002 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
@@ -28,3 +28,3 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorage;
 import org.openyolo.protocol.AuthenticationDomain;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveResponse;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
 import org.openyolo.protocol.RetrieveRequest;
@@ -34,65 +34,65 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Implements the OpenYOLO credential query receiver. This receiver is able to determine whether
  * a credential exists for the claimed set of authentication domains without unlocking the
  * password store.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull final Context context,
             @NonNull final BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // NOTE: in a more complete implementation, this is where we would expand the set of
         // authentication domains listed in requestorDomains to all equivalent authentication
         // domains (such as affiliated apps and sites). This potentially larger list would then be
         // matched against the requested set of domains.
 
         Log.i(LOG_TAG, "Processing query for " + query.getRequestingApp());
 
         CredentialStorage storage;
         try {
             storage = new CredentialStorage(context);
         }  catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to open credential storage", ex);
             responseSender.sendResponse(query, null);
             return;
         }
 
         boolean credentialsFound = false;
         byte[] responseBytes = null;
 
         Iterator<AuthenticationDomain> authDomainIter = requestorDomains.iterator();
         while (!credentialsFound && authDomainIter.hasNext()) {
             credentialsFound = storage.hasCredentialFor(authDomainIter.next().toString());
         }
 
         Log.d(LOG_TAG, "Credentials found for "
                 + query.getRequestingApp() + ": "
                 + credentialsFound);
 
         if (credentialsFound) {
             Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context);
-            CredentialRetrieveResponse response = CredentialRetrieveResponse.newBuilder()
+            CredentialRetrieveBbqResponse response = CredentialRetrieveBbqResponse.newBuilder()
                     .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
                     .build();
             responseBytes = response.toByteArray();
         }
 
         responseSender.sendResponse(query, responseBytes);
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
index df62fb9..ede3289 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
@@ -18,3 +18,2 @@ import android.content.ComponentName;
 import android.content.Intent;
-import android.net.Uri;
 import android.os.Bundle;
@@ -31,2 +30,3 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
@@ -37,138 +37,139 @@ import org.openyolo.protocol.ProtocolConstants;
 public class HintActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "HintActivity";
 
     private HintRequest mRequest;
     private AuthenticationDomain mCallerAuthDomain;
     private CredentialStorageClient mClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (!getIntent().hasExtra(ProtocolConstants.EXTRA_HINT_REQUEST)) {
             Log.w(LOG_TAG, "No hint request object found in the intent");
             finish(RESULT_CANCELED);
             return;
         }
 
         try {
             mRequest = HintRequest.fromProtoBytes(
                     getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_HINT_REQUEST));
         } catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
             finish(RESULT_CANCELED);
             return;
         }
 
         if (!extractCallerAuthDomain()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
             finish(RESULT_CANCELED);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
 
         if (!mClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
             finish(RESULT_CANCELED);
             return;
         }
 
         // some credential provider implementations may require an unlock to retrieve the
         // information required for hints, but for Barbican we instead choose to store basic
         // profile information usable for hints in plain text. With root access, this information
         // would be retrievable by malicious applications on the device, representing a privacy
         // risk. However, full credentials and associations between account identifiers
         // remain encrypted.
 
         List<AccountHint> hints;
         try {
             hints = mClient.getHints();
         } catch (IOException ex) {
             Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
             finish(RESULT_CANCELED);
             return;
         }
 
         // filter the credentials to just those which are pertinent to the request. For those
         // selected, turn them into credentials. Order the hints by the amount of information
         // they contain (so more complete items are displayed first), and then alphabetically.
         ArrayList<Credential> filteredHints = new ArrayList<>();
         for (AccountHint hint : hints) {
-            Set<Uri> authMethods = mRequest.getAuthenticationMethods();
-            if (!authMethods.contains(Uri.parse(hint.getAuthMethod()))) {
+            AuthenticationMethod hintAuthMethod = new AuthenticationMethod(hint.getAuthMethod());
+            Set<AuthenticationMethod> authMethods = mRequest.getAuthenticationMethods();
+            if (!authMethods.contains(hintAuthMethod)) {
                 continue;
             }
 
             Credential.Builder hintCredentialBuilder = Credential.newBuilder()
                     .setId(hint.getIdentifier())
-                    .setAuthMethod(hint.getAuthMethod())
-                    .setAuthDomain(mCallerAuthDomain.toString())
+                    .setAuthMethod(hintAuthMethod.toProtobuf())
+                    .setAuthDomain(mCallerAuthDomain.toProtobuf())
                     .setDisplayName(hint.getName())
                     .setDisplayPictureUri(hint.getPictureUri());
 
             // include a generated password if appropriate
             if (hint.getAuthMethod().equals(AuthenticationMethods.EMAIL.toString())) {
                 hintCredentialBuilder.setPassword(mRequest.getPasswordSpecification().generate());
             }
 
             filteredHints.add(hintCredentialBuilder.build());
         }
 
         // if there are no hints, immediately end the request
         if (filteredHints.isEmpty()) {
             finish(RESULT_CANCELED);
             return;
         }
 
         // otherwise, display the standard credential picker.
         Intent pickerIntent = CredentialPickerActivity.createIntent(
                 this,
                 filteredHints);
         pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(pickerIntent);
         finish();
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private boolean extractCallerAuthDomain() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         String callingPackage = callingActivity.getPackageName();
         List<AuthenticationDomain> authDomains =
                 AuthenticationDomain.listForPackage(this, callingPackage);
 
         if (authDomains.isEmpty()) {
             return false;
         }
 
         mCallerAuthDomain = authDomains.get(0);
         return true;
     }
 
     @UiThread
     private void finish(int resultCode) {
         setResult(resultCode);
         finish();
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
index 5ff69e6..174f5b4 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -38,138 +38,138 @@ import org.openyolo.protocol.Credential;
 /**
  * Confirms with the user whether they want to save a credential provided by the
  * calling app. Verification of the app's right to save such a credential occurs
  * in {@link SaveCredentialActivity} before reaching this point.
  */
 public class SaveCredentialConfirmationActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
     private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
 
     @BindView(R.id.save_prompt)
     TextView mSavePromptView;
 
     private Credential mCredential;
     private String mCallingAppName;
 
     private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
     private final CountDownLatch mClientConnected = new CountDownLatch(1);
 
     /**
      * Creates an intent to confirm whether the user wishes to save the specified credential.
      */
     public static Intent createIntent(
             Context context,
             String callingPackage,
             Credential credential) {
         Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
         intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
-        intent.putExtra(EXTRA_CREDENTIAL, credential.getProto().toByteArray());
+        intent.putExtra(EXTRA_CREDENTIAL, credential.toProtobuf().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mCredential = Credential.fromProtoBytes(
                     getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
         } catch (IOException e) {
             Log.e(LOG_TAG, "Unable to decode credential", e);
             finish(RESULT_CANCELED);
         }
 
         try {
             PackageManager pm = getPackageManager();
             ApplicationInfo info = pm.getApplicationInfo(getCallingPackage(), 0);
             mCallingAppName = pm.getApplicationLabel(info).toString();
         } catch (PackageManager.NameNotFoundException e) {
             e.printStackTrace();
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 mClient.set(client);
                 mClientConnected.countDown();
             }
         });
 
         setContentView(R.layout.save_layout);
         ButterKnife.bind(this);
 
         String savePromptTemplate = getString(R.string.save_prompt_template);
         mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
     }
 
     private void finish(int resultCode) {
         setResult(resultCode);
         finish();
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         CredentialStorageClient client = mClient.get();
         if (client != null) {
             client.disconnect(this);
         }
     }
 
     @OnClick(R.id.save_button)
     void onSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
             finish(RESULT_CANCELED);
             return;
         }
 
         if (client.isUnlocked()) {
             try {
-                client.upsertCredential(mCredential.getProto());
+                client.upsertCredential(mCredential.toProtobuf());
                 finish(RESULT_OK);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to write credential to storage");
                 finish(RESULT_CANCELED);
             }
         } else {
             Intent saveAfterUnlock = UnlockActivity.createIntent(
                     this,
                     true,
-                    SaveAfterUnlockActivity.createIntent(this, mCredential.getProto()));
+                    SaveAfterUnlockActivity.createIntent(this, mCredential.toProtobuf()));
             saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(saveAfterUnlock);
             finish();
         }
     }
 
     @OnClick(R.id.never_save_button)
     void onNeverSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             finish(RESULT_CANCELED);
             return;
         }
 
         try {
             client.addToNeverSaveList(mCredential.getAuthenticationDomain());
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to add app to never save list", e);
         }
 
         finish(RESULT_CANCELED);
     }
 
     private CredentialStorageClient getStorageClient() {
         try {
             mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
             return mClient.get();
         } catch (InterruptedException e) {
             Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
             return null;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
index dd54ebc..8853fd3 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
@@ -45,593 +45,595 @@ import org.spongycastle.crypto.io.CipherOutputStream;
 /**
  * An encrypted file-system based credential store. Uses bcrypt to derive an encryption key from
  * a password. Creates a directory for each authentication domain (using a hash of the domain)
  * under which the set of credentials for that domain is stored. This allows determining whether
  * a credential is available for a given authentication domain without the encryption key, which
  * is useful for answering OpenYOLO requests.
  */
 public final class CredentialStorage {
 
     private static final String LOG_TAG = "CredentialStorage";
 
     private static final int SALT_SIZE = 16;
     private static final int BCRYPT_COST = 10;
 
     private static final int AUTH_DOMAIN_HASH_SIZE = 32;
 
     private static final char[] HEX_CHARS =
             { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
     private static final byte[] KEY_VERIFICATION_BYTES =
             { 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0 };
     private static final int HALF_BYTE_WIDTH = 4;
     private static final int HALF_BYTE_MASK = 0xF;
 
     @NonNull
     private SecureRandom mRandom;
 
     @NonNull
     private File mStoreDir;
 
     private byte[] mSalt;
 
     @Nullable
     private byte[] mKey;
 
     /**
      * Initializes a credential store in the default location for the application.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(Context context) throws IOException {
         this(new SecureRandom(), new File(context.getFilesDir(), "store"));
     }
 
     /**
      * Initializes a credential store in the specified location.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(
             @NonNull SecureRandom random,
             @NonNull File storeDir)
             throws IOException {
         mRandom = random;
         mStoreDir = storeDir;
 
         if (mStoreDir.exists()) {
             CredentialMeta credentialMeta = readCredentialMeta();
             mSalt = credentialMeta.getSalt().toByteArray();
         }
     }
 
     /**
      * Determines whether a credential store exists in the initialized location.
      */
     public boolean isCreated() {
         return mStoreDir.exists();
     }
 
     /**
      * Determines whether the credential store is unlocked, meaning that the encryption key has
      * been derived from the password and is resident in memory.
      */
     public boolean isUnlocked() {
         return mKey != null;
     }
 
     /**
      * Locks the credential store, meaning that the derived encryption key is released from
      * memory if necessary.
      */
     public void lock() {
         // overwrite the key with random data, then release it for garbage collection
         mRandom.nextBytes(mKey);
         mKey = null;
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     @Nullable
     public List<String> retrieveNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         return meta.getNeverSaveList();
     }
 
     /**
      * Clears the "never save" list.
      * @throws IOException - in the case when the storage fails to be written
      */
     public void clearNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         writeCredentialMeta(meta.toBuilder().clearNeverSave().build());
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
         if (meta.getNeverSaveCount() < 1) {
             return false;
         }
 
         HashSet<String> authDomainsAsStrings = new HashSet<>();
         for (AuthenticationDomain authDomain : authDomains) {
             authDomainsAsStrings.add(authDomain.toString());
         }
 
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             if (authDomainsAsStrings.contains(neverSaveDomain)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Adds the specified authentication domain to the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             neverSaveDomains.add(neverSaveDomain);
         }
 
         neverSaveDomains.add(authDomain.toString());
 
         writeCredentialMeta(
                 meta.toBuilder()
                     .clearNeverSave()
                     .addAllNeverSave(neverSaveDomains)
                     .build());
     }
 
     /**
      * Removes the specified list of authentication domains from the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
         for (String neverSaveDomain : meta.getNeverSaveList()) {
             neverSaveDomains.add(neverSaveDomain);
         }
 
         for (AuthenticationDomain authDomain : authDomains) {
             neverSaveDomains.remove(authDomain.toString());
         }
 
         writeCredentialMeta(
                 meta.toBuilder()
                     .clearNeverSave()
                     .addAllNeverSave(neverSaveDomains)
                     .build());
     }
 
     /**
      * Returns all account hints. The list of hints is automatically maintained as part of the
      * other credential save / delete operations.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public List<AccountHint> getHints() throws IOException {
         CredentialMeta meta = readCredentialMeta();
         return meta.getHintsList();
     }
 
     /**
      * Determines whether any credentials are stored for the given authentication domain. This
      * does not require the credential store to be unlocked.
      */
     public boolean hasCredentialFor(@NonNull String authDomain) {
         return getAuthDomainDir(authDomain).exists();
     }
 
     /**
      * Returns a list of all stored credentials. Requires that the credential store is unlocked.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listAllCredentials() throws IOException {
         ArrayList<Credential> allCredentials = new ArrayList<>();
         checkUnlocked();
         for (File authDomainDir : mStoreDir.listFiles()) {
             if (!authDomainDir.isDirectory()) {
                 continue;
             }
 
             List<Credential> credentials = readCredentials(authDomainDir);
             allCredentials.addAll(credentials);
         }
 
         return allCredentials;
     }
 
     /**
      * Returns a list of credentials for the specified authentication domain. Requires
      * that the credential store is unlocked. May be empty.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listCredentials(String authDomain) throws IOException {
         checkUnlocked();
         return readCredentials(authDomain);
     }
 
     /**
      * Writes (or overwrites) the provided credential to the store. Requires that the credential
      * store is unlocked. May be empty.
      * @throws IOException if the credential could not be written.
      */
     public void upsertCredential(Credential credential) throws IOException {
         checkUnlocked();
-        List<Credential> credentials = new ArrayList<>(readCredentials(credential.getAuthDomain()));
+        List<Credential> credentials = new ArrayList<>(
+                readCredentials(credential.getAuthDomain().getUri()));
 
         // replace any existing equivalent
         ListIterator<Credential> it = credentials.listIterator();
         boolean existingFound = false;
         while (it.hasNext() && !existingFound) {
             Credential existing = it.next();
             if (credential.getId().equals(existing.getId())
                     && eq(credential.getAuthDomain(), existing.getAuthDomain())) {
                 existingFound = true;
                 it.set(credential);
             }
         }
 
         if (!existingFound) {
             it.add(credential);
         }
 
-        writeCredentials(credential.getAuthDomain(), credentials);
+        writeCredentials(credential.getAuthDomain().getUri(), credentials);
         upsertHint(credential);
     }
 
     /**
      * Removes the specified credential (or one with the same authentication domain, identifier
      * and "type") from the store. Requires that the store is unlocked.
      * @throws IOException if the credential could not be deleted.
      */
     public void deleteCredential(Credential credential) throws IOException {
         checkUnlocked();
-        List<Credential> credentials = new ArrayList<>(readCredentials(credential.getAuthDomain()));
+        List<Credential> credentials = new ArrayList<>(readCredentials(
+                credential.getAuthDomain().getUri()));
 
         ListIterator<Credential> it = credentials.listIterator();
         boolean existingFound = false;
         while (it.hasNext() && !existingFound) {
             Credential existing = it.next();
             if (credentialsAreEquivalent(credential, existing)) {
                 existingFound = true;
                 it.remove();
             }
         }
 
         if (existingFound) {
-            writeCredentials(credential.getAuthDomain(), credentials);
+            writeCredentials(credential.getAuthDomain().getUri(), credentials);
         }
     }
 
     private boolean credentialsAreEquivalent(Credential c1, Credential c2) {
         if (c1 == null) {
             return c2 == null;
         }
 
         if (c2 == null) {
             return false;
         }
 
         return c1.getId().equals(c2.getId())
                 && c1.getAuthDomain().equals(c2.getAuthDomain())
                 && c1.getAuthMethod().equals(c2.getAuthMethod());
     }
 
     private boolean areEqual(Object o1, Object o2) {
         return o1 == null ? o2 == null : o1.equals(o2);
     }
 
     /* **************************** store initialization ******************************************/
 
     /**
      * Creates a credential store at the initialized location, deriving an encryption key from
      * the specified password.
      * @throws IOException if the store could not be created.
      */
     public void create(String password) throws IOException {
         if (!mStoreDir.mkdirs()) {
             throw new IllegalStateException("unable to create credential store directory");
         }
 
         CredentialMeta meta = generateCredentialMeta();
         writeCredentialMeta(meta);
 
         mSalt = meta.getSalt().toByteArray();
         mKey = keyFromPassword(password, meta.getCost());
         generateKeyTestFile();
     }
 
     /**
      * Unlocks the credential store, deriving an encryption key from the specified password and
      * validates it.
      * @throws IOException if the store could not be unlocked.
      */
     public boolean unlock(String password) throws IOException {
         if (!isCreated()) {
             throw new IllegalStateException("Store has not been created");
         }
 
         CredentialMeta credentialMeta = readCredentialMeta();
         mSalt = credentialMeta.getSalt().toByteArray();
         mKey = keyFromPassword(password, credentialMeta.getCost());
         return verifyKey();
     }
 
     /* **************************** credential meta handling **************************************/
 
     private File getCredentialMetaFile() {
         return new File(mStoreDir, "meta");
     }
 
     private CredentialMeta generateCredentialMeta() {
         return CredentialMeta.newBuilder()
                 .setSalt(ByteString.copyFrom(generateRandomBytes(SALT_SIZE)))
                 .setCost(BCRYPT_COST)
                 .build();
     }
 
     private void writeCredentialMeta(CredentialMeta meta) throws IOException {
         FileOutputStream stream = null;
         try {
             stream = new FileOutputStream(getCredentialMetaFile());
             meta.writeTo(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private CredentialMeta readCredentialMeta() throws IOException {
         FileInputStream stream = null;
         try {
             stream = new FileInputStream(getCredentialMetaFile());
             return CredentialMeta.parseFrom(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private void upsertHint(Credential credential) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         // create a copy of the hints list for modification
         List<AccountHint> hints = new ArrayList<>(readCredentialMeta().getHintsList());
 
         ListIterator<AccountHint> hintIter = hints.listIterator();
         boolean found = false;
         while (!found && hintIter.hasNext()) {
             AccountHint existingHint = hintIter.next();
 
             if (existingHint.getIdentifier().equals(credential.getId())
                     && existingHint.getAuthMethod().equals(credential.getAuthMethod())
                     && CredentialQualityScore.getScore(existingHint)
                             <= CredentialQualityScore.getScore(credential)) {
                 hintIter.remove();
                 hintIter.add(convertCredentialToHint(credential));
                 found = true;
             }
         }
 
         if (!found) {
             hintIter.add(convertCredentialToHint(credential));
         }
 
         writeCredentialMeta(meta.toBuilder()
                 .clearHints()
                 .addAllHints(hints)
                 .build());
     }
 
     private AccountHint convertCredentialToHint(Credential credential) {
         return AccountHint.newBuilder()
                 .setIdentifier(credential.getId())
-                .setAuthMethod(credential.getAuthMethod())
+                .setAuthMethod(credential.getAuthMethod().getUri())
                 .setName(credential.getDisplayName())
                 .setPictureUri(credential.getDisplayPictureUri())
                 .build();
     }
 
     /* **************************** key validation ************************************************/
 
     private File getKeyTestFile() {
         return new File(mStoreDir, "test");
     }
 
     private void generateKeyTestFile() throws IOException {
         CipherOutputStream stream = null;
         try {
             stream = IoUtil.encryptTo(getKeyTestFile(), mKey);
             stream.write(KEY_VERIFICATION_BYTES);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private boolean verifyKey() throws IOException {
         CipherInputStream stream = null;
         try {
             stream = IoUtil.decryptFrom(getKeyTestFile(), mKey);
             byte[] bytes = new byte[KEY_VERIFICATION_BYTES.length];
             int numRead = stream.read(bytes);
             return numRead == KEY_VERIFICATION_BYTES.length
                 && bytesEqual(KEY_VERIFICATION_BYTES, bytes);
         } catch (IOException ex) {
             Log.i(LOG_TAG, "Key verification failed");
             return false;
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* ************************** auth domain directory management ********************************/
 
     private File getAuthDomainDir(String authDomain) {
         return new File(mStoreDir, toBlakeHash(authDomain));
     }
 
     private File initAuthDomainDir(String authDomain) throws IOException {
         File authorityDir = getAuthDomainDir(authDomain);
         if (!authorityDir.exists()) {
             if (!authorityDir.mkdirs()) {
                 throw new IOException("failed to create authority dir");
             }
         }
 
         return authorityDir;
     }
 
     private void deleteAuthDomainDir(String authDomain) throws IOException {
         File credsFile = getCredentialsFile(authDomain);
         if (credsFile.exists()) {
             if (!credsFile.delete()) {
                 throw new IOException("failed to delete credentials file");
             }
         }
 
         File authorityDir = getAuthDomainDir(authDomain);
         if (authorityDir.exists()) {
             if (!authorityDir.delete()) {
                 throw new IOException("failed to delete authority directory");
             }
         }
     }
 
     private File getCredentialsFile(String authDomain) {
         return getCredentialsFile(getAuthDomainDir(authDomain));
     }
 
     private File getCredentialsFile(File authDomainDir) {
         return new File(authDomainDir, "creds");
     }
 
     /* **************************** credential manipulation ***************************************/
 
     private void writeCredentials(String authDomain, List<Credential> credentials)
             throws IOException {
         if (credentials.size() == 0) {
             deleteAuthDomainDir(authDomain);
             return;
         }
 
         initAuthDomainDir(authDomain);
         CipherOutputStream stream = null;
         try {
             stream = IoUtil.encryptTo(getCredentialsFile(authDomain), mKey);
             CredentialList proto = CredentialList.newBuilder()
                     .addAllCredentials(credentials)
                     .build();
 
             proto.writeTo(stream);
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private List<Credential> readCredentials(String authDomain) throws IOException {
         return readCredentials(getAuthDomainDir(authDomain));
     }
 
     private List<Credential> readCredentials(File authDomain) throws IOException {
         File credentialsFile = getCredentialsFile(authDomain);
         if (!credentialsFile.exists()) {
             return Collections.emptyList();
         }
 
         CipherInputStream stream = null;
         try {
             stream = IoUtil.decryptFrom(credentialsFile, mKey);
             return CredentialList.parseFrom(stream).getCredentialsList();
         } finally {
             IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* *********************************** utils **************************************************/
 
     private void checkUnlocked() {
         if (!isUnlocked()) {
             throw new IllegalStateException("credential store is locked");
         }
     }
 
     private byte[] keyFromPassword(String password, int cost) {
         return BCrypt.generate(toUtf8Bytes(password), mSalt, cost);
     }
 
     private static byte[] toUtf8Bytes(String str) {
         try {
             return str.getBytes("UTF-8");
         } catch (UnsupportedEncodingException e) {
             throw new IllegalStateException("UTF-8 character set not supported, against spec");
         }
     }
 
     private byte[] generateRandomBytes(int length) {
         byte[] bytes = new byte[length];
         mRandom.nextBytes(bytes);
         return bytes;
     }
 
     private boolean bytesEqual(byte[] b1, byte[] b2) {
         if (b1 == null) {
             return b2 == null;
         }
 
         if (b2 == null || b1.length != b2.length) {
             return false;
         }
 
         for (int i = 0; i < b1.length; i++) {
             if (b1[i] != b2[i]) {
                 return false;
             }
         }
 
         return true;
     }
 
     private String toBlakeHash(String message) {
         Blake2bDigest digest = new Blake2bDigest(
                 null, /* no key */
                 AUTH_DOMAIN_HASH_SIZE,
                 mSalt,
                 null); /* no personalization of the hashing function */
         byte[] messageBytes = toUtf8Bytes(message);
         digest.update(messageBytes, 0, messageBytes.length);
         byte[] result = new byte[AUTH_DOMAIN_HASH_SIZE];
         digest.doFinal(result, 0);
         return toHexString(result);
     }
 
     private String toHexString(byte[] bytes) {
         char[] result = new char[bytes.length * 2];
         for (int i = 0, j = 0; i < bytes.length; i++, j += 2) {
             byte nextByte = bytes[i];
 
             result[j] = HEX_CHARS[(nextByte >>> HALF_BYTE_WIDTH) & HALF_BYTE_MASK];
             result[j + 1] = HEX_CHARS[nextByte & HALF_BYTE_MASK];
         }
         return new String(result);
     }
 
     private boolean eq(Object o1, Object o2) {
         if (o1 == null) {
             return o2 == null;
         }
         return o2 != null && o1.equals(o2);
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
index 3524338..d9a7d3a 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -26,3 +26,3 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveResponse;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
 import org.openyolo.protocol.RetrieveRequest;
@@ -32,46 +32,46 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
  * we respond to all requests with an intent as long as the
  * {@link org.openyolo.protocol.AuthenticationMethods#EMAIL email} authentication method is
  * supported.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         Log.i(LOG_TAG, "Processing retrieve query from claimed caller: "
                 + query.getRequestingApp());
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // Ensure the caller supports the email authentication method
         if (!request.getAuthenticationMethods().contains(AuthenticationMethods.EMAIL)) {
             responseSender.sendResponse(query,  null /* response */);
             return;
         }
 
         Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
-        CredentialRetrieveResponse response = CredentialRetrieveResponse.newBuilder()
+        CredentialRetrieveBbqResponse response = CredentialRetrieveBbqResponse.newBuilder()
                 .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
                 .build();
 
         Log.i(LOG_TAG, "Accepting credential request for claimed caller: "
                 + query.getRequestingApp());
         responseSender.sendResponse(query, response.toByteArray());
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
index 09cba04..fc5906d 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -28,3 +28,3 @@ import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.Credential;
 import org.openyolo.spi.RetrieveIntentResultUtil;
@@ -32,68 +32,68 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
  */
 public class RetrieveActivity extends AppCompatActivity {
 
     private static final int PIN_SIZE = 6;
 
     private static final String LOG_TAG = "TrapdoorRetrieve";
 
     private AuthenticationDomain mDomain;
 
     /**
      * Creates an Intent to start this activity.
      */
     public static Intent createIntent(Context context) {
         return new Intent(context, RetrieveActivity.class);
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
             setResult(RESULT_CANCELED);
             finish();
             return;
         }
 
         mDomain = new TreeSet<>(
                 AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
         Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
 
         setContentView(R.layout.dialog_layout);
         ((PinEntryView)findViewById(R.id.pin_entry_field))
                 .addTextChangedListener(new PinChangedWatcher());
     }
 
     private class PinChangedWatcher implements TextWatcher {
         @Override
         public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
 
         @Override
         public void onTextChanged(CharSequence seq, int start, int before, int count) {}
 
         @Override
         public void afterTextChanged(Editable pin) {
             if (pin.length() != PIN_SIZE) {
                 return;
             }
             String userName = UserDataStore.getUserName(RetrieveActivity.this);
             String password = PasswordGenerator.generatePassword(
                     userName,
                     pin.toString(),
                     mDomain.toString());
 
-            Credential credential = Credential.newBuilder()
-                    .setAuthMethod(AuthenticationMethods.EMAIL.toString())
-                    .setAuthDomain(mDomain.toString())
-                    .setId(UserDataStore.getUserName(RetrieveActivity.this))
+            Credential credential = new Credential.Builder(
+                    UserDataStore.getUserName(RetrieveActivity.this),
+                    AuthenticationMethods.EMAIL,
+                    mDomain)
                     .setPassword(password)
                     .build();
 
             setResult(RESULT_OK, RetrieveIntentResultUtil.createResponseData(credential));
             finish();
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
index 37743e3..827540b 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
@@ -29,2 +29,3 @@ import android.text.TextUtils;
 import android.util.Base64;
+import java.io.IOException;
 import java.security.MessageDigest;
@@ -39,188 +40,220 @@ import org.valid4j.Assertive;
 /**
  * A URI-based representation of an authentication domain, which determines the scope within which
  * a credential is valid. An authentication domain may have multiple equivalent representations,
  * such as when apps and sites share the same authentication system. The responsibility for
  * determining whether two given authentication domains are equivalent lies with the credential
  * provider.
  *
  * <p>Two broad classes of authentication domain are defined in the OpenYOLO
  * specification : Android authentication domains, of form
  * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
  * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
  * with no path, query or fragment. They must therefore always be of form
  * {@code scheme://authority}.
  */
 @SuppressLint("PackageManagerGetSignatures")
 public final class AuthenticationDomain implements Comparable<AuthenticationDomain> {
 
     private static final String DIGEST_SHA_512 = "SHA-512";
     private static final String SCHEME_ANDROID = "android";
     private static final String SCHEME_HTTP = "http";
     private static final String SCHEME_HTTPS = "https";
 
-    private final Uri mUri;
+    private final String mUriStr;
+
+    /**
+     * Initially null, created on-demand for each thread from mUriStr.
+     */
+    private final ThreadLocal<Uri> mParsedUri = new ThreadLocal<>();
 
     /**
      * Creates an authentication domain that represents the current package, as identified
      * by the provided context's {@link Context#getPackageName() getPackageName} method.
      */
     @NonNull
     public static AuthenticationDomain getSelfAuthDomain(@NonNull Context context) {
         require(context, notNullValue());
 
         PackageManager pm = context.getPackageManager();
         String packageName = context.getPackageName();
         PackageInfo packageInfo;
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             throw new IllegalStateException("Unable to find package info for " + packageName);
         }
 
         return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
     }
 
     /**
      * Creates the list of all authentication domains that represent the specified package.
      * The list will contain a distinct entry for every signature related to the application.
      */
     @NonNull
     public static List<AuthenticationDomain> listForPackage(
             @NonNull Context context,
             @Nullable String packageName) {
         require(context, notNullValue());
 
         PackageManager pm = context.getPackageManager();
         PackageInfo packageInfo;
         if (TextUtils.isEmpty(packageName)) {
             return Collections.emptyList();
         }
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             return Collections.emptyList();
         }
 
         ArrayList<AuthenticationDomain> authDomains =
                 new ArrayList<>(packageInfo.signatures.length);
         for (Signature signature : packageInfo.signatures) {
             authDomains.add(createAndroidAuthDomain(packageName, signature));
         }
 
         return authDomains;
     }
 
     /**
      * Creates an Android authentication domain (of form {@code android://SIGNATURE@PACKAGE}),
      * given the provided package name and signature.
      */
     @NonNull
     public static AuthenticationDomain createAndroidAuthDomain(
             @NonNull String packageName,
             @NonNull Signature signature) {
         require(!TextUtils.isEmpty(packageName), "packageName must not be null or empty");
         require(signature, notNullValue());
 
         return new AuthenticationDomain(
                 new Uri.Builder()
                         .scheme(SCHEME_ANDROID)
                         .encodedAuthority(generateSignatureHash(signature) + "@" + packageName)
-                        .build());
+                        .build()
+                        .toString());
+    }
+
+    /**
+     * Creates an authentication domain from its protocol buffer equivalent, in byte form.
+     * @throws IOException if the protocol buffer cannot be parsed.
+     */
+    @NonNull
+    public static AuthenticationDomain fromProtobufBytes(@NonNull byte[] protobufBytes)
+            throws IOException {
+        return fromProtobuf(Protobufs.AuthenticationDomain.parseFrom(protobufBytes));
+    }
+
+    /**
+     * Creates an authentication domain from its protocol buffer equivalent.
+     */
+    @NonNull
+    public static AuthenticationDomain fromProtobuf(
+            @NonNull Protobufs.AuthenticationDomain authDomain) {
+        return new AuthenticationDomain(authDomain.getUri());
     }
 
     @NonNull
     static String generateSignatureHash(@NonNull Signature signature) {
         try {
             MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_512);
             byte[] hashBytes = digest.digest(signature.toByteArray());
             return Base64.encodeToString(hashBytes, Base64.URL_SAFE).replace("\n", "");
         } catch (NoSuchAlgorithmException e) {
             throw new IllegalStateException(
                     "Platform does not support" + DIGEST_SHA_512 + " hashing");
         }
     }
 
     /**
      * Creates an authentication domain from the provided String representation. If the string
      * provided is not a valid authentication domain, an {@link IllegalArgumentException}
      * will be thrown.
      */
     public AuthenticationDomain(@NonNull String authDomainString) {
-        mUri = Assertive.require(
-                Uri.parse(authDomainString),
+        mUriStr = Assertive.require(
+                authDomainString,
                 CustomMatchers.isValidAuthenticationDomain());
     }
 
-    private AuthenticationDomain(@NonNull Uri authDomainUri) {
-        mUri = authDomainUri;
-    }
-
     /**
      * Determines whether the authentication domain refers to an Android application.
      */
     public boolean isAndroidAuthDomain() {
-        return SCHEME_ANDROID.equals(mUri.getScheme());
+        return SCHEME_ANDROID.equals(getParsedUri().getScheme());
     }
 
     /**
      * Determines whether the authentication domain refers to a Web domain.
      */
     public boolean isWebAuthDomain() {
-        return SCHEME_HTTP.equals(mUri.getScheme())
-                || SCHEME_HTTPS.equals(mUri.getScheme());
+        Uri parsedUri = getParsedUri();
+        return SCHEME_HTTP.equals(parsedUri.getScheme())
+                || SCHEME_HTTPS.equals(parsedUri.getScheme());
     }
 
     /**
      * Retrieves the Android package name from the authentication domain. If the authentication
      * domain does not represent an Android application, an {@link IllegalStateException} will
      * be thrown.
      */
     @NonNull
     public String getAndroidPackageName() {
         if (!isAndroidAuthDomain()) {
             throw new IllegalStateException("Authentication domain is not an Android domain");
         }
-        return mUri.getHost();
+        return getParsedUri().getHost();
     }
 
     /**
-     * Retrieves the URI form of the authentication domain.
+     * Creates a protocol buffer representation of the authentication domain, for transmission
+     * or storage.
      */
-    @NonNull
-    public Uri getUri() {
-        return mUri;
+    public Protobufs.AuthenticationDomain toProtobuf() {
+        return Protobufs.AuthenticationDomain.newBuilder()
+                .setUri(mUriStr)
+                .build();
     }
 
     /**
      * Retrieves the string form of the authentication domain.
      */
     @NonNull
     public String toString() {
-        return mUri.toString();
+        return mUriStr;
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (!(obj instanceof AuthenticationDomain)) {
             return false;
         }
 
-        AuthenticationDomain other = (AuthenticationDomain) obj;
-
-        return mUri.equals(other.getUri());
+        return compareTo((AuthenticationDomain) obj) == 0;
     }
 
     @Override
     public int hashCode() {
-        return mUri.hashCode();
+        return mUriStr.hashCode();
     }
 
     @Override
     public int compareTo(@NonNull AuthenticationDomain authenticationDomain) {
-        return mUri.compareTo(authenticationDomain.getUri());
+        return mUriStr.compareTo(authenticationDomain.mUriStr);
+    }
+
+    private Uri getParsedUri() {
+        Uri parsedUri = mParsedUri.get();
+        if (parsedUri == null) {
+            parsedUri = Uri.parse(mUriStr);
+            mParsedUri.set(parsedUri);
+        }
+
+        return parsedUri;
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationMethod.java b/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
new file mode 100644
index 0000000..c4afa08
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethod.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+import java.io.IOException;
+import org.openyolo.protocol.internal.CustomMatchers;
+
+
+/**
+ * A URI-based representation of an authentication method, which describes how a credential is
+ * used to authenticate a user.
+ */
+public final class AuthenticationMethod implements Comparable<AuthenticationMethod> {
+
+    /**
+     * Creates an authentication method from its protocol buffer equivalent, in byte form.
+     * @throws IOException if the protocol buffer cannot be parsed.
+     */
+    public static AuthenticationMethod fromProtobufBytes(byte[] protoBufBytes) throws IOException {
+        return fromProtobuf(Protobufs.AuthenticationMethod.parseFrom(protoBufBytes));
+    }
+
+    /**
+     * Creates an authentication method from its protocol buffer equivalent.
+     */
+    public static AuthenticationMethod fromProtobuf(Protobufs.AuthenticationMethod authMethod) {
+        return new AuthenticationMethod(authMethod.getUri());
+    }
+
+    private final String mUri;
+
+    /**
+     * Creates an authentication method from a URI string.
+     */
+    public AuthenticationMethod(@NonNull String authMethodUriStr) {
+        mUri = require(authMethodUriStr, CustomMatchers.isValidAuthenticationMethod());
+    }
+
+    /**
+     * Creates a protocol buffer representation of the authentication method, for transmission or
+     * storage.
+     */
+    public Protobufs.AuthenticationMethod toProtobuf() {
+        return Protobufs.AuthenticationMethod.newBuilder()
+                .setUri(mUri)
+                .build();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (!(obj instanceof AuthenticationMethod)) {
+            return false;
+        }
+
+        return compareTo((AuthenticationMethod)obj) == 0;
+    }
+
+    @Override
+    public int hashCode() {
+        return mUri.hashCode();
+    }
+
+    @Override
+    public int compareTo(@NonNull AuthenticationMethod authMethod) {
+        return mUri.compareTo(authMethod.mUri);
+    }
+
+    @Override
+    public String toString() {
+        return mUri;
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationMethods.java b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
index 386618e..13faad8 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
@@ -16,55 +16,57 @@ package org.openyolo.protocol;
 
-import android.net.Uri;
 import org.openyolo.protocol.Credential.Builder;
 
 /**
  * A set of well-known authentication method URIs for use with
- * {@link Builder#setAuthenticationMethod(String)}.
+ * {@link Builder#setAuthenticationMethod(AuthenticationMethod)}.
  */
 public final class AuthenticationMethods {
 
     /**
      * Email address based authentication, optionally with a password. This authentication type
      * is typically for accounts which have an email address as the primary (user facing)
      * identifier. Authentication typically occurs using the email address and a password, but
      * is also possible using the email address as a recovery method.
      */
-    public static final Uri EMAIL = Uri.parse("openyolo://email");
+    public static final AuthenticationMethod EMAIL = new AuthenticationMethod("openyolo://email");
 
     /**
      * Phone number based authentication, optionally with a password. This authentication type
      * is typically for accounts which have a phone number as the primary (user facing)
      * identifier. Authentication typically occurs by sending a code to the phone number, and
      * possible also requiring the entry of a password or pin.
      *
      * <p>When used to request a hint, OpenYOLO providers _MUST_ return the selected phone number
      * in E.164 format.
      */
-    public static final Uri PHONE = Uri.parse("openyolo://phone");
+    public static final AuthenticationMethod PHONE = new AuthenticationMethod("openyolo://phone");
 
     /**
      * User name and password based authentication. This authentication type requires the entry
      * of a unicode identifier string and a password.
      */
-    public static final Uri USER_NAME = Uri.parse("openyolo://username");
+    public static final AuthenticationMethod USER_NAME =
+            new AuthenticationMethod("openyolo://username");
 
     /**
      * Google Sign-in authentication.
      *
      * @see <a href="https://developers.google.com/identity/sign-in/android/">Google Sign-in for
      *     Android</a>.
      */
-    public static final Uri GOOGLE = Uri.parse("https://accounts.google.com");
+    public static final AuthenticationMethod GOOGLE =
+            new AuthenticationMethod("https://accounts.google.com");
 
     /**
      * Facebook Login authentication.
      *
      * @see <a href="https://developers.facebook.com/docs/facebook-login/android">Facebook Login
      *     for Android</a>.
      */
-    public static final Uri FACEBOOK = Uri.parse("https://www.facebook.com");
+    public static final AuthenticationMethod FACEBOOK =
+            new AuthenticationMethod("https://www.facebook.com");
 
     private AuthenticationMethods() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
index ee936dc..63f989e 100644
--- a/protocol/java/org/openyolo/protocol/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -16,5 +16,6 @@ package org.openyolo.protocol;
 
+import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
 import static org.openyolo.protocol.internal.CustomMatchers.isWebUri;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
 import static org.openyolo.protocol.internal.CustomMatchers.nullOr;
@@ -29,4 +30,8 @@ import android.support.annotation.Nullable;
 import android.text.TextUtils;
+import com.google.protobuf.ByteString;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
+import org.openyolo.protocol.internal.AuthenticationDomainConverters;
+import org.openyolo.protocol.internal.AuthenticationMethodConverters;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -35,348 +40,403 @@ import org.openyolo.protocol.internal.CollectionConverter;
 /**
  * A representation of a credential for use in sign-in or sign-up. This provides a
  * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential
  * protocol buffer} that is returned by the app.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
-    @NonNull
-    private final Protobufs.Credential mProto;
-
     /**
-     * Deserializes and validates a credential protocol buffer.
-     * @throws IOException if the credential is invalid.
+     * Creates a credential from its protocol buffer equivalent, in byte form.
+     * @throws IOException if the protocol buffer cannot be parsed.
      */
     public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
-        return new Credential.Builder(
-                Protobufs.Credential.parseFrom(credentialProtoBytes))
-                .build();
+        return fromProtobuf(Protobufs.Credential.parseFrom(credentialProtoBytes));
     }
 
-    private Credential(@NonNull Protobufs.Credential proto) {
-        mProto = proto;
+    /**
+     * Creates a credential from its protocol buffer equivalent.
+     */
+    public static Credential fromProtobuf(Protobufs.Credential credential) {
+        return new Credential.Builder(credential).build();
+    }
+
+    @NonNull
+    private final String mId;
+
+    @NonNull
+    private final AuthenticationDomain mAuthDomain;
+
+    @NonNull
+    private final AuthenticationMethod mAuthMethod;
+
+    @Nullable
+    private final String mDisplayName;
+
+    @Nullable
+    private final Uri mDisplayPicture;
+
+    @Nullable
+    private final String mPassword;
+
+    @Nullable
+    private final String mIdToken;
+
+    @NonNull
+    private final Map<String, ByteString> mAdditionalProps;
+
+    private Credential(
+            @NonNull String id,
+            @NonNull AuthenticationDomain authDomain,
+            @NonNull AuthenticationMethod authMethod,
+            @Nullable String displayName,
+            @Nullable Uri displayPicture,
+            @Nullable String password,
+            @Nullable String idToken,
+            @NonNull Map<String, ByteString> additionalProps) {
+        mId = id;
+        mAuthDomain = authDomain;
+        mAuthMethod = authMethod;
+        mDisplayName = displayName;
+        mDisplayPicture = displayPicture;
+        mPassword = password;
+        mIdToken = idToken;
+        mAdditionalProps = additionalProps;
     }
 
     /**
-     * The underlying protocol buffer form of the credential.
+     * Creates a protocol buffer representation of the credential, for transmission or storage.
      */
     @NonNull
-    public Protobufs.Credential getProto() {
-        return mProto;
+    public Protobufs.Credential toProtobuf() {
+        Protobufs.Credential.Builder builder = Protobufs.Credential.newBuilder()
+                .setId(mId)
+                .setAuthMethod(mAuthMethod.toProtobuf())
+                .setAuthDomain(mAuthDomain.toProtobuf())
+                .putAllAdditionalProps(mAdditionalProps);
+
+        if (mDisplayName != null) {
+            builder.setDisplayName(mDisplayName);
+        }
+
+        if (mDisplayPicture != null) {
+            builder.setDisplayPictureUri(mDisplayPicture.toString());
+        }
+
+        if (mPassword != null) {
+            builder.setPassword(mPassword);
+        }
+
+        if (mIdToken != null) {
+            builder.setIdToken(mIdToken);
+        }
+
+        return builder.build();
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
-        return mProto.getId();
+        return mId;
     }
 
     /**
-     * The authentication domain against which this credential can be used, if specified.
+     * The authentication method for the credential, which describes the mechanism by which
+     * it should be verified by the receiving app. This may be any valid URI, but is typically
+     * one of the {@link AuthenticationMethods standard values}.
      */
-    @Nullable
-    public AuthenticationDomain getAuthenticationDomain() {
-        String authDomainStr = nullifyEmptyString(mProto.getAuthDomain());
-        if (authDomainStr == null) {
-            return null;
-        }
-
-        return new AuthenticationDomain(mProto.getAuthDomain());
+    @NonNull
+    public AuthenticationMethod getAuthenticationMethod() {
+        return mAuthMethod;
     }
 
     /**
-     * The credential password, if defined. Must be non-empty, but any further restrictions are
-     * the responsibility of the authentication domain to define and validate.
+     * The authentication domain against which this credential can be used, if specified.
      */
-    @Nullable
-    public String getPassword() {
-        return nullifyEmptyString(mProto.getPassword());
+    @NonNull
+    public AuthenticationDomain getAuthenticationDomain() {
+        return mAuthDomain;
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
-        return nullifyEmptyString(mProto.getDisplayName());
+        return mDisplayName;
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
-        String displayPictureUriStr = nullifyEmptyString(mProto.getDisplayPictureUri());
-        return (displayPictureUriStr != null)
-                ? Uri.parse(displayPictureUriStr)
-                : null;
+        return mDisplayPicture;
     }
 
     /**
-     * The authentication method for the credential, which describes the mechanism by which
-     * it should be verified by the receiving app. This may be any valid URI, but is typically
-     * one of the {@link AuthenticationMethods standard values}.
+     * The credential password, if defined. Must be non-empty, but any further restrictions are
+     * the responsibility of the authentication domain to define and validate.
      */
-    @NonNull
-    public Uri getAuthenticationMethod() {
-        return Uri.parse(mProto.getAuthMethod());
+    @Nullable
+    public String getPassword() {
+        return mPassword;
+    }
+
+    /**
+     * An ID token which provides "proof of access" to the identifier for this credential, if
+     * available.
+     */
+    @Nullable
+    public String getIdToken() {
+        return mIdToken;
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return CollectionConverter.convertMapValues(
-            mProto.getAdditionalPropsMap(),
+            mAdditionalProps,
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
-        byte[] encoded = mProto.toByteArray();
+        byte[] encoded = toProtobuf().toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
-        private Protobufs.Credential.Builder mProtoBuilder;
+        private String mId;
+        private AuthenticationMethod mAuthMethod;
+        private AuthenticationDomain mAuthDomain;
+        private String mDisplayName;
+        private Uri mDisplayPicture;
+        private String mPassword;
+        private String mIdToken;
+        private Map<String, ByteString> mAdditionalProps = new HashMap<>();
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          */
         public Builder(@NonNull Protobufs.Credential proto) {
-            mProtoBuilder = Protobufs.Credential.newBuilder();
-
             // required properties
             setIdentifier(proto.getId());
-            setAuthenticationDomain(new AuthenticationDomain(proto.getAuthDomain()));
-            setAuthenticationMethod(proto.getAuthMethod());
+            setAuthenticationMethod(
+                    AuthenticationMethodConverters.PROTOBUF_TO_OBJECT
+                            .convert(proto.getAuthMethod()));
+            setAuthenticationDomain(
+                    AuthenticationDomainConverters.PROTOBUF_TO_OBJECT
+                            .convert(proto.getAuthDomain()));
 
             // optional properties
+
             setDisplayName(proto.getDisplayName());
             setDisplayPicture(proto.getDisplayPictureUri());
             setPassword(proto.getPassword());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             proto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
-                @NonNull Uri authenticationMethod,
+                @NonNull AuthenticationMethod authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
-            mProtoBuilder = Protobufs.Credential.newBuilder();
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method (as a string) and authentication domain (as a string). To create
          * a credential for your own application.
          *
-         * @see #Builder(String, Uri, AuthenticationDomain)
+         * @see #Builder(String, AuthenticationMethod, AuthenticationDomain)
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull String authenticationMethod,
                 @NonNull String authenticationDomain) {
             this(identifier,
-                    Uri.parse(authenticationMethod),
+                    new AuthenticationMethod(authenticationMethod),
                     new AuthenticationDomain(authenticationDomain));
         }
 
         /**
          * Specifies the identifier for the credential. The provided value must be non-null
          * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
             require(!TextUtils.isEmpty(identifier), "identifier must not be null or empty");
-            mProtoBuilder.setId(identifier);
+            mId = identifier;
             return this;
         }
 
         /**
          * Specifies the authentication domain against which this credential is valid. The provided
          * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             require(domain, notNullValue());
-            mProtoBuilder.setAuthDomain(extractString(domain));
+            mAuthDomain = domain;
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
-        public Builder setAuthenticationMethod(@NonNull Uri authMethod) {
-            require(authMethod, isValidAuthenticationMethod());
-            mProtoBuilder.setAuthMethod(extractString(authMethod));
+        public Builder setAuthenticationMethod(@NonNull AuthenticationMethod authMethod) {
+            require(authMethod, notNullValue());
+            mAuthMethod = authMethod;
             return this;
         }
 
-        /**
-         * Specifies the authentication method for the credential, in string form for convenience.
-         * The provided value must be non-null and non-empty.
-         * @see #setAuthenticationMethod(Uri)
-         */
-        @NonNull
-        public Builder setAuthenticationMethod(@NonNull String authMethod) {
-            require(!TextUtils.isEmpty(authMethod), "authMethod must not be null or empty");
-            return setAuthenticationMethod(Uri.parse(authMethod));
-        }
-
         /**
          * Specifies the password for the credential. If a null or empty value is provided, this
          * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
-            if (nullifyEmptyString(password) == null) {
-                mProtoBuilder.clearPassword();
-            } else {
-                mProtoBuilder.setPassword(password);
-            }
-
+            mPassword = nullifyEmptyString(password);
             return this;
         }
 
         /**
          * Specifies the display name for the credential. If a null or empty value is provided,
          * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
-            if (nullifyEmptyString(displayName) == null) {
-                mProtoBuilder.clearDisplayName();
-            } else {
-                mProtoBuilder.setDisplayName(displayName);
-            }
+            mDisplayName = nullifyEmptyString(displayName);
             return this;
         }
 
         /**
          * Specifies the display picture for the credential. If a null value is provided, this
          * is equivalent to removing the display picture from the credential. If a non-null
          * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             require(displayPicture, nullOr(isWebUri()));
-            if (displayPicture == null) {
-                mProtoBuilder.clearDisplayPictureUri();
-            } else {
-                mProtoBuilder.setDisplayPictureUri(extractString(displayPicture));
-            }
+            mDisplayPicture = displayPicture;
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
                     nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
-            if (mProtoBuilder.getAdditionalPropsCount() > 0) {
-                mProtoBuilder.clearAdditionalProps();
+            if (additionalProps == null) {
+                mAdditionalProps.clear();
             }
-            mProtoBuilder.putAllAdditionalProps(
-                    CollectionConverter.convertMapValues(
-                            additionalProps,
-                            ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING));
+            require(additionalProps.keySet(), everyItem(notNullOrEmptyString()));
+            require(additionalProps.values(), everyItem(notNullValue()));
+
+            mAdditionalProps = CollectionConverter.convertMapValues(
+                    additionalProps,
+                    ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING);
             return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
-            return new Credential(mProtoBuilder.build());
-        }
-
-        private String extractString(@Nullable Object obj) {
-            return (obj != null) ? obj.toString() : null;
+            return new Credential(
+                    mId,
+                    mAuthDomain,
+                    mAuthMethod,
+                    mDisplayName,
+                    mDisplayPicture,
+                    mPassword,
+                    mIdToken,
+                    mAdditionalProps);
         }
     }
 
-    static final class CredentialCreator implements Creator<Credential> {
+    private static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
                 Protobufs.Credential proto = Protobufs.Credential.parseFrom(encodedBytes);
-                return new Credential(proto);
+                return new Credential.Builder(proto).build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRequest.java b/protocol/java/org/openyolo/protocol/HintRequest.java
index d8e03ad..a07439e 100644
--- a/protocol/java/org/openyolo/protocol/HintRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRequest.java
@@ -20,10 +20,5 @@ import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationDomain;
-import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
-import static org.openyolo.protocol.internal.UriConverters.CONVERTER_STRING_TO_URI;
-import static org.openyolo.protocol.internal.UriConverters.CONVERTER_URI_TO_STRING;
 import static org.valid4j.Assertive.require;
 
-import android.net.Uri;
 import android.os.Parcel;
@@ -38,2 +33,3 @@ import java.util.Map;
 import java.util.Set;
+import org.openyolo.protocol.internal.AuthenticationMethodConverters;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -41,352 +37,315 @@ import org.openyolo.protocol.internal.CollectionConverter;
 import org.openyolo.protocol.internal.NoopValueConverter;
-import org.openyolo.protocol.internal.UriConverters;
 
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
 public class HintRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
-    private final Set<Uri> mAuthMethods;
+    private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
     public static HintRequest forEmailAndPasswordAccount() {
         return new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws IOException if the hint request could not be decoded.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws IOException {
         if (hintRequestProtoBytes == null) {
             throw new IOException("Unable to decode hint request from null array");
         }
         return new HintRequest.Builder(
                 Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
                 .build();
     }
 
     private HintRequest(
-            @NonNull Set<Uri> authMethods,
+            @NonNull Set<AuthenticationMethod> authMethods,
             @NonNull PasswordSpecification passwordSpec,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mPasswordSpec = passwordSpec;
         mAdditionalProperties = additionalParams;
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
-    public Set<Uri> getAuthenticationMethods() {
+    public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProperties;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8
      * encoded string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         require(key, notNullValue());
         if (mAdditionalProperties.containsKey(key)) {
             return new String(mAdditionalProperties.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         require(key, notNullValue());
         return mAdditionalProperties.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .addAllAuthMethods(
-                        CollectionConverter.toList(mAuthMethods, CONVERTER_URI_TO_STRING))
+                        CollectionConverter.toList(
+                                mAuthMethods,
+                                AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                     CollectionConverter.convertMapValues(
                             mAdditionalProperties,
-                        ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
+                            ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRequest} instances.
      */
     public static final class Builder {
 
-        private Set<Uri> mAuthMethods = new HashSet<>();
-        private Set<Uri> mIdTypes = new HashSet<>();
+        private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalProps = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          *
          * @see HintRequest#toProtocolBuffer()
          */
         public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
-                    CONVERTER_STRING_TO_URI));
+                    AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setPasswordSpecification(
                     new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
-        public Builder(@NonNull Uri authMethod, @NonNull Uri... additionalAuthMethods) {
+        public Builder(
+                @NonNull AuthenticationMethod authMethod,
+                @NonNull AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
-        public Builder(@NonNull String authMethod, @NonNull String... additionalAuthMethods) {
-            setAuthenticationMethods(authMethod, additionalAuthMethods);
-        }
-
-        /**
-         * Starts the process of defining a hint request, specifying at least one supported
-         * authentication method in string form.
-         *
-         * @see AuthenticationMethods
-         */
-        public Builder(@NonNull Set<Uri> authMethods) {
+        public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
-                @NonNull Uri authMethod,
-                Uri... additionalAuthMethods) {
+                @NonNull AuthenticationMethod authMethod,
+                AuthenticationMethod... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
-                            NoopValueConverter.<Uri>getInstance()));
-            return this;
-        }
-
-        /**
-         * Specifies the authentication methods supported by the requester, in string form. At
-         * least one authentication method must be specified.
-         *
-         * @see AuthenticationMethods
-         */
-        public Builder setAuthenticationMethods(
-                @NonNull String authMethod,
-                @NonNull String... additionalAuthMethods) {
-            setAuthenticationMethods(
-                    CollectionConverter.toSet(
-                            authMethod,
-                            additionalAuthMethods,
-                            UriConverters.CONVERTER_STRING_TO_URI));
+                            NoopValueConverter.<AuthenticationMethod>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
-        public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
+        public Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             require(authMethods, notNullValue());
+            require(!authMethods.contains(null), "every authentication methods must be non-null");
             require(!authMethods.isEmpty(), "At least one authentication method must be specified");
-            require(authMethods, everyItem(isValidAuthenticationMethod()));
             mAuthMethods = authMethods;
             return this;
         }
 
-        /**
-         * Adds an authentication method (in string form) supported by the requester.
-         *
-         * @see AuthenticationMethods
-         */
-        @NonNull
-        public Builder addAuthenticationMethod(@NonNull String authMethodStr) {
-            require(authMethodStr, notNullOrEmptyString());
-            addAuthenticationMethod(Uri.parse(authMethodStr));
-            return this;
-        }
-
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
-        public Builder addAuthenticationMethod(@NonNull Uri authenticationMethod) {
-            require(authenticationMethod, isValidAuthenticationDomain());
+        public Builder addAuthenticationMethod(@NonNull AuthenticationMethod authenticationMethod) {
+            require(authenticationMethod, notNullValue());
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
             mAdditionalProps = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request with a string value, that
          * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
          * key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
             require(value, notNullValue());
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request, that will be encoded as
          * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
             mAdditionalProps.put(name, value);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             require(passwordSpec, notNullValue());
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRequest build() {
             return new HintRequest(
                     unmodifiableSet(mAuthMethods),
                     mPasswordSpec,
                     unmodifiableMap(mAdditionalProps));
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRequest> {
         @Override
         public HintRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new HintRequest.Builder(
                         Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRequest[] newArray(int size) {
             return new HintRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/RetrieveRequest.java b/protocol/java/org/openyolo/protocol/RetrieveRequest.java
index e6cab86..838e5f3 100644
--- a/protocol/java/org/openyolo/protocol/RetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/RetrieveRequest.java
@@ -21,11 +21,9 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.hasItem;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
-import static org.openyolo.protocol.internal.UriConverters.CONVERTER_STRING_TO_URI;
-import static org.openyolo.protocol.internal.UriConverters.CONVERTER_URI_TO_STRING;
 import static org.valid4j.Validation.validate;
 
-import android.net.Uri;
 import android.os.Parcel;
@@ -40,2 +38,3 @@ import java.util.Map;
 import java.util.Set;
+import org.openyolo.protocol.internal.AuthenticationMethodConverters;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -45,249 +44,247 @@ import org.openyolo.protocol.internal.NoopValueConverter;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class RetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     @NonNull
-    private final Set<Uri> mAuthMethods;
+    private final Set<AuthenticationMethod> mAuthMethods;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProps;
 
     private RetrieveRequest(
-            @NonNull Set<Uri> authMethods,
+            @NonNull Set<AuthenticationMethod> authMethods,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mAdditionalProps = additionalParams;
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(
-            @NonNull Set<Uri> authenticationMethods) {
+            @NonNull Set<AuthenticationMethod> authenticationMethods) {
         return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
-    public static RetrieveRequest forAuthenticationMethods(@NonNull Uri... authenticationMethods) {
+    public static RetrieveRequest forAuthenticationMethods(
+            @NonNull AuthenticationMethod... authenticationMethods) {
         return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * The set of authentication methods that the requestor supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
-    public Set<Uri> getAuthenticationMethods() {
+    public Set<AuthenticationMethod> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProps;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         if (mAdditionalProps.containsKey(key)) {
             return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
         return mAdditionalProps.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
         return Protobufs.CredentialRetrieveRequest.newBuilder()
                 .addAllAuthMethods(
                         CollectionConverter.toList(
                                 mAuthMethods,
-                                CONVERTER_URI_TO_STRING))
+                                AuthenticationMethodConverters.OBJECT_TO_PROTOBUF))
                 .putAllAdditionalProps(
                         CollectionConverter.convertMapValues(
                                 mAdditionalProps,
                                 ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
      * Creates {@link RetrieveRequest} instances.
      */
     public static final class Builder {
 
-        private Set<Uri> mAuthMethods = new HashSet<>();
+        private Set<AuthenticationMethod> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
         public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
             validate(requestProto, notNullValue(), IllegalArgumentException.class);
 
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
-                    CONVERTER_STRING_TO_URI));
+                    AuthenticationMethodConverters.PROTOBUF_TO_OBJECT));
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
-        public Builder(@NonNull Uri... authMethods) {
+        public Builder(@NonNull AuthenticationMethod... authMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethods,
-                            NoopValueConverter.<Uri>getInstance()));
+                            NoopValueConverter.<AuthenticationMethod>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
-        public Builder(@NonNull Set<Uri> authMethods) {
+        public Builder(@NonNull Set<AuthenticationMethod> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
-        private Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
+        private Builder setAuthenticationMethods(@NonNull Set<AuthenticationMethod> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
+            validate(authMethods, not(hasItem(nullValue())), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
-            validate(
-                    authMethods,
-                    everyItem(isValidAuthenticationMethod()),
-                    IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
          * @see RetrieveRequest#getAdditionalPropertyAsString(String)
          */
         public Builder addAdditionalProperty(
                 @NonNull String name,
                 @NonNull String value) {
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalProperty(String name, byte[] value) {
             validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link RetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public RetrieveRequest build() {
             return new RetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
     private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
 
         @Override
         public RetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new RetrieveRequest.Builder(
                         Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public RetrieveRequest[] newArray(int size) {
             return new RetrieveRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/RetrieveResult.java b/protocol/java/org/openyolo/protocol/RetrieveResult.java
index 4953845..0337ed2 100644
--- a/protocol/java/org/openyolo/protocol/RetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/RetrieveResult.java
@@ -29,3 +29,3 @@ import java.util.Map;
 import java.util.Set;
-import org.openyolo.protocol.Protobufs.CredentialRetrieveResponse;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveBbqResponse;
 import org.openyolo.protocol.internal.ByteStringConverters;
@@ -35,182 +35,182 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * A response to a {@link RetrieveRequest credential retrieve request}.
  */
 public class RetrieveResult implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveResult} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveResult> CREATOR = new RetrieveResultCreator();
 
     @Nullable
     private final Intent mRetrieveIntent;
 
     @NonNull
-    private final Map<String, CredentialRetrieveResponse> mResponses;
+    private final Map<String, CredentialRetrieveBbqResponse> mResponses;
 
     private RetrieveResult(
             @Nullable Intent retrieveIntent,
-            @NonNull Map<String, CredentialRetrieveResponse> responses) {
+            @NonNull Map<String, CredentialRetrieveBbqResponse> responses) {
         mRetrieveIntent = retrieveIntent;
         mResponses = responses;
     }
 
     /**
      * An intent that can be used to retrieve a credential for the calling app. If no credentials
      * are available, this will be {@code null}. User input may or may not be required to retrieve
      * the credential, at the discretion of the credential provider. The retrieve intent
      * should be fired when the app is ready to retrieve the credential - typically immediately
      * after the retrieve result is received.
      */
     @Nullable
     public Intent getRetrieveIntent() {
         return mRetrieveIntent;
     }
 
     /**
      * The package names of responding credential providers that indicated they may have a usable
      * credential.
      */
     @NonNull
     public Set<String> getResponderPackageNames() {
         return mResponses.keySet();
     }
 
     /**
      * Retrieves the intent for the specified responder package name, if available.
      */
     @NonNull
     public Intent getRetrieveIntentForResponder(@NonNull String responderPackageName) {
         require(responderPackageName, notNullValue());
-        CredentialRetrieveResponse response = mResponses.get(responderPackageName);
+        CredentialRetrieveBbqResponse response = mResponses.get(responderPackageName);
         if (response == null) {
             throw new IllegalArgumentException(responderPackageName + " is not a responder");
         }
 
         return IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
     }
 
     /**
      * Retrieves the additional, non-standard response parameters for the specified responder
      * package name, if available.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalPropsForResponder(String responderPackageName) {
-        CredentialRetrieveResponse response = mResponses.get(responderPackageName);
+        CredentialRetrieveBbqResponse response = mResponses.get(responderPackageName);
         if (response == null) {
             throw new IllegalArgumentException(responderPackageName + " is not a responder");
         }
 
         return CollectionConverter.convertMapValues(
                 response.getAdditionalPropsMap(),
             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link RetrieveResult} instances.
      */
     public static final class Builder {
 
         @Nullable
         private Intent mIntent;
 
         @NonNull
-        private Map<String, CredentialRetrieveResponse> mProtoResponses;
+        private Map<String, CredentialRetrieveBbqResponse> mProtoResponses;
 
         /**
          * Starts the process of describing a credential retrieve result.
          */
         public Builder() {
             mIntent = null;
             mProtoResponses = Collections.emptyMap();
         }
 
         /**
          * Specifies the map of protocol buffer responses received for the credential request,
          * keyed by the package name of the responder.
          */
         @NonNull
         public Builder setProtoResponses(
-                @NonNull Map<String, CredentialRetrieveResponse> protoResponses) {
+                @NonNull Map<String, CredentialRetrieveBbqResponse> protoResponses) {
             require(protoResponses, notNullValue());
-            for (CredentialRetrieveResponse value : protoResponses.values()) {
+            for (CredentialRetrieveBbqResponse value : protoResponses.values()) {
                 require(value, notNullValue());
             }
             mProtoResponses = protoResponses;
             return this;
         }
 
         /**
          * Specifies the retrieve intent, that can be used to retrieve existing credentials from
          * the provider, if available.
          */
         @NonNull
         public Builder setRetrieveIntent(@Nullable Intent intent) {
             mIntent = intent;
             return this;
         }
 
         /**
          * Creates a {@link RetrieveResult} with the properties described to the builder.
          */
         @NonNull
         public RetrieveResult build() {
             return new RetrieveResult(mIntent, mProtoResponses);
         }
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeParcelable(mRetrieveIntent, 0);
         dest.writeInt(mResponses.size());
 
         for (String key : mResponses.keySet()) {
             byte[] responseBytes = mResponses.get(key).toByteArray();
             dest.writeString(key);
             dest.writeInt(responseBytes.length);
             dest.writeByteArray(responseBytes);
         }
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     static final class RetrieveResultCreator implements Creator<RetrieveResult> {
         @Override
         public RetrieveResult createFromParcel(Parcel in) {
             Intent retrieveIntent = in.readParcelable(Intent.class.getClassLoader());
             int numResponses = in.readInt();
 
-            Map<String, CredentialRetrieveResponse> responses = new HashMap<>(numResponses);
+            Map<String, CredentialRetrieveBbqResponse> responses = new HashMap<>(numResponses);
             for (int i = 0; i < numResponses; i++) {
                 String key = in.readString();
                 int responseSize = in.readInt();
                 byte[] responseBytes = new byte[responseSize];
                 in.readByteArray(responseBytes);
 
-                CredentialRetrieveResponse response;
+                CredentialRetrieveBbqResponse response;
                 try {
-                    response = CredentialRetrieveResponse.parseFrom(responseBytes);
+                    response = CredentialRetrieveBbqResponse.parseFrom(responseBytes);
                 } catch (InvalidProtocolBufferException ex) {
                     throw new IllegalArgumentException("Unable to parse response proto");
                 }
 
                 responses.put(key, response);
             }
 
             return new RetrieveResult.Builder()
                     .setRetrieveIntent(retrieveIntent)
                     .setProtoResponses(responses)
                     .build();
         }
 
         @Override
         public RetrieveResult[] newArray(int size) {
             return new RetrieveResult[size];
         }
     }
 
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java b/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
index 1392a81..69866f6 100644
--- a/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
+++ b/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
@@ -17,40 +17,72 @@ package org.openyolo.protocol.internal;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs;
 
 /**
  * Implementations of {@link ValueConverter} related to {@link AuthenticationDomain}.
  */
 public final class AuthenticationDomainConverters {
 
     /**
      * Creates {@link AuthenticationDomain} instances from strings.
      */
     public static final ValueConverter<String, AuthenticationDomain> STRING_TO_DOMAIN =
             new StringToAuthenticationDomainConverter();
 
     /**
      * Extracts the string representation from {@link AuthenticationDomain} instances.
      */
     public static final ValueConverter<AuthenticationDomain, String> DOMAIN_TO_STRING =
             new AuthenticationDomainToStringConverter();
 
+    /**
+     * Creates {@link AuthenticationDomain} instances from their protocol buffer form.
+     */
+    public static final ValueConverter<AuthenticationDomain, Protobufs.AuthenticationDomain>
+            OBJECT_TO_PROTOBUF = new ObjectToProtobufConverter();
+
+    /**
+     * Creates protocol buffers from {@link AuthenticationDomain} instances.
+     */
+    public static final ValueConverter<Protobufs.AuthenticationDomain, AuthenticationDomain>
+            PROTOBUF_TO_OBJECT = new ProtobufToObjectConverter();
+
     private AuthenticationDomainConverters() {
         throw new IllegalStateException("not intended to be constructed");
     }
 
     private static final class StringToAuthenticationDomainConverter
             implements ValueConverter<String, AuthenticationDomain> {
         @Override
         public AuthenticationDomain convert(String value) {
             return new AuthenticationDomain(value);
         }
     }
 
     private static final class AuthenticationDomainToStringConverter
             implements ValueConverter<AuthenticationDomain, String> {
 
         @Override
         public String convert(AuthenticationDomain value) {
             return value.toString();
         }
     }
+
+    private static final class ObjectToProtobufConverter
+            implements ValueConverter<AuthenticationDomain, Protobufs.AuthenticationDomain> {
+
+
+        @Override
+        public Protobufs.AuthenticationDomain convert(AuthenticationDomain value) {
+            return value.toProtobuf();
+        }
+    }
+
+    private static final class ProtobufToObjectConverter
+            implements ValueConverter<Protobufs.AuthenticationDomain, AuthenticationDomain> {
+
+        @Override
+        public AuthenticationDomain convert(Protobufs.AuthenticationDomain value) {
+            return AuthenticationDomain.fromProtobuf(value);
+        }
+    }
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java b/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java
new file mode 100644
index 0000000..a86ab38
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/AuthenticationMethodConverters.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import org.openyolo.protocol.AuthenticationMethod;
+import org.openyolo.protocol.Protobufs;
+
+/**
+ * Implementations of {@link ValueConverter} related to authentication methods.
+ */
+public final class AuthenticationMethodConverters {
+
+    /**
+     * Creates the protocol buffer equivalent of an {@link AuthenticationMethod}.
+     */
+    public static final ValueConverter<AuthenticationMethod, Protobufs.AuthenticationMethod>
+            OBJECT_TO_PROTOBUF = new ObjectToProtobufConverter();
+
+    /**
+     * Creates an {@link AuthenticationMethod} from its protocol buffer equivalent.
+     */
+    public static final ValueConverter<Protobufs.AuthenticationMethod, AuthenticationMethod>
+            PROTOBUF_TO_OBJECT = new ProtobufToObjectConverter();
+
+    private static final class ObjectToProtobufConverter
+            implements ValueConverter<AuthenticationMethod, Protobufs.AuthenticationMethod> {
+
+        @Override
+        public Protobufs.AuthenticationMethod convert(AuthenticationMethod value) {
+            return value.toProtobuf();
+        }
+    }
+
+    private static final class ProtobufToObjectConverter
+            implements ValueConverter<Protobufs.AuthenticationMethod, AuthenticationMethod> {
+
+        @Override
+        public AuthenticationMethod convert(Protobufs.AuthenticationMethod value) {
+            return new AuthenticationMethod(value.getUri());
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java b/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
index c10fa77..061be75 100644
--- a/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
+++ b/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
@@ -28,159 +28,188 @@ import org.hamcrest.Matcher;
 /**
  * Convenient hamcrest-based input validators.
  */
 public final class CustomMatchers {
 
     /**
      * Matcher for web URIs (http or https).
      */
     public static Matcher<Uri> isWebUri() {
         return UriMatcher.WEB_MATCHER;
     }
 
     /**
      * Matcher for HTTPS web URIs.
      */
     public static Matcher<Uri> isHttpsUri() {
         return UriMatcher.HTTPS_ONLY_MATCHER;
     }
 
     /**
-     * Matcher for OpenYOLO authentication domains.
+     * Matcher for OpenYOLO authentication methods, in string form.
      */
-    public static Matcher<Uri> isValidAuthenticationMethod() {
+    public static Matcher<String> isValidAuthenticationMethod() {
+        return StringUriMatcher.AUTHENTICATION_METHOD_STR;
+    }
+
+    /**
+     * Matcher for OpenYOLO authentication methods, in parsed Uri form.
+     */
+    public static Matcher<Uri> isValidAuthenticationMethodUri() {
         return UriMatcher.AUTHENTICATION_METHOD;
     }
 
     /**
-     * Matcher for OpenYOLO authentication domains.
+     * Matcher for OpenYOLO authentication domains, in string form.
      */
-    public static Matcher<Uri> isValidAuthenticationDomain() {
-        return UriMatcher.AUTHENTICATION_DOMAIN;
+    public static Matcher<String> isValidAuthenticationDomain() {
+        return StringUriMatcher.AUTHENTICATION_DOMAIN_STR;
     }
 
-    public static Matcher<Uri> isValidIdentifierType() {
-        return UriMatcher.IDENTIFIER_TYPE;
+    /**
+     * Matcher for OpenYOLO authentication domains, in parsed Uri form.
+     */
+    public static Matcher<Uri> isValidAuthenticationDomainUri() {
+        return UriMatcher.AUTHENTICATION_DOMAIN;
     }
 
     /**
      * Matcher for null values, or those which match the provided matcher.
      */
     public static <T> Matcher<T> nullOr(Matcher<T> matcher) {
         return new NullOrOtherMatcher<>(matcher);
     }
 
     /**
      * Matcher which only accepts non-null, non-empty strings.
      */
     public static Matcher<String> notNullOrEmptyString() {
         return NotNullOrEmptyStringMatcher.INSTANCE;
     }
 
     private static final class NotNullOrEmptyStringMatcher extends BaseMatcher<String> {
 
         private static final NotNullOrEmptyStringMatcher INSTANCE =
                 new NotNullOrEmptyStringMatcher();
 
         @Override
         public boolean matches(Object item) {
             if (item == null) {
                 return false;
             }
 
             if (!(item instanceof String)) {
                 return false;
             }
 
             return !TextUtils.isEmpty((String)item);
         }
 
         @Override
         public void describeTo(Description description) {
             description.appendText("is not a null or empty string");
         }
     }
 
     private static final class NullOrOtherMatcher<T> extends BaseMatcher<T> {
 
         final Matcher<T> mMatcher;
 
         NullOrOtherMatcher(Matcher<T> matcher) {
             mMatcher = matcher;
         }
 
         @Override
         public boolean matches(Object item) {
             return item == null || mMatcher.matches(item);
         }
 
         @Override
         public void describeTo(Description description) {
             description.appendText("null or ").appendDescriptionOf(mMatcher);
         }
     }
 
+    private static final class StringUriMatcher extends CustomTypeSafeMatcher<String> {
+
+        static final StringUriMatcher AUTHENTICATION_DOMAIN_STR =
+                new StringUriMatcher(UriMatcher.AUTHENTICATION_DOMAIN);
+
+        static final StringUriMatcher AUTHENTICATION_METHOD_STR =
+                new StringUriMatcher(UriMatcher.AUTHENTICATION_METHOD);
+
+        private final UriMatcher mUriMatcher;
+
+        StringUriMatcher(UriMatcher matcher) {
+            super(matcher.mUriDescriptor);
+            mUriMatcher = matcher;
+        }
+
+        @Override
+        protected boolean matchesSafely(String item) {
+            Uri uri = Uri.parse(item);
+            return mUriMatcher.matchesSafely(uri);
+        }
+    }
+
     private static final class UriMatcher extends CustomTypeSafeMatcher<Uri> {
 
         static final String SCHEME_HTTP = "http";
         static final String SCHEME_HTTPS = "https";
 
-        static final UriMatcher IDENTIFIER_TYPE = new UriMatcher(
-                Collections.<String>emptySet(),
-                false,
-                "an identifier type");
-
         static final UriMatcher AUTHENTICATION_DOMAIN = new UriMatcher(
                 Collections.<String>emptySet(),
                 false,
                 "an authentication domain");
 
         static final UriMatcher AUTHENTICATION_METHOD = new UriMatcher(
                 Collections.<String>emptySet(),
                 false,
                 "an authentication method");
 
         static final UriMatcher HTTPS_ONLY_MATCHER = new UriMatcher(
                 Collections.singleton(SCHEME_HTTPS),
                 true,
                 "an https URL");
 
         static final UriMatcher WEB_MATCHER = new UriMatcher(
                 new HashSet<>(Arrays.asList(SCHEME_HTTP, SCHEME_HTTPS)),
                 true,
                 "a web URL");
 
         final Set<String> mPermittedSchemes;
         final boolean mAllowPathQueryOrFragment;
+        final String mUriDescriptor;
 
         UriMatcher(
                 Set<String> permittedSchemes,
                 boolean allowPathQueryOrFragment,
                 String uriDescriptor) {
             super(uriDescriptor);
             mPermittedSchemes = permittedSchemes;
             mAllowPathQueryOrFragment = allowPathQueryOrFragment;
+            mUriDescriptor = uriDescriptor;
         }
 
         @Override
         protected boolean matchesSafely(Uri item) {
             if (!item.isAbsolute()
                     || !item.isHierarchical()
                     || TextUtils.isEmpty(item.getScheme())
                     || TextUtils.isEmpty(item.getAuthority())) {
                 return false;
             }
 
             if (!mPermittedSchemes.isEmpty() && !mPermittedSchemes.contains(item.getScheme())) {
                 return false;
             }
 
             if (mAllowPathQueryOrFragment) {
                 return true;
             }
 
             return TextUtils.isEmpty(item.getPath())
                     && item.getQuery() == null
                     && item.getFragment() == null;
         }
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
index dfa7f67..057b991 100644
--- a/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
+++ b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
@@ -46,188 +46,173 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Unit tests for {@link AuthenticationDomain}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AuthenticationDomainTest {
 
+    private static final String WEB_AUTH_DOMAIN_STR = "https://www.example.com";
+
     private static final String VALID_PACKAGE_NAME = "com.example.app";
 
     private static byte[] VALID_SIGNATURE_BYTES = new byte[]
             { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
     private static final String VALID_FINGERPRINT =
             "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                     + "7V4Lo8BdCxaA307H0HYkAw==";
 
     private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
             "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
 
     private static final PackageInfo VALID_PACKAGE_INFO = makeValidPackageInfo();
 
     private static PackageInfo makeValidPackageInfo() {
         PackageInfo packageInfo = new PackageInfo();
         packageInfo.signatures = new Signature[2];
         packageInfo.signatures[0] = new Signature(VALID_SIGNATURE_BYTES);
         packageInfo.signatures[1] = new Signature(new byte[16]);
 
         return packageInfo;
     }
 
     @Mock
     PackageManager mockPackageManager;
     @Mock
     Context mockContext;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenReturn(VALID_PACKAGE_INFO);
         when(mockContext.getPackageName()).thenReturn(VALID_PACKAGE_NAME);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
     }
 
     @Test
     public void getSelfAuthDomain_withValidInput_returnsValidDomain() throws Exception {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain).isNotNull();
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.toString())
                 .isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test
     public void listForPackage_forValidPackage_containsValidAuthenticationDomain() {
         assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME))
                 .contains(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
     }
 
     @Test
     public void listForPackage_forNullPackageName_returnsEmpty() throws Exception {
         assertThat(AuthenticationDomain.listForPackage(mockContext, null /* package */)).isEmpty();
     }
 
     @Test
     public void listForPackage_packageDoesNotExist_returnsEmpty() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenAnswer(new Answer<PackageInfo>() {
                     @Override
                     public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                         throw new NameNotFoundException();
                     }
                 });
 
         assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME)).isEmpty();
     }
 
-    @Test
-    public void getUri_returnsExpectedValue() throws Exception{
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-
-        assertThat(authDomain.getUri().toString()).isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
-    }
-
     @Test(expected = RequireViolation.class)
     public void CreateAndroidAuthDomain_withNullDomain_throwsRequireViolation() throws Exception{
         AuthenticationDomain.createAndroidAuthDomain(null /* authDomain */, mock(Signature.class));
     }
 
     @Test
     public void validWebAuthDomain_hasExpectedBehaviour() {
         AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
 
         assertThat(authDomain.isAndroidAuthDomain()).isFalse();
         assertThat(authDomain.isWebAuthDomain()).isTrue();
 
         try {
             authDomain.getAndroidPackageName();
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void validAndroidAuthDomain_hasExpectedBehaviour(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.isWebAuthDomain()).isFalse();
 
         assertThat(authDomain.getAndroidPackageName()).isEqualTo(VALID_PACKAGE_NAME);
     }
 
     @Test
     public void getSelfAuthDomain_packageNotFoundException_throwsException() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
             .thenAnswer(new Answer<PackageInfo>() {
                 @Override
                 public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                     throw new NameNotFoundException();
                 }
             });
 
         try {
             AuthenticationDomain.getSelfAuthDomain(mockContext);
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void stringsToAuthDomainsConverter_withValidInput_returnsExpectValues()
             throws Exception {
         List<String> domains = new ArrayList<>();
         domains.add("https://www.google.com");
         domains.add("https://www.yahoo.com");
         domains.add("https://www.facebook.com");
 
         List<AuthenticationDomain> result =
                 CollectionConverter.toList(
                         domains,
                         AuthenticationDomainConverters.STRING_TO_DOMAIN);
 
         assertThat(result.size()).isEqualTo(3);
 
-        assertThat(result.get(0).getUri().toString()).isEqualTo(domains.get(0));
-        assertThat(result.get(1).getUri().toString()).isEqualTo(domains.get(1));
-        assertThat(result.get(2).getUri().toString()).isEqualTo(domains.get(2));
-    }
-
-    @Test
-    public void hashCode_ofAuthDomainAndEquivalentUri_areEqual(){
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        Uri authDomainUri = authDomain.getUri();
-
-        assertThat(authDomain.hashCode()).isEqualTo(authDomainUri.hashCode());
-    }
-
-    @Test
-    public void hashCode_ofAuthDomainAndUnequalUri_areNotEqual(){
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        Uri authDomainUri = authDomain.getUri();
-
-        assertThat(authDomain.hashCode()).isEqualTo(authDomainUri.hashCode());
+        assertThat(result.get(0).toString()).isEqualTo(domains.get(0));
+        assertThat(result.get(1).toString()).isEqualTo(domains.get(1));
+        assertThat(result.get(2).toString()).isEqualTo(domains.get(2));
     }
 
     @Test
     public void equals_withEquivalent_returnsTrue() throws Exception {
         AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mockContext);
         AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomainA).isEqualTo(authDomainA);
         assertThat(authDomainA).isEqualTo(authDomainB);
 
         assertThat(authDomainA.compareTo(authDomainB)).isEqualTo(0);
     }
 
     @Test
     public void equals_withDifferentType_returnsFalse() throws Exception {
-        final String authenticationDomainString = "https://www.example.com";
-        AuthenticationDomain domain = new AuthenticationDomain(authenticationDomainString);
+        AuthenticationDomain domain = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
+        assertThat(domain).isNotEqualTo(WEB_AUTH_DOMAIN_STR);
+    }
+
+    @Test
+    public void testHashCode_equivalent() throws Exception {
+        AuthenticationDomain authDomainA = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
+        AuthenticationDomain authDomainB = new AuthenticationDomain(WEB_AUTH_DOMAIN_STR);
 
-        assertThat(domain).isNotEqualTo(authenticationDomainString);
+        assertThat(authDomainA.hashCode()).isEqualTo(authDomainB.hashCode());
     }
 
 }
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 8ba9281..83bd4a0 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -30,248 +30,248 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     public static final String EMAIL_ID = "alice@example.com";
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithoutScheme() {
-        new Credential.Builder(EMAIL_ID, Uri.parse("www.example.com"), AUTH_DOMAIN);
+        new Credential.Builder(EMAIL_ID, "www.example.com", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithPath() {
-        new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com/path"), AUTH_DOMAIN);
+        new Credential.Builder(EMAIL_ID, "https://www.example.com/path", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithQuery() {
-        new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com?a=b"), AUTH_DOMAIN);
+        new Credential.Builder(EMAIL_ID, "https://www.example.com?a=b", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithFragment() {
-        new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com#a"), AUTH_DOMAIN);
+        new Credential.Builder(EMAIL_ID, "https://www.example.com#a", AUTH_DOMAIN_STR);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
-        Protobufs.Credential proto = cr.getProto();
+        Protobufs.Credential proto = cr.toProtobuf();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
index 5c372a6..a92c9f4 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
@@ -32,317 +32,263 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link HintRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRequest request = new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .addAdditionalProperty("a", new byte[] { 1, 2, 3})
                 .addAdditionalProperty("b", "hello")
                 .setPasswordSpecification(originalSpec)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
 
         assertThat(request.getAdditionalProperties())
                 .containsOnly(
                         entry("a", new byte[] {1, 2, 3}),
                         entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
 
         assertThat(request.getAdditionalProperty("a")).isEqualTo(new byte[] {1, 2, 3});
         assertThat(request.getAdditionalPropertyAsString("b")).isEqualTo("hello");
 
         assertThat(request.getAdditionalProperty("c")).isNull();
         assertThat(request.getAdditionalPropertyAsString("d")).isNull();
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRequest request = new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testForEmailAndPasswordAccount() {
         HintRequest request = HintRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testSerialize() {
         HintRequest request = new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRequest read = HintRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullRequestProto() {
         new HintRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
-        new HintRequest.Builder((Uri) null).build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_constructor_nullString() {
-        new HintRequest.Builder((String) null).build();
+        new HintRequest.Builder((AuthenticationMethod) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriSet() {
-        new HintRequest.Builder((Set<Uri>) null).build();
+        new HintRequest.Builder((Set<AuthenticationMethod>) null).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRequest.Builder(
                 AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = RequireViolation.class)
-    public void testBuild_constructor_nullStringInVarargs() {
+    public void testBuild_constructor_nullInVarargs() {
         new HintRequest.Builder(
-                "custom://auth-method",
+                AuthenticationMethods.EMAIL,
                 null,
-                "custom://another-auth-method")
+                AuthenticationMethods.PHONE)
                 .build();
     }
 
-    @Test(expected = RequireViolation.class)
-    public void testBuild_constructor_invalidAuthMethodString() {
-        new HintRequest.Builder("notAnAuthMethod").build();
-    }
-
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_emptySet() {
-        new HintRequest.Builder(new HashSet<Uri>()).build();
+        new HintRequest.Builder(new HashSet<AuthenticationMethod>()).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_setContainingNull() {
-        HashSet<Uri> authMethods = new HashSet<>();
+        HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAuthenticationMethods((Uri) null)
+                .setAuthenticationMethods((AuthenticationMethod) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setAuthenticationMethods_nullString() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAuthenticationMethods((String) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setAuthenticationMethods_nullStringInVarargs() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAuthenticationMethods(
-                        "custom://auth-method",
-                        null,
-                        "custom://another-auth-method")
-                .build();
-    }
-
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAuthenticationMethods((Set<Uri>) null)
+                .setAuthenticationMethods(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .setAuthenticationMethods(new HashSet<Uri>())
+                .setAuthenticationMethods(new HashSet<AuthenticationMethod>())
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
-        HashSet<Uri> authMethods = new HashSet<>();
+        HashSet<AuthenticationMethod> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAuthenticationMethod((Uri) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAuthenticationMethod_nullString() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAuthenticationMethod((String) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAuthenticationMethod_emptyString() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAuthenticationMethod("")
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addAuthenticationMethod_invalidString() {
-        new HintRequest.Builder(AuthenticationMethods.EMAIL)
-                .addAuthenticationMethod("notAnAuthMethod")
+                .addAuthenticationMethod(null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullMap() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(null)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullKey() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty(null, "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_emptyKey() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("", "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullByteArrayValue() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (byte[]) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullStringValue() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
index 3300fe5..c128acd 100644
--- a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
@@ -35,98 +35,98 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveRequestTest {
 
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
     private RetrieveRequest request;
 
     @Before
     public void setUp() {
         request = new RetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("a", "b")
                 .addAdditionalProperty("c", testBytes)
                 .build();
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
                     deserialized.getAdditionalProperties(),
                     request.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
-        new RetrieveRequest.Builder(new HashSet<Uri>()  /* authenticationMethods */);
+        new RetrieveRequest.Builder(new HashSet<AuthenticationMethod>());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
         new RetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         RetrieveRequest request = RetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
-        Set<Uri> authenticationMethods = new HashSet<>();
+        Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testGetAdditionalProperties() {
         assertThat(request.getAdditionalProperties()).isNotNull();
         assertThat(request.getAdditionalProperties()).hasSize(2);
         assertThat(request.getAdditionalPropertyAsString("a")).isEqualTo("b");
         assertThat(request.getAdditionalProperty("c")).isEqualTo(testBytes);
     }
 
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.EMAIL);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
         Protobufs.CredentialRetrieveRequest.parseFrom((byte[]) null);
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
index 0816f67..4694dda 100644
--- a/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
@@ -38,75 +38,75 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for the RetrieveIntent class
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveResultTest {
 
     private RetrieveResult underTest;
 
     @Before
     public void setUp() throws Exception {
         Intent fromIntent = new Intent("com.openyolo.ACTION");
         fromIntent.setPackage("com.openyolo");
         byte[] fromBytes = IntentUtil.toBytes(fromIntent);
         Intent retrieveIntent= IntentUtil.fromBytes(fromBytes);
 
-        Map<String, Protobufs.CredentialRetrieveResponse> protoResponses = new HashMap<>();
+        Map<String, Protobufs.CredentialRetrieveBbqResponse> protoResponses = new HashMap<>();
 
         underTest = new RetrieveResult.Builder()
                 .setProtoResponses(protoResponses)
                 .setRetrieveIntent(retrieveIntent)
                 .build();
     }
 
     @Test
     public void testGetRetrieveIntent(){
         Intent intent = underTest.getRetrieveIntent();
         assertNotNull(intent);
     }
 
     @Test
     public void testGetResponderPackageNames(){
         Set<String> responders = underTest.getResponderPackageNames();
         assertNotNull(responders);
     }
 
     @Test(expected = RequireViolation.class)
     public void testGetRetrieveIntentForResponder_null(){
         underTest.getRetrieveIntentForResponder(null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testGetRetrieveIntentForResponder_illegal(){
         underTest.getRetrieveIntentForResponder("BLahblah");
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         underTest.writeToParcel(p, 0);
         p.setDataPosition(0);
 
         RetrieveResult result = RetrieveResult.CREATOR.createFromParcel(p);
         checkIntentsEquivalent(underTest.getRetrieveIntent(), result.getRetrieveIntent());
         assertThat(result.getResponderPackageNames())
                 .isEqualTo(underTest.getResponderPackageNames());
 
         for (String responder : result.getResponderPackageNames()) {
             checkIntentsEquivalent(
                     underTest.getRetrieveIntentForResponder(responder),
                     result.getRetrieveIntentForResponder(responder));
 
             assertThat(result.getAdditionalPropsForResponder(responder))
                     .isEqualTo(underTest.getAdditionalPropsForResponder(responder));
         }
     }
 
     private void checkIntentsEquivalent(Intent expected, Intent actual) {
         // NOTE: we don't check the full intent, just the basic properties
         assertThat(actual.getPackage())
                 .isEqualTo(expected.getPackage());
         assertThat(actual.getAction())
                 .isEqualTo(expected.getAction());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java b/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
index 5a54e83..cb5fbe2 100644
--- a/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
+++ b/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
@@ -31,108 +31,108 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for the custom Matchers suite extending hamcrest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CustomMatchersTest {
     @Test
     public void isWebUri_http() throws Exception {
         assertTrue(CustomMatchers.isWebUri().matches(Uri.parse("http://www.blah.com")));
     }
 
     @Test
     public void isWebUri_https() throws Exception {
         assertTrue(CustomMatchers.isWebUri().matches(Uri.parse("https://www.blah.com")));
     }
 
     @Test
     public void isWebUri_noproto() throws Exception {
         assertFalse(CustomMatchers.isWebUri().matches(Uri.parse("www.blah.com")));
     }
 
     @Test
     public void isWebUri_ftp() throws Exception {
         assertFalse(CustomMatchers.isWebUri().matches(Uri.parse("ftp://www.blah.com")));
     }
 
     @Test
     public void isHttpsUri() throws Exception {
         assertTrue(CustomMatchers.isHttpsUri().matches(Uri.parse("https://www.blah.com")));
     }
 
     @Test
     public void isHttpsUri_withPath() {
         assertTrue(CustomMatchers.isHttpsUri().matches(
                 Uri.parse("https://www.blah.com/resource")));
     }
 
     @Test
     public void isHttpsUri_withQuery() {
         assertTrue(CustomMatchers.isHttpsUri().matches(
                 Uri.parse("https://www.blah.com/resource?a=b")));
     }
 
     @Test
     public void isHttpsUri_withFragment() {
         assertTrue(CustomMatchers.isHttpsUri().matches(
                 Uri.parse("https://www.blah.com/resource#entry")));
     }
 
     @Test
     public void isHttpsUri_http() {
         assertFalse(CustomMatchers.isHttpsUri().matches(Uri.parse("http://www.blah.com")));
     }
 
     @Test
-    public void isValidAuthenticationDomain_http() throws Exception {
-        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
-                Uri.parse("http://www.blah.com")));
+    public void isValidAuthenticationDomainUri_http() throws Exception {
+        String uriStr = "http://www.blah.com";
+        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(uriStr));
+        assertTrue(CustomMatchers.isValidAuthenticationDomainUri().matches(Uri.parse(uriStr)));
     }
 
     @Test
     public void isValidAuthenticationDomain_https() throws Exception {
-        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
-                Uri.parse("https://www.blah.com")));
+        String uriStr = "https://www.blah.com";
+        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(uriStr));
+        assertTrue(CustomMatchers.isValidAuthenticationDomainUri().matches(Uri.parse(uriStr)));
     }
 
     @Test
     public void isValidAuthenticationDomain_android() throws Exception {
-        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
-                Uri.parse("android://signature@com.blah.app")));
+        String uriStr = "android://signature@com.blah.app";
+        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(uriStr));
+        assertTrue(CustomMatchers.isValidAuthenticationDomainUri().matches(Uri.parse(uriStr)));
     }
 
     @Test
-    public void isValidAuthenticationDomain() throws Exception {
-        assertFalse(CustomMatchers.isValidAuthenticationDomain().matches(
-                Uri.parse("http://www.blah.com/resource")));
+    public void isValidAuthenticationDomain_path() throws Exception {
+        String uriStr = "http://www.blah.com/resource";
+        assertFalse(CustomMatchers.isValidAuthenticationDomain().matches(uriStr));
+        assertFalse(CustomMatchers.isValidAuthenticationDomainUri().matches(Uri.parse(uriStr)));
     }
 
     @Test
-    public void isValidAuthenticationMethod_builtIn() throws Exception {
-        assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(
-                AuthenticationMethods.EMAIL));
+    public void isValidAuthenticationMethodUri_custom() {
+        String uriStr = "https://www.blah.com";
+        assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(uriStr));
+        assertTrue(CustomMatchers.isValidAuthenticationMethodUri().matches(Uri.parse(uriStr)));
     }
 
     @Test
-    public void isValidAuthenticationMethod_custom() {
-        assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(
-                Uri.parse("https://www.blah.com")));
-    }
-
-    @Test
-    public void isValidAuthenticationMethod_path() {
-        assertFalse(CustomMatchers.isValidAuthenticationMethod().matches(
-                Uri.parse("http://www.blah.com/resource")));
+    public void isValidAuthenticationMethodUri_path() {
+        String uriStr = "http://www.blah.com/resource";
+        assertFalse(CustomMatchers.isValidAuthenticationMethod().matches(uriStr));
+        assertFalse(CustomMatchers.isValidAuthenticationMethodUri().matches(Uri.parse(uriStr)));
     }
 
     @Test
     public void nullOr_null() {
         Matcher<Uri> matcher = CustomMatchers.nullOr(CustomMatchers.isHttpsUri());
         assertTrue(matcher.matches(null));
     }
 
     @Test
     public void nullOr_Https() {
         Matcher<Uri> matcher = CustomMatchers.nullOr(CustomMatchers.isHttpsUri());
         assertTrue(matcher.matches(Uri.parse("https://www.blah.com")));
     }
 }
\ No newline at end of file
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index ade34b7..9b31b34 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -24,30 +24,26 @@ option java_outer_classname = "Protobufs";
 message CredentialRetrieveRequest {
     // at least one authMethod required
-    repeated string authMethods = 1;
-    map<string, TokenRequestInfo> supportedTokenProviders = 2;
-    map<string, bytes> additionalProps = 3;
+    repeated AuthenticationMethod authMethods = 1;
+
+    map<string, TokenRequestInfo> supportedTokenProviders = 3;
+    map<string, bytes> additionalProps = 4;
 }
 
-message CredentialRetrieveResponse {
+message CredentialRetrieveBbqResponse {
     bytes retrieveIntent = 1;
     map<string, bytes> additionalProps = 2;
 }
 
-message CredentialRetrieveResponseList {
-    repeated CredentialRetrieveResponse responses = 1;
-}
-
 message HintRetrieveRequest {
     // at least one authMethod required
-    repeated string authMethods = 1;
+    repeated AuthenticationMethod authMethods = 1;
 
     PasswordSpecification passwordSpec = 2;
     map<string, TokenRequestInfo> supportedTokenProviders = 3;
     map<string, bytes> additionalProps = 4;
 }
 
-message TokenRequestInfo {
-    string clientId = 1;
-    string nonce = 2;
-    map<string, bytes> additionalProps = 3;
+message HintRetrieveResult {
+    Credential credential = 1;
+    map<string, bytes> additionalProps = 2;
 }
@@ -55,13 +51,16 @@ message TokenRequestInfo {
 message Credential {
-    // required fields:
+    // required
     string id = 1;
-    string authDomain = 2;
-    string authMethod = 3;
 
-    // optional fields:
+    // required
+    AuthenticationDomain authDomain = 2;
+
+    // required
+    AuthenticationMethod authMethod = 3;
+
     string displayName = 4;
     string displayPictureUri = 5;
     string password = 6;
     string idToken = 7;
     map<string, bytes> additionalProps = 8;
 }
@@ -72,10 +71,23 @@ message CredentialList {
 
+message AuthenticationMethod {
+    // required
+    string uri = 1;
+}
+
+message AuthenticationDomain {
+    // required
+    string uri = 1;
+}
+
 message PasswordSpecification {
-    // required fields:
+    // required
     string allowed = 1;
+
+    // required
     uint32 minSize = 2;
+
+    // required
     uint32 maxSize = 3;
 
-    // optional:
     repeated RequiredCharSet requiredSets = 4;
 }
@@ -83,5 +95,13 @@ message PasswordSpecification {
 message RequiredCharSet {
-    // all fields required
+    // required
     string chars = 1;
+
+    // required
     uint32 count = 2;
-}
\ No newline at end of file
+}
+
+message TokenRequestInfo {
+    string clientId = 1;
+    string nonce = 2;
+    map<string, bytes> additionalProps = 3;
+}
diff --git a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
index 41ab721..75e5b40 100644
--- a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
+++ b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
@@ -18,3 +18,5 @@ import android.content.Intent;
 import android.support.annotation.Nullable;
-import org.openyolo.protocol.Protobufs.Credential;
+
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.Protobufs;
 import org.openyolo.protocol.ProtocolConstants;
@@ -22,17 +24,26 @@ import org.openyolo.protocol.ProtocolConstants;
 /**
  * Utility methods for expressing and manipulating the result of a credential retrieve intent.
  */
 public final class RetrieveIntentResultUtil {
 
     /**
      * Creates an {@link android.content.Intent} wrapper for the result of a credential retrieve
      * intent.
      */
     public static Intent createResponseData(@Nullable Credential credential) {
+        return createResponseData(
+                credential != null ? credential.toProtobuf() : null);
+    }
+
+    /**
+     * Creates an {@link android.content.Intent} wrapper for the result of a credential retrieve
+     * intent.
+     */
+    public static Intent createResponseData(@Nullable Protobufs.Credential credential) {
         Intent responseData = new Intent();
         if (credential != null) {
             responseData.putExtra(ProtocolConstants.EXTRA_CREDENTIAL, credential.toByteArray());
         }
         return responseData;
     }
 }
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
index 404eb13..ccd419a 100644
--- a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -42,2 +42,4 @@ import org.mockito.MockitoAnnotations;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethod;
+import org.openyolo.protocol.Protobufs;
 import org.openyolo.protocol.Protobufs.CredentialRetrieveRequest;
@@ -48,153 +50,154 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link BaseCredentialQueryReceiver}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE,
         shadows = {
                 ShadowQueryResponseSender.class,
                 ShadowAuthenticationDomain.class
         })
 public class BaseCredentialQueryReceiverTest {
 
     private BaseCredentialQueryReceiver credentialQueryReceiver;
 
     @Mock
     Context mockContext;
 
     private static final String CALLING_PACKAGE_NAME = "org.openyolo.supercoolapp";
 
     private static final BroadcastQuery QUERY_WITH_NULL_MESSAGE =
             makeQueryFromRequest(null /* request */);
 
     private static final BroadcastQuery QUERY_WITH_INVALID_REQUEST =
             makeQueryFromRequest(makeInvalidCredentialRetrieveRequest());
 
     private static final BroadcastQuery QUERY_WITH_VALID_REQUEST =
             makeQueryFromRequest(makeValidCredentialRetrieveRequest());
 
     private static final List<AuthenticationDomain> VALID_AUTHENTICATION_DOMAINS =
             makeValidAuthenticationDomains();
 
 
     private static BroadcastQuery makeQueryFromRequest(
             @Nullable CredentialRetrieveRequest request) {
         BroadcastQuery.Builder builder = BroadcastQuery.newBuilder()
                 .setRequestingApp(CALLING_PACKAGE_NAME)
                 .setDataType("blah")
                 .setRequestId(101L)
                 .setResponseId(102L);
 
         if (request != null) {
             builder.setQueryMessage(ByteString.copyFrom(request.toByteArray()));
         }
 
         return builder.build();
     }
 
     private static List<AuthenticationDomain> makeValidAuthenticationDomains() {
         List<AuthenticationDomain> authenticationDomains = new ArrayList<>();
         authenticationDomains.add(mock(AuthenticationDomain.class));
 
         return authenticationDomains;
     }
 
     private static CredentialRetrieveRequest makeInvalidCredentialRetrieveRequest() {
         // Invalid because it does not specify a non-empty set of authentication method
         return CredentialRetrieveRequest.newBuilder().build();
     }
 
     private static CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
         return CredentialRetrieveRequest.newBuilder()
-            .addAuthMethods("custom://one")
-            .addAuthMethods("custom://two")
+            .addAuthMethods(new AuthenticationMethod("custom://one").toProtobuf())
+            .addAuthMethods(new AuthenticationMethod("custom://two").toProtobuf())
             .build();
     }
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         ShadowQueryResponseSender.intializeForTest();
 
         credentialQueryReceiver = spy(
                 new BaseCredentialQueryReceiver("TestCredentialQueryReceiver") {
                     @Override
                     protected void processCredentialRequest(
                             @NonNull Context context,
                             @NonNull BroadcastQuery query,
                             @NonNull RetrieveRequest request,
                             @NonNull Set<AuthenticationDomain> requestorDomains) {
                         // Do nothing
                     }
                 });
 
         ShadowAuthenticationDomain.setListForPackageResponse(VALID_AUTHENTICATION_DOMAINS);
     }
 
     @Test
     public void processQuery_withNullQuery_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_NULL_MESSAGE);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withInvalidRequest_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_INVALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withValidRequest_processesRequest() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasCalled();
         verifyQueryResponseIsNotSent();
     }
 
     @Test
     public void processQuery_withValidRequestAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
             throws Exception {
-        ShadowAuthenticationDomain.setListForPackageResponse(Collections.EMPTY_LIST);
+        ShadowAuthenticationDomain.setListForPackageResponse(
+                Collections.<AuthenticationDomain>emptyList());
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     private void verifyQueryResponseIsNotSent() {
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(0))
                 .sendResponse((BroadcastQuery) any(), (byte[]) any());
     }
 
     private void verifyQueryResponseIsSentWith(@Nullable byte[] response) {
         if (null == response) {
             verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                     .sendResponse((BroadcastQuery) any(), (byte[]) isNull());
             return;
         }
 
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                 .sendResponse((BroadcastQuery) any(), eq(response));
     }
 
     private void verifyProcessCredentialRequestWasCalled() {
         verify(credentialQueryReceiver, times(1))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (RetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 
     private void verifyProcessCredentialRequestWasNotCalled() {
         verify(credentialQueryReceiver, times(0))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (RetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
index 11f3da2..967f9b9 100644
--- a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
+++ b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
@@ -34,31 +34,30 @@ import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
 /**
  * Battery of tests for RetrieveIntentResultUtil
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveIntentResultUtilTest {
     public static final String EMAIL_ID = "alice@example.com";
 
     @Test
     public void testCreateResponseData() throws Exception {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .build();
-        Intent response = RetrieveIntentResultUtil.createResponseData(cr.getProto());
+        Intent response = RetrieveIntentResultUtil.createResponseData(cr.toProtobuf());
 
         assertThat(response.hasExtra(ProtocolConstants.EXTRA_CREDENTIAL)).isTrue();
         byte[] bytes = response.getExtras().getByteArray(ProtocolConstants.EXTRA_CREDENTIAL);
         Credential credential = Credential.fromProtoBytes(bytes);
         assertThat(credential.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(credential.getAuthenticationMethod()).isEqualTo(EMAIL);
     }
 
     @Test
     public void testCreateResponseData_withNull() throws Exception {
-        Intent response = RetrieveIntentResultUtil.createResponseData(null);
+        Intent response = RetrieveIntentResultUtil.createResponseData((Credential) null);
         assertNull(response.getExtras());
     }
-
 }
\ No newline at end of file
diff --git a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
index 064dcd4..e96240f 100644
--- a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
+++ b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
@@ -17,4 +17,4 @@ package org.openyolo.testapp;
 import android.content.Context;
-import android.net.Uri;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.View;
@@ -27,90 +27,99 @@ import java.util.HashSet;
 import java.util.Set;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
+import org.valid4j.errors.RequireViolation;
 
 public final class AuthenticationMethodsInputView extends LinearLayout {
 
+    private static final String TAG = "AuthMethodsInputView";
+
     @BindView(R.id.facebook_authentication_method_checkbox)
     CheckBox mFaceBookCheckBox;
 
     @BindView(R.id.google_authentication_method_checkbox)
     CheckBox mGoogleCheckBox;
 
     @BindView(R.id.email_authentication_method_checkbox)
     CheckBox mEmailCheckBox;
 
     @BindView(R.id.custom_authentication_method_checkbox)
     CheckBox mCustomAuthenticationMethodCheckBox;
 
     @BindView(R.id.custom_authentication_method)
     EditText mCustomAuthenticationMethod;
 
     /**
      * Simple constructor to use when creating an authentication method selection view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public AuthenticationMethodsInputView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public AuthenticationMethodsInputView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public AuthenticationMethodsInputView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.authentication_method_input_layout, this);
 
         ButterKnife.bind(view);
     }
 
     /**
      * @return A set of authentication domains that are marked as enabled.
      */
-    public Set<Uri> getEnabledAuthenticationMethods() {
-        Set<Uri> authenticationMethods = new HashSet<>();
+    public Set<AuthenticationMethod> getEnabledAuthenticationMethods() {
+        Set<AuthenticationMethod> authenticationMethods = new HashSet<>();
 
         if (mFaceBookCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.FACEBOOK);
         }
 
         if (mGoogleCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.GOOGLE);
         }
 
         if (mEmailCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.EMAIL);
         }
 
         if (mCustomAuthenticationMethodCheckBox.isChecked()) {
-            Uri authenticationMethod = Uri.parse(mCustomAuthenticationMethod.getText().toString());
-            authenticationMethods.add(authenticationMethod);
+            String customAuthMethodStr = mCustomAuthenticationMethod.getText().toString();
+            try {
+                authenticationMethods.add(new AuthenticationMethod(customAuthMethodStr));
+            } catch (RequireViolation ex) {
+                Log.w(TAG, "Authentication method " + customAuthMethodStr
+                        + " is invalid, ignoring");
+            }
         }
 
         return authenticationMethods;
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index ff8279d..64034b6 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -21,2 +21,3 @@ import android.support.annotation.Nullable;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.View;
@@ -32,2 +33,3 @@ import com.bumptech.glide.Glide;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
@@ -35,215 +37,223 @@ import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.PasswordSpecification;
+import org.valid4j.errors.RequireViolation;
 
 public final class CredentialView extends LinearLayout {
 
+    private static final String TAG = "CredentialView";
+
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_email_provider_button)
     ImageButton mEmailProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
     /**
      * Simple constructor to use when creating a credential view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mEmailProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void setEmailAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
         Glide.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
-        String authenticationMethod = mAuthenticationMethodField.getText().toString();
-        Uri authMethodUri = Uri.parse(authenticationMethod);
+        String authMethodStr = mAuthenticationMethodField.getText().toString();
+        AuthenticationMethod authMethod;
+        try {
+            authMethod = new AuthenticationMethod(authMethodStr);
+        } catch (RequireViolation ex) {
+            Log.w(TAG, "User entered authentication method " + authMethodStr + " is invalid", ex);
+            return null;
+        }
+
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
-                authMethodUri,
+                authMethod,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
-        if (authMethodUri.equals(AuthenticationMethods.EMAIL)) {
-            credentialBuilder.setPassword(mPasswordField.getText().toString());
-        }
+        credentialBuilder.setPassword(mPasswordField.getText().toString());
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index ad5552c..4c099f4 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -20,3 +20,2 @@ import static android.app.Activity.RESULT_OK;
 import android.content.Intent;
-import android.net.Uri;
 import android.os.Bundle;
@@ -32,2 +31,3 @@ import butterknife.OnClick;
 import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.AuthenticationMethods;
@@ -35,105 +35,108 @@ import org.openyolo.protocol.Credential;
 import org.openyolo.protocol.HintRequest;
+import org.valid4j.errors.RequireViolation;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_method_text_input)
     EditText mAuthenticationMethodInput;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
-        String uriString = mAuthenticationMethodInput.getText().toString();
-        if (uriString.isEmpty()) {
+        String authMethodStr = mAuthenticationMethodInput.getText().toString();
+        AuthenticationMethod authMethod;
+        try {
+            authMethod = new AuthenticationMethod(authMethodStr);
+        } catch (RequireViolation ex) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
-        Uri authMethodUri = Uri.parse(uriString);
 
-        HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethodUri);
+        HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethod);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.openyolo_email_provider_button)
     void onEmailAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index 5d7891e..f6b59ed 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -21,3 +21,2 @@ import android.content.ActivityNotFoundException;
 import android.content.Intent;
-import android.net.Uri;
 import android.os.Bundle;
@@ -35,2 +34,3 @@ import org.openyolo.api.CredentialClient;
 import org.openyolo.api.RetrieveCallback;
+import org.openyolo.protocol.AuthenticationMethod;
 import org.openyolo.protocol.Credential;
@@ -40,116 +40,116 @@ import org.openyolo.protocol.RetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
-        Set<Uri> authenticationMethods =
+        Set<AuthenticationMethod> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 2cbf51a..8de7fec 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,57 +1,57 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
     <string name="no_credentials">No credentials available</string>
     <string name="retrieve_cancelled">Credential retrieve cancelled</string>
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_cancelled">Hint retrieve cancelled</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
-    <string name="authentication_field_required">Must select authentication method</string>
+    <string name="authentication_field_required">Must select or enter valid authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
     <string name="no_credential_returned">No credential returned</string>
 </resources>

commit 9d136d2a55ed9fe3d7ed07a388c24d4466416a22
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue Apr 25 16:39:31 2017 -0700

    Remove old spec source, add link to the official spec.

diff --git a/README.md b/README.md
index b46bd2c..4a20026 100644
--- a/README.md
+++ b/README.md
@@ -10,5 +10,4 @@ any installed credential provider on the device.
 
-This repository contains the
-[OpenYOLO Specification](https://github.com/openid/OpenYOLO-Android/tree/master/spec/en) and
-reference implementation.
+This repository contains the reference implementation of the OpenYOLO protocol,
+and the standard API and Service Provider Interface (SPI).
 
@@ -25,3 +24,12 @@ and ready for production use, an official announcement shall be made and both
 the specification and reference implementation will be promoted to v1.0.0.
 
+## OpenYOLO Specification
+
+The OpenYOLO for Android specification can be found 
+[here](https://spec.openyolo.org/openyolo-android-spec.html). This is
+currently under review by the 
+[Account Chooser and OpenYOLO Working Group](http://openid.net/wg/ac/),
+with the intention for it to become an implementor's draft by Q3 2017,
+and reach full standardization by Q4 2017.
+
 [yolo]: https://developers.google.com/identity/smartlock-passwords/android/
diff --git a/spec/.gitignore b/spec/.gitignore
deleted file mode 100644
index f174344..0000000
--- a/spec/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-_book
diff --git a/spec/LANGS.md b/spec/LANGS.md
deleted file mode 100644
index f8515ab..0000000
--- a/spec/LANGS.md
+++ /dev/null
@@ -1,5 +0,0 @@
-* [English](en)
-
-<!--
-* [French](fr)
--->
diff --git a/spec/en/README.md b/spec/en/README.md
deleted file mode 100644
index 1b8d2e3..0000000
--- a/spec/en/README.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# The OpenYOLO Specification
-
-OpenYOLO is a protocol for retrieving, updating and assisting in the creation of
-user credentials for Android apps. The protocol is intended to work on any
-Android 15+ device, and has no mandatory dependencies on Google-specific
-software or infrastructure, such as Google Play Services or the
-Google Play Store.
-
-This document describes the OpenYOLO protocol, and the underlying
-Background Broadcast Query protocol (BBQ) upon which it is built, and the
-APIs that simplify their usage:
-
-- The [OpenYOLO overview](openyolo-overview.md) chapter describes the high
-  level concepts and operations that OpenYOLO provides.
-
-- The [BBQ protocol](bbq-protocol.md) chapter describes the broadcast intent based
-  mechanism that is used to communicate with multiple credential providers
-  simultaneously. This is primarily used by the credential request flow.
-
-- [Retrieving credentials](retrieving-credentials.md) describes in detail the
-  flow for retrieving a credential from one of the providers installed on a
-  user's device, and allows for automatic sign-in to applications in most
-  cases.
-
-- [Assisting sign-up](assisting-sign-up.md) describes in detail the mechanism
-  by which a credential provider can provide information to "bootstrap" a new
-  account for an app. This typically allows the app to bypass the majority of
-  the manual text entry that is required for new account creation.
-
-- [Saving credentials](saving-credentials.md) describes in detail the flow for
-  saving and updating credentials, allowing an app to increase the chances that
-  a credential can be automatically retrieved upon future installations.
-
-- [Protecting users from malicious providers](protecting-users.md) describes
-  the technical counter-measures employed by the OpenYOLO API to minimize
-  the risk of credential theft and spoofing by malicious apps.
-
-- The [OpenYOLO API](api-overview.md) chapter describes the high-level API that
-  allows apps to retrieve and save credentials, and request assisted sign-up.
-
-- The [OpenYOLO SPI](spi-overview.md) chapter describes the Service Provider
-  Interface which helps credential providers to support the OpenYOLO protocol.
-
-App developers who wish to use OpenYOLO should read the
-[OpenYOLO overview](openyolo-overview.md) and the
-[API overview](api-overview.md) chapters. The other chapters may be of interest
-but are not pertinent to simply using the API. Those who are implementing
-OpenYOLO in a credential provider should read all chapters.
-
-## Authors
-
-* Iain McGinniss ([@iainmcgin](https://github.com/iainmcgin)), Google Inc.
-
-## Errata
-
-Queries and errata related to the specification should
-be filed as [GitHub issues](https://github.com/google/OpenYOLO/issues)
-on the [OpenYOLO repository](https://github.com/google/OpenYOLO)
-under the label "specification". The raw markdown source for the specification
-can be found at
-[https://github.com/google/OpenYOLO/spec](https://github.com/google/OpenYOLO/spec).
-We accept and encourage contributions, large and small, from any interested
-parties who are able to sign the Contributor License Agreement - see the
-[CONTRIBUTORS](https://github.com/google/OpenYOLO/CONTRIBUTORS) file for more
-information.
-
-## What does the name mean?
-
-YOLO, You Only Login Once, is the internal code name for Google's
-[Smart Lock for Passwords][yolo] API. Lessons learned from the design and use
-of this API have heavily influenced the design of OpenYOLO.
-
-[yolo]: https://developers.google.com/identity/smartlock-passwords/android
diff --git a/spec/en/SUMMARY.md b/spec/en/SUMMARY.md
deleted file mode 100644
index c1cff49..0000000
--- a/spec/en/SUMMARY.md
+++ /dev/null
@@ -1,8 +0,0 @@
-* [OpenYOLO overview](openyolo-overview.md)
-* [BBQ protocol](bbq-protocol.md)
-* [Retrieving credentials](retrieving-credentials.md)
-* [Assisting sign-up](assisting-sign-up.md)
-* [Saving credentials](saving-credentials.md)
-* [Protecting users from malicious providers](protecting-users.md)
-* [OpenYOLO API](api-overview.md)
-* [OpenYOLO SPI](spi-overview.md)
diff --git a/spec/en/api-overview.md b/spec/en/api-overview.md
deleted file mode 100644
index 56f1443..0000000
--- a/spec/en/api-overview.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# OpenYOLO API
-
-The details of OpenYOLO API are not yet formally defined. See the reference
-implementation for current progress.
diff --git a/spec/en/assisting-sign-up.md b/spec/en/assisting-sign-up.md
deleted file mode 100644
index 29b22d0..0000000
--- a/spec/en/assisting-sign-up.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Assisting sign-up
-
-The details of the assisted sign-up protocol are not yet defined.
diff --git a/spec/en/bbq-protocol.md b/spec/en/bbq-protocol.md
deleted file mode 100644
index 684380c..0000000
--- a/spec/en/bbq-protocol.md
+++ /dev/null
@@ -1,178 +0,0 @@
-# Background broadcast query protocol (BBQ)
-
-BBQ is a protocol designed to allow an Android app to simultaneously request
-data from multiple providers on the device. Requests and responses are sent
-as targeted broadcast messages, using
-[protocol buffer (v2) messages][protobuf] to encode the request and response
-data. The use of broadcast messages allows implementations to be fully
-asynchronous, and protocol buffers allow messages to be compact and efficient,
-while avoiding common issues with custom Parcelable types.
-
-## Structure of a request
-
-A broadcast query has the following mandatory properties:
-
-- The data type being requested, described with
-  [reverse domain name notation][reverse-domain], as is
-  typically used for package names and intent actions in Android.
-  For example, `org.openyolo.credential`.
-- The package name of the requesting app, e.g. `com.example.app`.
-- A randomly generated, 64-bit request ID. This is used to distinguish the
-  request from other requests with the same data type that may not have been
-  fully resolved.
-- A randomly generated, 64-bit response ID. A separate response ID is generated
-  for each expected responder, allowing responders to be distinguished and their
-  identity to be recovered from the mapping of response ID to package name that
-  is created prior to sending the request.
-- A description of the cryptographic scheme used for the exchange:
-    - A string that uniquely identifies the scheme.
-    - A set of key-value pairs carrying scheme-specific parameters.
-
-An additional data-type specific message can be carried in the request if
-necessary, in the form of a byte-array (typically an encoded protocol buffer).
-Additional parameters can also be encoded into the message as
-key-value pairs, allowing for extension of the protocol itself.
-
-The request is encoded using a [protocol buffer (v2) message][protobuf].
-Following the current guidance for protocol buffer message definitions, all
-fields are marked `optional` or `repeated` to provide flexibility in changing
-this specification in future. Fields currently considered to be required are
-marked as such with a comment.
-
-```protobuf
-message BroadcastQuery {
-  optional string       dataType         = 1; // required
-  optional string       requestingApp    = 2; // required
-  optional sfixed64     requestId        = 3; // required
-  optional sfixed64     responseId       = 4; // required
-  optional bytes        queryMessage     = 5;
-  repeated Parameter    additionalParams = 6;
-}
-
-message Parameter {
-	optional string name  = 1; // required
-	optional bytes  value = 2;
-}
-```
-
-## Dispatching a request
-
-A request is dispatched as one or more targeted broadcast intents. First, the
-requester uses the Android [PackageManager][pm-api] API to determine the set
-of apps which can provide data of the required type:
-
-```java
-Intent intent = new Intent(dataType);
-intent.addCategory(BBQ_CATEGORY);
-List<ResolveInfo> responderInfos =
-    packageManager.queryBroadcastReceivers(intent, 0);
-```
-
-A separate request is created for each potential responder, with a unique
-response ID, and sent as a targeted broadcast:
-
-```java
-BroadcastQuery query = new BroadcastQuery.Builder()
-    /* ... */
-    .setResponseId(idForResponder.get(responder))
-    .build();
-Intent bbqIntent = new Intent(dataType);
-bbqIntent.setPackage(responder);
-bbqIntent.setExtra(EXTRA_QUERY_MESSAGE, query.encode());
-context.sendBroadcast(bbqIntent);
-```
-
-## Structure of a response
-
-A broadcast query response has the following mandatory properties:
-
-- The 64-bit request ID that the response is associated with, copied from the
-  request.
-- The 64-bit response ID unique to this response, copied from the request.
-
-Query responses are also represented as a V2 protocol buffer messages.
-The response copies the request and response IDs from the request message,
-and may include a data-type specific response message, if necessary.
-The absence of a data-type specific response message is generally interpreted
-to mean that the provider is unable to service the request.
-
-The structure of the query response message is therefore as follows:
-
-```protobuf
-message BroadcastQueryResponse {
-  optional sfixed64  requestId             = 1; // required
-  optional sfixed64  responseId            = 2; // required
-  optional bytes     responseMessage       = 3;
-  repeated Parameter additionalParams      = 4;
-}
-```
-
-## Receiving a response
-
-Responses are sent back to the requester in the form of targeted broadcasts.
-The requester dynamically registers a broadcast receiver to capture
-responses. The _ACTION_ for the response is the requested data type with the
-request ID concatenated in zero-padded hex form, e.g.
-"org.openyolo.credential:000000000000CAFE" where "org.openyolo.credential" is
-the requested data type and "000000000000CAFE" is the request ID (51966 in
-decimal).
-
-```java
-IntentFilter filter = new IntentFilter();
-filter.addAction(encodeAction(dataType, requestId));
-filter.addCategory(BBQ_CATEGORY);
-context.registerReceiver(new BroadcastReciever() { ... }, filter);
-```
-
-In order to avoid waiting indefinitely for responses from faulty receivers,
-a timeout should be used, after which absent responses should be treated as
-though the provider was unable to service the request (equivalent to
-responding with no data-type specific message payload).
-
-## Rooted devices
-
-The BBQ protocol relies on the integrity of the Android broadcast system
-(and the `setPackage` mechanism in particular) to guarantee the privacy of the
-messages sent between a requester and a provider. On a rooted device, it is
-potentially possible for a malicious app or system service with root access to
-read these messages, and expose plain-text passwords.
-
-Cryptography provides no additional protection. If an attacker can read the
-private messages sent via the broadcast system, this will typically imply they
-have access to the memory location of the buffers. If ephemeral public-private
-key pairs are used, which don't authenticate either party, a man-in-the-middle
-attack is possible.
-
-There is no trusted third party which can sign keys to
-prove they are associated to a particular app:
-
-- Key pairs cannot be distributed with the app, as they could be easily
-  extracted from the application in advance, or on-demand with
-  root access on the device.
-
-- Keys cannot be dynamically signed by a trusted entity on the device (such as
-  the platform itself, or Google Play Services) as these exchanges
-  would also be susceptible to attack by anything with root access.
-
-As such, we strongly recommend that password manager apps disable the OpenYOLO
-protocol on rooted devices, if they are able to detect this. The option could
-be given to the user to re-enable the feature, with a warning as to the security
-risks of doing this. Generally, rooted devices are very risky to a user's
-security, so warning users of this fact prior to even allowing a password
-manager to be configured is also advisable, as the following attacks are
-also possible:
-
-- Directly reading keys and passwords from the memory space of the password
-  manager or app
-- Scraping the contents of EditText instances for passwords
-- Key-logging the user
-- Injecting code into the process space of the password manager or app
-
-The authors of this specification have no evidence that the kernel modifications
-required to break this protocol exist on real devices, but they are certainly
-feasible. As such, all rooted devices should be treated with suspicion when
-using the BBQ protocol to transport security- or privacy-sensitive data.
-
-[pm-api]: https://developer.android.com/reference/android/content/pm/PackageManager.html "android.content.pm.PackageManager"
-[protobuf]: https://developers.google.com/protocol-buffers
-[reverse-domain]: https://en.wikipedia.org/wiki/Reverse_domain_name_notation
diff --git a/spec/en/openyolo-overview.md b/spec/en/openyolo-overview.md
deleted file mode 100644
index 61cfc98..0000000
--- a/spec/en/openyolo-overview.md
+++ /dev/null
@@ -1,327 +0,0 @@
-# OpenYOLO overview
-
-The OpenYOLO protocol defines three core operations to assist with
-authentication in an Android app:
-
-- Retrieving an existing credential: An app can attempt to retrieve a
-  credential to authenticate a user. In most cases, a user can be
-  automatically signed-in using a credential retrieved using OpenYOLO.
-
-- Assisting with sign-up: In the case where no credential can be retrieved
-  by OpenYOLO, a request can be made to a provider to retrieve information
-  that can be used to create a new account, including generating a unique
-  password if required. The entire sign-up process of the app can often be
-  replaced with a single tap when using this API, producing a basic user profile
-  and unique password suitable for use with the application.
-
-- Saving a credential: An app can attempt to save a credential that
-  has been used to successfully authenticate. With user permission, this
-  credential will be saved to the provider of their choice. Saving the
-  credential facilitates future authentication attempts through the retrieve
-  operation, and is particularly useful when the credential provider supports
-  cross-device synchronization.
-
-## High level concepts
-
-Before providing a high level overview of the OpenYOLO operations, some
-terms that will be used throughout the discussion must be defined.
-
-### Credential
-
-A _credential_ is defined in OpenYOLO to be composed of the following
-properties:
-
-- A required _authentication domain_, where the credential can be used.
-
-- A required _authentication method_, which describes how to verify the
-  credential.
-
-- A required _identifier_ which designates a specific account in the context of
-  both the authentication domain and method. Typically, identifiers are
-  email addresses, phone numbers, or some other unique account identifier
-  associated with a federated identity provider.
-
-- An optional _password_, which can be used for password-based authentication
-  methods.
-
-- An optional _display name_, used to assist the user in identifying
-  credentials. Typically, the display name for a credential is the user's
-  real name or chosen alias.
-
-- An optional _display picture_, used to assist the user in visually identifying
-  credentials. Typically, the display picture is a picture of the user, or
-  an avatar that they have chosen or been assigned.
-
-Additional properties can also be optionally specified for a credential,
-however a credential provider is not _required_ to store or return any optional
-values. As such, the existence of these values should not be relied upon by
-apps which consume credentials from OpenYOLO.
-
-A credential is represented in OpenYOLO using a
-[protocol buffer (v2) message][protobuf], defined as follows:
-
-```protobuf
-message Credential {
-    optional string       id                    = 1; // required
-    optional string       authDomain            = 2; // required
-    optional string       authMethod            = 3; // required
-    optional string       displayName           = 4;
-    optional string       displayPictureUri     = 5;
-    optional string       password              = 6;
-    repeated KeyValuePair additionalProps       = 7;
-}
-```
-
-### Credential providers
-
-A _credential provider_ is defined in OpenYOLO to be any application which
-provides the required broadcast receivers and activity intent filters to
-handle all OpenYOLO operations. Credential providers are typically one of
-the following:
-
-- Dedicated apps whose sole purpose is to store and protect credentials a
-  user has chosen to store.
-
-- Browsers which save and form-fill credentials. Many sites have dedicated
-  Android applications which can benefit from retrieving credentials that are
-  already stored in the browser.
-
-- System services such as Smart Lock for Passwords which can store credentials
-  for the user in the absence of other installed alternatives.
-
-While any app can become a credential provider by supporting the
-required OpenYOLO endpoints, only apps for which credential management is a
-clearly declared and visible feature to the user should become credential
-providers. [Protecting users](protecting-users.md) describes these criteria
-in more detail, and the technical counter-measures that are taken to make it
-difficult for inappropriate or malicious apps to be used as credential
-providers.
-
-### Authentication domains
-
-An _authentication domain_ is defined in OpenYOLO to be a scope within
-which a credential is considered to be usable. Authentication domains are
-represented as absolute, hierarchical URIs of form `scheme://authority` -
-no path, query or fragment is permitted.
-
-Two forms of authentication domain are defined for OpenYOLO:
-
-- Android authentication domains, of form `android://FINGERPRINT@PACKAGE` where
-  `PACKAGE` is the package name of an app and `FINGERPRINT` is a
-  Base64, URL-safe encoding of the app's public key (provided by
-  the [Signature][signature-class] type in Android). The fingerprint string
-  includes both the hash used, and the hash data, e.g.
-  `sha512-7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg==`.
-  The two fingerprint hash algorithms officially supported by all OpenYOLO
-  providers are `sha256` and `sha512`.
-
-- Web authentication domains, which match the domain of the site and can have
-  either a http or https scheme (e.g. `https://example.com` and
-  `http://www.example.com` are valid web authentication domains).
-
-A single _authentication system_, which maintains and validates credentials,
-may be represented by multiple distinct authentication domains. For example,
-a credential for `android://...@com.example.app` may be usable on
-`https://example.com` or `https://www.example.com`, when these three entities
-all use the same authentication system.
-However, it is important that `android://HASH-A@com.example.app` and
-`android://HASH-B@com.example.app` should not be treated as equivalent
-_automatically_ - either could represent a compromised, side-loaded variant of
-an app that is attempting to steal user credentials.
-
-An authentication domain _equivalence class_ defines the set of authentication
-domains across which a given credential can be freely shared. Such equivalence
-classes improve the usability of OpenYOLO, but must be carefully defined to
-avoid compromising the security of a user's credentials.
-
-Determining which apps and sites form an equivalence class is the
-responsibility of a credential provider implementation, and need not be
-consistent between credential provider implementations. Google's
-[Digital Asset Links API][asset-links] provides a data source of declared,
-verifiable relationships between apps and sites that can be used to construct
-an authentication domain equivalence class for a given credential.
-The [OpenYOLO SPI](spi-overview.md) will provide utilities to help in using
-the digital asset links API, though credential providers are free to use any
-other data source.
-
-### Authentication method
-
-An _authentication method_ is a mechanism by which a user credential can be
-verified, and is given a unique URI identifier. Any URI of form
-`scheme://authority` can be used to describe an authentication method; OpenYOLO
-defines some standard URIs for the two most common types of authentication
-method:
-
-- Identifier and password based authentication under the direct control of the
-  app, where the identifier and password are non-empty strings composed of
-  printable ASCII characters. The URI for this authentication method is
-  standardized as `openyolo://id-and-password`.
-
-- Federated credentials (e.g. OpenID Connect), where a user identifier is
-  passed to an identity provider (that is typically not controlled by the app).
-  with some supporting information that identifies the app. The URI
-  used to denote authentication with an identity provider is based upon the
-  origin to which federated requests are typically sent for that provider.
-  For example, the URI that should be used for Google Sign-in accounts is
-  `https://accounts.google.com`, while the URI that should be used for
-  Facebook Sign-in accounts is `https://www.facebook.com`. Other common
-  federated identity provider URIs are defined in the OpenYOLO specification.
-  Any authentication mechanism with protocol http or https is assumed to
-  represent an federated identity provider.
-
-## Retrieving credentials
-
-Credential retrieval requests are dispatched using the
-[BBQ protocol](bbq-protocol.md) to all credential providers on the device
-simultaneously. This is particularly useful for users who have more than one
-credential provider, such as Smart Lock for Passwords (present on all devices
-with Google apps), and Dashlane, which the user has chosen to install. Such
-users are often in a state where disjoint sets of credentials are stored in
-each, so querying both increases the chance that a credential can be found.
-
-The BBQ protocol uses [Android broadcast intents][intent-overview] with
-recipients specified by package name in order to asynchronously deliver
-requests and responses. A retrieval request carries the following information:
-
-- The set of authentication mechanisms that are supported by the requester.
-
-It is recommended that an app send a credential request whenever a user would
-typically be required to sign in manually, and _before_ any login UI is shown.
-Some intermediate UI (such as a loading screen) can be displayed while waiting
-for a response. If a credential is available, the entire manual sign-in flow
-can be skipped, resulting in an improved user experience.
-
-Retrieval responses may carry an intent that can be used to retrieve a
-credential from a provider. Providers respond with no intent if they know that
-they do not have a credential for the provider, or if they refuse to service
-the request. Providers _may_ respond with an intent even if they do not know
-that they have a credential available: providers which use a master password
-to encrypt their stores which is not stored to disk may require the user to
-take an action to unlock the store before an accurate answer can be determined.
-
-The OpenYOLO API will return a single intent that can be dispatched with
-[startActivityForResult][intent-results], and returns the selected credential
-data (if any) via `onActivityResult`.
-
-For the specifics of this flow, see
-[Retrieving Credentials](retrieving-credentials.md).
-
-## Assisting sign-up
-
-If no existing credentials can be retrieved from a credential provider,
-then OpenYOLO provides a fall-back mechanism that can be used to help in
-creating a new account. This mechanism will typically allow a new user
-account to be created without the need to manually enter any information.
-
-First, the app must provide a descriptor of the types of credentials that
-it can support. This is done by providing a list of one or more
-supported authentication methods. If password authentication is supported,
-then a _password specification_ can optionally be provided that describes
-the set of passwords that the app supports.
-
-This descriptor can then be sent to a credential provider using the OpenYOLO
-API in order to derive a credential hint. If a default credential provider can
-be determined by the OpenYOLO API, then it will construct an intent to send the
-descriptor to this provider and return it for the app to dispatch when ready.
-Similarly, if only one credential provider is available on the device and it is
-a "known" provider, then an intent to directly interact with that provider will
-be constructed and returned. See [Protecting users](protecting-users.md) for
-details on default and known providers.
-
-If no default provider is found or multiple providers exist, an intent
-is constructed for a dialog that will allow the user to choose a provider,
-after which an intent will be dispatched to that provider containing the
-descriptor.
-
-The flow for creating a credential hint based on the descriptor is under the
-control of the provider, and not part of this specification. A hint constructed
-by the provider is returned to the app via the intent data carried by
-`onActivityResult`.
-
-For more detail on this flow, see [Assisting sign-up](assisting-sign-up.md).
-
-## Saving credentials
-
-When a user successfully authenticates with an app, either manually or via
-the OpenYOLO retrieve or assisted sign-up flows, this credential should be
-saved for future use. Manually saving credentials to a provider is frustrating
-and error-prone - the user must manually switch to the credential provider,
-and follow the provider-specific flow to manually enter their credential again
-for storage, with the possibility of typographical errors.
-
-A significantly better user experience can be provided if the credential can
-be saved in-context, just after it has been verified by an app. OpenYOLO
-provides the mechanism to achieve this.
-
-After a credential has been verified by an app, it should construct a
-representation of the credential to be saved by a credential provider. This
-can then be sent to be stored using the OpenYOLO aPI.
-
-If a preferred credential provider can be determined by the OpenYOLO API, then
-it will construct an intent to send the save request to the provider,
-carrying the plain-text credential data in an intent extra. Similarly, if
-only one credential provider is available on the device and it is a "known"
-provider, the intent to directly interact with that provider will be
-constructed. See [Protecting users](protecting-users.md) for details on
-default and known providers.
-
-If no preferred provider is found, an intent is constructed for a dialog that
-will allow the user to choose a provider, after which an intent will be
-dispatched to that provider containing the credential.
-
-The flow for saving the credential past this point is under the control of
-the provider, and not part of this specification. The outcome of the save
-operation (success or failure) is communicated back to the app via a result
-code to `onActivityResult`.
-
-For more detail on this flow, see [Saving credentials](saving-credentials.md).
-
-## Protecting users from malicious providers
-
-Given the sensitive nature of the data being exchanged by OpenYOLO, the protocol
-will become an obvious target for attackers. A probable attack will be for
-malicious apps to register themselves as credential providers, and attempt to
-trick users into providing credentials. Distinguishing legitimate credential
-provider apps from malicious apps is therefore an important aspect of building
-trust in the protocol, for both app developers and users.
-
-In order to achieve this, a "known provider" list will be hosted by the
-OpenID Foundation. A static version of this list is included in the OpenYOLO
-API, and is automatically updated by client library when necessary.
-
-An "unknown" provider will still be usable via the protocol. Prior to any
-interaction with an unknown provider, a dialog will be displayed
-warning the user that this provider is unknown, and that they should only
-proceed if they trust the provider. "Known" providers will not have this
-restriction.
-
-Additionally, on devices with Google Play Services, further protections can
-be offered. Play Services will provide a secure host for user preferences
-on the majority of Android devices. A new API for Google Play Services is
-proposed that will:
-
-- Specify which providers are enabled. This will require that providers
-  explicitly "opt-in" by directing the user to a settings page to enable
-  the provider, typically after installing the provider. Many credential
-  providers already include such a flow in order to enable themselves as an
-  "accessibility service" in order to perform form-fill.
-
-  If a provider is not on this explicit whitelist, the OpenYOLO API
-  will not even attempt to communicate with it. This protects the user in a much
-  more direct way, avoiding the possibility of a user accidentally interacting
-  with a provider.
-
-- Specify a "default" provider. This is the provider that will be automatically
-  used for save requests and hint requests, removing the need to show a
-  "provider picker" dialog prior to these operations.
-
-Technical information on the known provider list and the Play Services API
-can be found in the chapter on [protecting users](protecting-users.md).
-
-
-[asset-links]: https://developers.google.com/digital-asset-links/
-[cancel-result]: https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED
-[intent-results]: https://developer.android.com/training/basics/intents/result.html
-[intent-overview]: https://developer.android.com/guide/components/intents-filters.html
-[protobuf]: https://developers.google.com/protocol-buffers
-[signature-class]: https://developer.android.com/reference/android/content/pm/Signature.html
diff --git a/spec/en/protecting-users.md b/spec/en/protecting-users.md
deleted file mode 100644
index e65caec..0000000
--- a/spec/en/protecting-users.md
+++ /dev/null
@@ -1,236 +0,0 @@
-# Protecting users from malicious providers
-
-OpenYOLO offers a novel mechanism for direct credential exchange between apps
-and credential providers, which can dramatically simplify the sign-in and
-sign-up experience. User understanding of the feature, and in particular its
-security implications, will also be low. It is therefore important that
-technical measures are taken to prevent the user from inadvertently compromising
-the security of their credentials.
-
-Two mechanisms are proposed in order to achieve this:
-
-- A known provider list, which can be utilized by the client library in order
-  to warn a user before it interacts with an unknown provider. This will work
-  on any Android device.
-- A supporting Google Play Services API, which will store an explicit
-  whitelist of providers that the user has selected, and their "default"
-  provider for the save and hint flows. This will only work on devices with
-  Google Play Services - the majority, but not all, Android devices. The API
-  is therefore designed to provide additional security when available, but not
-  to be essential to the functioning of OpenYOLO.
-
-## The known provider list
-
-The "known provider" list will be retrievable from
-(*TODO: URL TO BE DETERMINED*), and served from infrastructure
-controlled by the OpenID Foundation. This resource has mime-type
-"application/json", is UTF-8 encoded, and contains a list of JSON objects that
-describe each provider via the following properties:
-
-- "name": The canonical, human-readable name of the provider (e.g.
-  "Smart Lock for Passwords")
-- "package-identifiers": a list of one or more strings in the format used for
-  authentication domains, that identifies the legitimate app package name(s)
-  and signature(s) for this provider. For instance, a provider may have multiple
-  signatures due to key rotation, and multiple package names if they release
-  "beta" / "alpha" channels of their app under different package names, to
-  allow concurrent installation.
-- "store-link": a canonical link for the app. It must be possible for the
-  maintainers of the known app list to verify the app's signature using this
-  link. Google Play Store links are preferred, but other stores may be
-  referenced for apps that are targeted at specific demographics
-  (e.g. the Chinese market).
-
-For example, such a list may look like:
-
-```json
-[
-  {
-    "name": "Firefox",
-    "package-identifiers": [
-      "android://sha256-2gCe6pR_AO_Q2Vu8Iep-4AsiKNnUHQxu0FaDHO_qa178GByKybdT_BuE8_dYk99G5Uvx_gdONXAOO2EaXidpVQ==@org.mozilla.firefox",
-      "android://sha256-2gCe6pR_AO_Q2Vu8Iep-4AsiKNnUHQxu0FaDHO_qa178GByKybdT_BuE8_dYk99G5Uvx_gdONXAOO2EaXidpVQ==@org.mozilla.firefox_beta"
-    ],
-    "store-link": "https://play.google.com/store/apps/details?id=org.mozilla.firefox"
-  },
-  //
-  // ...
-  //
-  {
-    "name": "LastPass",
-    "package-identifiers": [
-      "android://sha256-d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7ofwLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ==@com.lastpass.lpandroid"
-    ],
-    "store-link": "https://www.amazon.com/dp/B005V2S7FW",
-  },
-  {
-    "name": "Smart Lock for Passwords",
-    "package-identifiers": [
-      "android://sha256-7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg==@com.google.android.gms"
-    ],
-    "store-link": "https://play.google.com/store/apps/details?id=com.google.android.gms",
-  },
-]
-```
-
-### Inclusion and exclusion criteria
-
-The criteria for an provider to be included in the known list are as follows:
-
-- The app must be published on at least one major app store, as determined by
-  the OpenYOLO repository owners.
-- The app must clearly be a credential provider of some form: either a
-  dedicated app, or an app that clearly states its ability to store passwords
-  (browsers typically fall into this category).
-- A point of contact (email) must be designated for the app for notification
-  of security issues, and acknowledgment of security issues via this address
-  must occur in a timely manner (e.g. 1 business day for critical issues).
-
-Only "production" package identifiers will be permitted in the list: apps
-compiled with debug keys or those that are not published in a manner accessible
-to end users will not be included.
-
-An app may be removed from the list for the following reasons:
-
-- An actively exploited security issue with high user impact is discovered.
-- If an adequate plan to fix a lower impact security issue is not sent in
-  response to a query via the point of contact in a timely manner (e.g.
-  10 business days).
-- If a plan to fix a security issue is not adhered to, leaving an app
-  exploitable with no steps towards resolution.
-
-Examples of security issues with high user impact are:
-
-- The provider does not correctly construct an authentication domain equivalence
-  class, resulting in one or more apps being able to retrieve credentials to
-  which they should not have access.
-- An exploit exists allowing an app to corrupt the provider data store
-  with a save credential request, resulting in loss of user credential data.
-- A code injection attack on a provider from data sent via the OpenYOLO
-  protocol.
-
-A provider will be reinstated to the known provider list after critical issues
-are resolved and the updated app has been available in app stores long enough
-for most user devices to have updated.
-
-To submit your application for inclusion in the known provider list, an issue
-must be opened on the OpenYOLO repository.
-
-## The Google Play Services "credentialproviders" API
-
-*NOTE*: The API described in this section is a proposal, that may or may not
-be implemented in this form or at all.
-
-The BBQ and OpenYOLO protocols are designed to work without the need for a
-"trusted" intermediary, allowing it to work on any Android device.
-A trusted intermediary would, however, be very useful in providing additional
-protection against attackers. Similar to root certificate authorities for
-transport layer security, a mutually trusted party allows otherwise
-independent entities to establish mutual trust.
-
-Most Android devices at API level 9 and above have the suite of Google apps
-installed, including Google Play Services, which provides developer APIs
-independently of the base platform. Google Play Services is a viable candidate
-for a trusted intermediary for OpenYOLO, providing security benefits
-for the OpenYOLO API when available.
-
-A "credentialproviders" support API is proposed that will provide the following
-functionality:
-
-```java
-package com.google.android.gms.auth.credentialproviders;
-
-import com.google.android.gms.tasks.Task;
-
-public interface CredentialProvidersApi {
-
-  /**
-   * Provides the (potentially empty) list of credential providers that the
-   * user has selected.
-   * Each provider is identified by a URI of form
-   * {@code android://SIGNATURE@PACKAGE}, where:
-   *
-   * <ul>
-   * <li>
-   * {@code SIGNATURE} is a url-safe Base64 encoding of the SHA-512 hash of the
-   * {@link Signature} object associated with the app.
-   * </li>
-   * <li>
-   * {@code PACKAGE} is the package name of the app.
-   * </li>
-   */
-  Task<List<String>> getProviders();
-
-
-  /**
-   * Provides the user's default credential provider, if defined. The provider
-   * is identified by a URI of form {@code android://SIGNATURE@PACKAGE}, where:
-   *
-   * <ul>
-   * <li>
-   * {@code SIGNATURE} is a url-safe Base64 encoding of the SHA-512 hash of the
-   * {@link Signature} object associated with the app.
-   * </li>
-   * <li>
-   * {@code PACKAGE} is the package name of the app.
-   * </li>
-   */
-  Task<String> getDefaultProvider();
-
-  /**
-   * Provides an {@link Intent} for launching the credential provider settings
-   * activity, that allows the user to whitelist credential providers for
-   * use on the device.
-   */
-  Intent getSettingsIntent();
-}
-
-public final class CredentialProviders implements CredentialProvidersApi {
-  public static CredentialProviders getInstance();
-  // ... implementation of CredentialProvidersApi methods ...
-}
-```
-
-This API will be used by the OpenYOLO client library to:
-
-- Ensure that the library does not interact with credential providers they have
-  not explicitly selected (as returned by `getProviders()`).
-
-- Interact with only the user's default credential provider for save and
-  hint requests.
-
-It is recommended that providers direct the user to the settings activity at
-some point during the setup flow, immediately after installation.
-This is a common occurrence in providers already to enable the provider as an
-`accessibility provider` in order to perform form-fill in apps. Our hope is that
-over time, and with additional platform support, launching the credential
-provider settings activity will be the system configuration step that a
-credential provider will need to do in order to fully integrate their
-functionality into the platform.
-
-The selection of providers available to the user in the settings activity will
-be populated by all apps found on the device that provide broadcast receivers
-and activity intent filters for the OpenYOLO operations. The known provider list
-will be used to annotate these entries with "known" / "unknown" as appropriate
-and to warn the user if they enable an unknown provider.
-
-One may wonder why the API does not provide methods allowing a provider to
-request that they be added to the whitelist, or be set as the
-default credential provider, rather than launching a general settings activity.
-Such an API would likely be implemented by showing a dialog to the user stating
-"Would you like to add X as a credential provider?" with some
-explanatory text and "YES"/"NO" options. The risk with such a presentation is
-that users often don't read or understand the implications of such a prompt,
-and will press the button that most obviously looks like the default action
-of the dialog. This is particularly risky for a credential provider list, as
-an app can trick a user into agreeing to this prompt by manipulating the
-context in which it is shown. For example, a malicious app masquerading as a
-game could present a screen prior to launching the dialog stating "agree to
-the following prompt to disable ads" and users will likely click through any
-sequence of actions for this. Warnings about unknown providers would likely
-be similarly ignored.
-
-It is therefore preferable to launch a full-screen dialog which does not have
-an obvious "default" action to continue: the user must at least process the
-contents of the screen, increasing the chance that they will realize they are
-being put at risk by a malicious app.
diff --git a/spec/en/retrieving-credentials.md b/spec/en/retrieving-credentials.md
deleted file mode 100644
index b28a215..0000000
--- a/spec/en/retrieving-credentials.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# Retrieving credentials
-
-NOTE: writing this chapter is *in progress*.
-
-## Credential
-
-## Retrieve request messages
-
-```protobuf
-message CredentialRetrieveRequest {
-    repeated string       authMethods        = 2; // at least one required
-    repeated KeyValuePair additionalParams   = 3;
-}
-```
-
-The CredentialRetrieveRequest must explicitly specify all credentials qualifiers the client
-supports with the exception of the authentication domain which will determined implicitly via the
-callers package name.
-
-## Retrieve response messages
-
-```protobuf
-message CredentialRetrieveResponse {
-    optional bytes        retrieveIntent   = 1; // required
-    repeated KeyValuePair additionalParams = 2;
-}
-```
-
-Providers indicate whether they may be able to provide a credential to the
-requester by responding with a message that optionally contains an activity
-[Intent][intent-class]
-to retrieve the credential. The absence of an intent in the response indicates
-that the provider knows that it does not have an available credential, or is
-refusing to serve the request.
-
-An activity intent is used for the final stage of retrieving the request to
-allow the credential provider to interact with the user in some way before
-releasing the credential. Many credential providers will require an unlock code
-(a PIN number, password or recognized fingerprint) in order to decrypt and
-release the credential, or may simply wish to notify the user that the
-credential is being released to avoid surprising the user.
-
-If the requester receives more than one Intent-carrying response, the user
-should be prompted to choose between the available options. If no
-intent-carrying responses are received, then the requester should proceed to
-a manual sign-in.
-
-## Retrieve intent responses
-
-The intent should be dispatched using [startActivityForResult][intent-results],
-allowing the response to be delivered to via `onActivityResult`. The provider
-can describe two outcomes to this process:
-
-- The operation was canceled (indicated by
-  [ACTIVITY_CANCELED][result-canceled]). This can occur as a result of the user
-  failing to enter their unlock code correctly, or explicitly canceling the
-  flow.
-- The operation succeeded (indicated by [ACTIVITY_OK][result-ok]), and a
-  credential is carried in the response. The credential is encrypted using the
-  shared secret established by the BBQ protocol.
-
-When provided with a credential, the application should immediately attempt to
-use this credential, and should do so without requiring any additional user
-input (e.g. pressing a "sign in" button).
-
-[intent-class]: https://developer.android.com/reference/android/content/Intent.html
-[intent-results]: https://developer.android.com/training/basics/intents/result.html
-[result-canceled]: https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED
-[result-ok]: https://developer.android.com/reference/android/app/Activity.html#RESULT_OK
diff --git a/spec/en/saving-credentials.md b/spec/en/saving-credentials.md
deleted file mode 100644
index baeb76e..0000000
--- a/spec/en/saving-credentials.md
+++ /dev/null
@@ -1,108 +0,0 @@
-# Saving credentials
-
-After successfully authenticating a user, it is recommended that an app always
-attempt to save this known-good credential using OpenYOLO. First, the
-system must be queried to determine which providers are able to save the
-credential. This is a simple [Package Manager][pm-api] API call to find
-activities with action `org.openyolo.save` and category `org.openyolo`.
-
-It is anticipated that some credential providers will only be able to store
-id-and-password based credentials, while others may support federated
-credentials. Such providers can be distinguished by requiring that providers
-declare their supported set of authentication methods via an intent filter,
-with a data URI filter based on the authentication method URI.
-
-For a credential provider which only supports id-and-password based credentials,
-this would look as follows:
-
-```xml
-<activity
-    android:name="com.example.provider.SaveCredentialActivity"
-    android:theme="@style/AppTheme.Dialog"
-    android:exported="true"
-    android:excludeFromRecents="true">
-  <intent-filter>
-    <action android:name="org.openyolo.save"/>
-    <category android:name="org.openyolo" />
-    <!--
-    as this app only supports saving email based credentials, this is declared using a data filter.
-    -->
-    <data
-        android:scheme="openyolo"
-        android:host="email" />
-  </intent-filter>
-</activity>
-```
-
-If a provider supports saving credentials for multiple authentication methods,
-then multiple data filters can be specified. If the data filter is omitted,
-this indicates the provider supports saving all credentials, regardless of
-authentication type.
-
-Given a credential object to be saved, the system can be queried to
-find all password managers which support saving this credential:
-
-```java
-Intent saveIntent = new Intent("org.openyolo.save");
-saveIntent.addCategory("org.openyolo");
-
-// set the authentication type as a data parameter
-saveIntent.setData(Uri.parse("openyolo://id-and-password"));
-
-List<ResolveInfo> supportingProviders =
-    getPackageManager().queryIntentActivities(saveIntent, 0);
-```
-
-This list should be presented to the user, in order to allow them to select
-which provider they wish to save the credential to.
-
-## Filtering the provider list
-
-The list of credential providers returned by querying the package manager
-may include unsafe options - it is important to further filter this list based
-on the following criteria:
-
-1. If the user has a preferred credential provider defined in the Google Play
-   Services managed settings, and this credential provider
-   is in the list, it should be used directly.
-
-1. If the user has a whitelist of credential providers defined in the
-   Google Play Services managed settings, the dialog presented to the user
-   for save should be restricted to these options.
-
-1. If Google Play Services is unavailable, all options should be displayed
-   such that known providers are clearly distinguished from unknown providers.
-   Selecting an unknown provider should require a second confirmation, to avoid
-   the user accidentally interacting with an unknown provider by tapping on the
-   wrong area of the screen.
-
-[Protecting the user from malicious providers](protecting-users.md) provides
-more information on how the Google Play Services settings and the known
-providers list are defined.
-
-## Behavior of the save intent
-
-The behavior of the activity or activities that implement the save flow
-is beyond the scope of this specification. However,. if a saved credential
-matches an existing credential by identifier and authentication method, and
-authentication domain, the credential provider should allow this to be
-automatically saved where possible. This will allow apps to easily update
-credentials in response to password change events.
-
-To mitigate potential attempts to spoof a credential provider's UI, it is
-also recommended that a method of pushing the request to a full screen version
-of the provider is made available. This will allow security-conscious users
-to determine that it is really the credential provider they are interacting
-with, and not some attempt to phish their master password.
-
-## Save response
-
-The save response, returned to the app via `onActivityResult`, can be one of
-two values:
-
-1. `RESULT_OK`, if the credential is successfully saved.
-2. `RESULT_CANCELLED`, if the credential was not saved for any reason. No
-   further details need to be provided to the calling application, as the
-   application is unlikely to be able to take any remedial action.
-
-[pm-api]: https://developer.android.com/reference/android/content/pm/PackageManager.html "android.content.pm.PackageManager"
diff --git a/spec/en/spi-overview.md b/spec/en/spi-overview.md
deleted file mode 100644
index 40783df..0000000
--- a/spec/en/spi-overview.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# OpenYOLO SPI
-
-The details of OpenYOLO SPI are not yet formally defined. See the reference
-implementation for current progress.

commit 7318a26ca8a1d91fc3b518b8f3e6047bc5e8252c
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue Apr 18 18:15:08 2017 -0700

    Add heuristic for choosing the "preferred" provider
    
    The behavior of the heuristic is specified in #7.

diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 94e8874..34edea0 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -37,2 +37,3 @@ import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
@@ -49,234 +50,326 @@ import org.openyolo.protocol.internal.IntentUtil;
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION, null);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
         byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
-        // TODO: if a preferred credential provider is set, directly invoke it.
+        // if there is a preferred provider, directly invoke it.
+        ComponentName preferredProviderActivity = getPreferredProvider(hintProviders);
+        if (preferredProviderActivity != null) {
+            return createHintIntent(preferredProviderActivity, encodedRequest);
+        }
+
+        // otherwise, display a picker for all the providers.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
-            Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
-            hintIntent.putExtra(EXTRA_HINT_REQUEST, encodedRequest);
-            hintIntents.add(hintIntent);
+            hintIntents.add(createHintIntent(providerActivity, encodedRequest));
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final RetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
                 findProviders(SAVE_CREDENTIAL_ACTION, credentialToSave.getAuthenticationMethod());
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
-        // TODO: if a preferred password manager is set, directly invoke it if it is in the list,
-        // otherwise return no intent.
-
         byte[] encodedCredential = credentialToSave.getProto().toByteArray();
 
+        // if there is a preferred provider, directly invoke it.
+        ComponentName preferredSaveActivity = getPreferredProvider(saveProviders);
+        if (preferredSaveActivity != null) {
+            return createSaveIntent(
+                    preferredSaveActivity,
+                    credentialToSave.getAuthenticationMethod(),
+                    encodedCredential);
+        }
+
+        // otherwise, display a picker for all the providers.
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
-            Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
-            saveIntent.setData(credentialToSave.getAuthenticationMethod());
-            saveIntent.putExtra(EXTRA_CREDENTIAL, encodedCredential);
-            saveIntents.add(saveIntent);
+            saveIntents.add(createSaveIntent(
+                    providerActivity,
+                    credentialToSave.getAuthenticationMethod(),
+                    encodedCredential));
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
+    private Intent createHintIntent(ComponentName providerActivity, byte[] hintRequest) {
+        Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
+        hintIntent.putExtra(EXTRA_HINT_REQUEST, hintRequest);
+        return hintIntent;
+    }
+
+    private Intent createSaveIntent(
+            ComponentName providerActivity,
+            Uri authenticationMethod,
+            byte[] saveRequest) {
+        Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
+        saveIntent.setData(authenticationMethod);
+        saveIntent.putExtra(EXTRA_CREDENTIAL, saveRequest);
+        return saveIntent;
+    }
+
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @Nullable
     public Credential getCredentialFromActivityResult(@Nullable Intent resultData) {
         if (resultData == null) {
             Log.i(LOG_TAG, "resultData is null, exiting (returning null)");
             return null;
         }
 
         if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
             Log.i(LOG_TAG, "credential data missing from response");
             return null;
         }
 
         byte[] credentialBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
         if (credentialBytes == null) {
             Log.i(LOG_TAG, "No credential found in response");
             return null;
         }
 
         Protobufs.Credential credentialProto;
         try {
             credentialProto = Protobufs.Credential.parseFrom(credentialBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "failed to decode credential from response data");
             return null;
         }
 
         try {
             return new Credential.Builder(credentialProto).build();
         } catch (IllegalArgumentException ex) {
             Log.e(LOG_TAG, "validation of received credential failed", ex);
             return null;
         }
     }
 
     private List<ComponentName> findProviders(
             @NonNull String action,
             @Nullable Uri data) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
         if (data != null) {
             saveIntent.setData(data);
         }
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
+    @Nullable
+    private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
+        // In the future, the user will be able to explicitly set their preferred provider in
+        // their device settings. For now, we heuristically determine the preferred provider based
+        // on the following rules:
+
+        // 1. If there are any unknown providers on the device, there is no preferred provider.
+        List<ComponentName> knownProviders = filterToKnownProviders(providers);
+        if (knownProviders.size() != providers.size()) {
+            return null;
+        }
+
+        // 2. If there are no known providers, then there is no preferred provider. Unknown
+        // providers are not trusted for automatic usage.
+        if (knownProviders.isEmpty()) {
+            return null;
+        }
+
+        // 3. If there is exactly one provider on the device and it is known,
+        // it is the preferred provider.
+        if (knownProviders.size() == 1) {
+            return knownProviders.get(0);
+        }
+
+        // 3. If there are exactly two known providers on the device, and one of them is Google,
+        // choose the other one.
+        // This reflects the reality that Google is pre-installed on most devices, whereas a second
+        // provider would likely have been explicitly installed by the user - it is likely that
+        // their intent is to use this other provider.
+        providers = filterOutGoogle(knownProviders);
+        if (providers.size() == 1) {
+            return knownProviders.get(0);
+        }
+
+        // 4. Otherwise, there is no preferred provider.
+        return null;
+    }
+
+    private List<ComponentName> filterToKnownProviders(List<ComponentName> providers) {
+        KnownProviders knownProviders =
+                KnownProviders.getApplicationBoundInstance(mApplicationContext);
+
+        ArrayList<ComponentName> filteredProviders = new ArrayList<>();
+        for (ComponentName provider : providers) {
+            if (knownProviders.isKnown(provider.getPackageName())) {
+                filteredProviders.add(provider);
+            }
+        }
+
+        return filteredProviders;
+    }
+
+    private List<ComponentName> filterOutGoogle(List<ComponentName> providers) {
+        Iterator<ComponentName> providerIter = providers.iterator();
+        while (providerIter.hasNext()) {
+            ComponentName provider = providerIter.next();
+            if (provider.getPackageName().equals(
+                    KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName())) {
+                providerIter.remove();
+            }
+        }
+
+        return providers;
+    }
+
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
             Map<String, Protobufs.CredentialRetrieveResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
                 Protobufs.CredentialRetrieveResponse response;
                 try {
                     response = Protobufs.CredentialRetrieveResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
                 if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
                             IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveResult.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/KnownProviders.java b/api/java/org/openyolo/api/KnownProviders.java
index f4bd536..f2e47a4 100644
--- a/api/java/org/openyolo/api/KnownProviders.java
+++ b/api/java/org/openyolo/api/KnownProviders.java
@@ -27,155 +27,173 @@ import org.openyolo.protocol.AuthenticationDomain;
 /**
  * Manages a list of known providers, identified by their package name and a hash of their
  * signing certificate. This class will attempt to dynamically retrieve a list of known providers
  * from openyolo.org if possible, otherwise it will fall back to the list of known providers at
  * compile time.
  */
 public class KnownProviders {
 
-    private Context mApplicationContext;
-    private Set<AuthenticationDomain> mKnownProviders;
-
     /**
      * The known package name and certificate hash for
      * <a href="https://www.dashlane.com">Dashlane</a>.
      */
     public static final AuthenticationDomain DASHLANE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
                     + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
                     + "@com.dashlane");
 
     /**
      * The known package name and certificate hash for Google's
      * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
      * Smart Lock for Passwords</a>.
      */
     public static final AuthenticationDomain GOOGLE_PROVIDER =
             new AuthenticationDomain("android://"
                     + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
                     + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
                     + "@com.google.android.gms");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://keepersecurity.com/">Keeper</a>.
      */
     public static final AuthenticationDomain KEEPER_PROVIDER =
             new AuthenticationDomain("android://"
                     + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
                     + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
                     + "@com.callpod.android_apps.keeper");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.lastpass.com/">LastPass</a>.
      */
     public static final AuthenticationDomain LASTPASS_PROVIDER =
             new AuthenticationDomain("android://"
                     + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
                     + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
                     + "@com.lastpass.lpandroid");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://1password.com/">1Password</a>.
      */
     public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
             new AuthenticationDomain("android://"
                     + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
                     + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
                     + "@com.agilebits.onepassword");
 
     /**
      * The known package name and certificate hash for
      * <a href="https://www.roboform.com/">Roboform</a>.
      */
     public static final AuthenticationDomain ROBOFORM_PROVIDER =
             new AuthenticationDomain("android://"
                     + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
                     + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
                     + "@com.siber.roboform");
 
     /**
      * The list of known providers at the time this library was compiled.
      */
     public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
             Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
                     DASHLANE_PROVIDER,
                     GOOGLE_PROVIDER,
                     KEEPER_PROVIDER,
                     LASTPASS_PROVIDER,
                     ONEPASSWORD_PROVIDER,
                     ROBOFORM_PROVIDER
             )));
 
     private static final AtomicReference<KnownProviders> INSTANCE_REF =
             new AtomicReference<>();
 
     /**
      * Retrieves the singleton instance of the known provider list.
      */
     public static KnownProviders getApplicationBoundInstance(Context context) {
         KnownProviders providers = new KnownProviders(context);
         if (!INSTANCE_REF.compareAndSet(null, providers)) {
             providers = INSTANCE_REF.get();
         }
 
         return providers;
     }
 
+    /**
+     * FOR TESTING ONLY - Overrides the KnownProvider instance. It is *strongly discouraged*
+     * to use this method in anything other than unit tests, as it can compromise the security
+     * of your app and the user's credentials.
+     */
+    @VisibleForTesting
+    static void setApplicationBoundInstance(KnownProviders instance) {
+        INSTANCE_REF.set(instance);
+    }
+
+    /**
+     * FOR TESTING ONLY - Clears the current instance of KnownProvider.
+     */
+    @VisibleForTesting
+    static void clearApplicationBoundInstance() {
+        INSTANCE_REF.set(null);
+    }
+
+    private final Context mApplicationContext;
+    private Set<AuthenticationDomain> mKnownProviders;
+
     private KnownProviders(Context context) {
         mApplicationContext = context.getApplicationContext();
 
         // TODO: implement dynamic retrieval of known providers from
         // https://www.openyolo.org/known-providers
         // and fall back to the static list only if this fails
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     public Set<AuthenticationDomain> getKnownProviders() {
-        return mKnownProviders;
+        return new HashSet<>(mKnownProviders);
     }
 
     /**
      * Determines whether the application with the specified package name (if installed) is
      * on the known provider list.
      */
     public boolean isKnown(String packageName) {
         List<AuthenticationDomain> packageAuthDomains =
                 AuthenticationDomain.listForPackage(mApplicationContext, packageName);
 
         for (AuthenticationDomain packageAuthDomain : packageAuthDomains) {
             if (mKnownProviders.contains(packageAuthDomain)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Reset the list of known providers to the default provider set. If possible, this will be
      * dynamically updated with a list retrieved from openyolo.org.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void resetKnownProvidersToDefault() {
         mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
     }
 
     /**
      * Adds a provider to the known provider list.
      *
      * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
      * than a unit test or test app.
      */
     @VisibleForTesting
     public void addKnownProvider(AuthenticationDomain provider) {
         HashSet<AuthenticationDomain> knownProviders = new HashSet<>(mKnownProviders);
         knownProviders.add(provider);
         mKnownProviders = Collections.unmodifiableSet(knownProviders);
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 24775f6..d274bd3 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -21,7 +21,6 @@ import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
 import static junit.framework.TestCase.assertNotNull;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -36,3 +35,4 @@ import android.content.pm.ResolveInfo;
 import java.util.ArrayList;
-import java.util.List;
+import java.util.Collections;
+import org.junit.After;
 import org.junit.Before;
@@ -45,2 +45,3 @@ import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.HintRequest;
 import org.robolectric.RobolectricTestRunner;
@@ -49,71 +50,289 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
+
+    private static final String EMAIL_ID = "alice@example.com";
+    private static final AuthenticationDomain AUTH_DOMAIN =
+            new AuthenticationDomain("https://www.example.com");
+
+    private static final String DASHLANE =
+            KnownProviders.DASHLANE_PROVIDER.getAndroidPackageName();
+
+    private static final String ONEPASSWORD =
+            KnownProviders.ONEPASSWORD_PROVIDER.getAndroidPackageName();
+
+    private static final String GOOGLE =
+            KnownProviders.GOOGLE_PROVIDER.getAndroidPackageName();
+
+    private static final String UNKNOWN_PROVIDER_1 = "com.example.superpassword";
+
+    private static final String UNKNOWN_PROVIDER_2 = "com.example.locker";
+
     @Mock
     private Context mockContext;
 
-    private CredentialClient underTest;
-    public static final String EMAIL_ID = "alice@example.com";
-    public static final AuthenticationDomain AUTH_DOMAIN =
-            new AuthenticationDomain("https://www.example.com");
-    private Credential testCredentials;
+    @Mock
+    private PackageManager mockPackageManager;
+
+    @Mock
+    private KnownProviders mockKnownProviders;
 
+    private CredentialClient credentialClient;
+    private Credential testCredential;
+
+    private ArrayList<ResolveInfo> installedProviders;
+
+    @SuppressWarnings("WrongConstant")
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        underTest = new CredentialClient(mockContext);
+
+        installedProviders = new ArrayList<>();
+
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
-        testCredentials = new Credential.Builder(
+
+        testCredential = new Credential.Builder(
                 EMAIL_ID,
                 EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
+
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+        when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
+                .thenReturn(installedProviders);
+
+        KnownProviders.setApplicationBoundInstance(mockKnownProviders);
+
+        credentialClient = new CredentialClient(mockContext);
+        testCredential = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN).build();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        KnownProviders.clearApplicationBoundInstance();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
-    public void getSaveIntent() throws Exception {
-        PackageManager mockPackageManager = mock(PackageManager.class);
-        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
-        List<ResolveInfo> response = new ArrayList<>();
-        ResolveInfo info = new ResolveInfo();
-        ActivityInfo mockActivityInfo = new ActivityInfo();
-        mockActivityInfo.packageName =  "com.dashlane";
-        mockActivityInfo.name =  "Dashlane";
-        info.activityInfo = mockActivityInfo;
-        response.add(info);
-        when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(response);
+    public void testGetHintIntent_noProviders() throws Exception {
+        when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
+                .thenReturn(Collections.<ResolveInfo>emptyList());
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
+
+        assertThat(hintIntent).isNull();
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetHintIntent_unknownProviderPresent() throws Exception {
+        addKnownProviders(DASHLANE);
+        addUnknownProviders(UNKNOWN_PROVIDER_1);
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
+
+        // with an unknown provider, the heuristic determines is no preferred provider.
+        // Therefore a provider picker should be displayed.
+        assertThat(hintIntent).isNotNull();
+        assertThat(hintIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetHintIntent_singleKnownProvider() throws Exception {
+        addKnownProviders(DASHLANE);
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
+        assertThat(hintIntent).isNotNull();
+        assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
+    }
 
-        Intent i = underTest.getSaveIntent(testCredentials);
-        assertNotNull(i);
-        assertTrue(i.getExtras().getParcelableArrayList("providerIntents").size()==1);
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetHintIntent_twoKnownProviders_googleAndDashlane() throws Exception {
+        addKnownProviders(DASHLANE, GOOGLE);
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
+
+        // due to the preferred provider selection heuristics, we expect that Dashlane will be
+        // selected for direct invocation.
+        assertThat(hintIntent).isNotNull();
+        assertThat(hintIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetHintIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
+        addKnownProviders(DASHLANE, ONEPASSWORD);
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
 
+        // due to the preferred provider selection heuristics, we expect that Dashlane will be
+        // selected for direct invocation.
+        assertThat(hintIntent).isNotNull();
+        assertThat(hintIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetHintIntent_threeKnownProviders() throws Exception {
+        addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
+
+        // with three known providers, the preferred provider heuristic determines there is no
+        // preferred provider. Therefore, a provider picker should be displayed.
+        assertThat(hintIntent).isNotNull();
+        assertThat(hintIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetHintIntent_noKnownProviders() throws Exception {
+        addUnknownProviders(UNKNOWN_PROVIDER_1, UNKNOWN_PROVIDER_2);
+        Intent hintIntent = credentialClient.getHintRetrieveIntent(
+                HintRequest.forEmailAndPasswordAccount());
+
+        // With no known providers, the preferred provider heuristic will determine there is no
+        // preferred provider. therefore, a provider picker should be displayed.
+        assertThat(hintIntent).isNotNull();
+        assertThat(hintIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void testGetSaveIntent_noProviders() throws Exception {
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNull();
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void getSaveIntent_singleKnownProvider() throws Exception {
+        addKnownProviders(DASHLANE);
+
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNotNull();
+        assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void getSaveIntent_unknownProviderPresent() throws Exception {
+        addKnownProviders(DASHLANE);
+        addUnknownProviders(UNKNOWN_PROVIDER_1);
+
+        // with an unknown provider, the heuristic determines is no preferred provider.
+        // Therefore a provider picker should be displayed.
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNotNull();
+        assertThat(saveIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void getSaveIntent_twoKnownProviders_googleAndDashlane() throws Exception {
+        addKnownProviders(DASHLANE, GOOGLE);
+
+        // due to the preferred provider selection heuristics, we expect that Dashlane will be
+        // selected for direct invocation.
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNotNull();
+        assertThat(saveIntent.getComponent().getPackageName()).isEqualTo(DASHLANE);
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void getSaveIntent_twoKnownProviders_dashlaneAnd1Password() throws Exception {
+        addKnownProviders(DASHLANE, ONEPASSWORD);
+
+        // as there are two known providers, and neither is Google, the preferred provider
+        // heuristics should determine there are no preferred providers. Therefore, a provider
+        // picker should be launched.
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNotNull();
+        assertThat(saveIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void getSaveIntent_threeKnownProviders() throws Exception {
+        addKnownProviders(DASHLANE, ONEPASSWORD, GOOGLE);
+
+        // with three known providers, the preferred provider heuristic determines there is no
+        // preferred provider. Therefore, a provider picker should be displayed.
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNotNull();
+        assertThat(saveIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
+    }
+
+    @SuppressWarnings("WrongConstant")
+    @Test
+    public void getSaveIntent_noKnownProviders() throws Exception {
+        addUnknownProviders("com.example.superpassword", "com.example.locker");
+
+        // With no known providers, the preferred provider heuristic will determine there is no
+        // preferred provider. therefore, a provider picker should be displayed.
+        Intent saveIntent = credentialClient.getSaveIntent(testCredential);
+        assertThat(saveIntent).isNotNull();
+        assertThat(saveIntent.getComponent().getClassName())
+                .endsWith("ProviderPickerActivity");
     }
 
     @Test
     public void getCredentialFromActivityResult_noExtras() throws Exception {
         Intent intent = new Intent();
-
-        Credential result = underTest.getCredentialFromActivityResult(intent);
+        Credential result = credentialClient.getCredentialFromActivityResult(intent);
         assertNull(result);
     }
 
     @Test
     public void getCredentialFromActivityResult_withExtras() throws Exception {
         Intent intent = new Intent();
-        byte[] array = testCredentials.getProto().toByteArray();
+        byte[] array = testCredential.getProto().toByteArray();
         intent.putExtra(EXTRA_CREDENTIAL, array);
-        Credential result = underTest.getCredentialFromActivityResult(intent);
+        Credential result = credentialClient.getCredentialFromActivityResult(intent);
         assertEquals(result.getIdentifier(), "alice@example.com");
         assertEquals(result.getAuthenticationMethod(), AuthenticationMethods.EMAIL);
         assertEquals(result.getAuthenticationDomain(), AUTH_DOMAIN);
     }
+
+    private ResolveInfo createResolveInfo(String packageName, String name) {
+        ResolveInfo resolveInfo = new ResolveInfo();
+        ActivityInfo activityInfo = new ActivityInfo();
+        activityInfo.packageName = packageName;
+        activityInfo.name =  name;
+        resolveInfo.activityInfo = activityInfo;
+
+        return resolveInfo;
+    }
+
+    private void addKnownProviders(String... packageNames) {
+        for (String packageName : packageNames) {
+            installedProviders.add(createResolveInfo(packageName, packageName));
+            when(mockKnownProviders.isKnown(packageName)).thenReturn(true);
+        }
+    }
+
+    private void addUnknownProviders(String... packageNames) {
+        for (String packageName : packageNames) {
+            installedProviders.add(createResolveInfo(packageName, packageName));
+            when(mockKnownProviders.isKnown(packageName)).thenReturn(false);
+        }
+    }
 }
\ No newline at end of file

commit 62cb733b65cc5c220f06d02eceb7f326eabc70ae
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu Apr 20 20:02:57 2017 -0700

    Remove identifier types

diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 17e869d..24775f6 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -27,3 +27,3 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.openyolo.protocol.AuthenticationMethods.ID_AND_PASSWORD;
+import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
 import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
@@ -43,2 +43,3 @@ import org.mockito.MockitoAnnotations;
 import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Credential;
@@ -48,71 +49,71 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
     @Mock
     private Context mockContext;
 
     private CredentialClient underTest;
     public static final String EMAIL_ID = "alice@example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
     private Credential testCredentials;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         underTest = new CredentialClient(mockContext);
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
         testCredentials = new Credential.Builder(
                 EMAIL_ID,
-                ID_AND_PASSWORD,
+                EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
     @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent() throws Exception {
         PackageManager mockPackageManager = mock(PackageManager.class);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         List<ResolveInfo> response = new ArrayList<>();
         ResolveInfo info = new ResolveInfo();
         ActivityInfo mockActivityInfo = new ActivityInfo();
         mockActivityInfo.packageName =  "com.dashlane";
         mockActivityInfo.name =  "Dashlane";
         info.activityInfo = mockActivityInfo;
         response.add(info);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(response);
 
         Intent i = underTest.getSaveIntent(testCredentials);
         assertNotNull(i);
         assertTrue(i.getExtras().getParcelableArrayList("providerIntents").size()==1);
 
     }
 
     @Test
     public void getCredentialFromActivityResult_noExtras() throws Exception {
         Intent intent = new Intent();
 
         Credential result = underTest.getCredentialFromActivityResult(intent);
         assertNull(result);
     }
 
     @Test
     public void getCredentialFromActivityResult_withExtras() throws Exception {
         Intent intent = new Intent();
         byte[] array = testCredentials.getProto().toByteArray();
         intent.putExtra(EXTRA_CREDENTIAL, array);
         Credential result = underTest.getCredentialFromActivityResult(intent);
         assertEquals(result.getIdentifier(), "alice@example.com");
-        assertEquals(result.getAuthenticationMethod().toString(), "openyolo://id-and-password");
-        assertEquals(result.getAuthenticationDomain().toString(), "https://www.example.com");
+        assertEquals(result.getAuthenticationMethod(), AuthenticationMethods.EMAIL);
+        assertEquals(result.getAuthenticationDomain(), AUTH_DOMAIN);
     }
 }
\ No newline at end of file
diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
index fd2acc7..5abd2cc 100644
--- a/demoproviders/barbican/AndroidManifest.xml
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -1,148 +1,148 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     package="org.openyolo.demoprovider.barbican">
 
     <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
 
     <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name_short"
         android:supportsRtl="false"
         android:theme="@style/AppTheme"
         android:name=".Application">
 
         <activity
             android:name=".LaunchActivity"
             android:label="@string/app_name_short"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateHidden"
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data
                     android:host="barbican.openyolo.org"
                     android:scheme="https" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".WelcomeActivity"
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".UnlockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:windowSoftInputMode="adjustResize|stateVisible"
             android:exported="false" />
 
         <activity
             android:name=".LockActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="false" />
 
         <activity
             android:name=".CredentialListActivity"
             android:label="Stored Credentials"
             android:theme="@style/AppTheme"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity
             android:name=".CreateCredentialActivity"
             android:theme="@style/AppTheme"
             android:label="@string/create_credential_activity_label"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:exported="false" />
 
         <activity android:name=".provider.RetrieveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveCredentialActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.save"/>
                 <category android:name="org.openyolo" />
                 <!--
-                as this app only supports saving ID and password based credentials, this is
+                as this app only supports saving email based credentials, this is
                 declared using a data filter.
                 -->
                 <data
                     android:scheme="openyolo"
-                    android:host="id-and-password" />
+                    android:host="email" />
             </intent-filter>
         </activity>
 
         <activity
             android:name=".provider.HintActivity"
             android:theme="@style/AppTheme.NoUi"
             android:exported="true"
             android:excludeFromRecents="true">
             <intent-filter>
                 <action android:name="org.openyolo.hint"/>
                 <category android:name="org.openyolo" />
             </intent-filter>
         </activity>
 
         <activity android:name=".provider.SaveCredentialConfirmationActivity"
                   android:theme="@style/AppTheme.Dialog"
                   android:excludeFromRecents="true" />
 
         <activity android:name=".provider.SaveAfterUnlockActivity"
                   android:theme="@style/AppTheme.NoUi"
                   android:excludeFromRecents="true" />
 
         <activity
             android:name=".provider.AutoSignInActivity"
             android:theme="@style/AutoSignInTheme"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".provider.CredentialPickerActivity"
             android:theme="@style/AppTheme.Dialog"
             android:excludeFromRecents="true"
             android:exported="false" />
 
         <activity
             android:name=".NeverSaveListActivity"
             android:theme="@style/AppTheme"/>
             android:exported="false" />
 
         <service
             android:name=".storage.CredentialStorageService"
             android:label="@string/credential_storage_service_label"
             android:enabled="true"
             android:exported="false"
             android:permission="org.openyolo.demoprovider.STORAGE"/>
 
         <receiver
             android:name=".provider.CredentialQueryReceiver"
             android:exported="true"
             android:enabled="true"
             tools:ignore="ExportedReceiver">
             <intent-filter>
                 <action android:name="org.openyolo.credential" />
                 <category android:name="com.google.bbq.QUERY" />
             </intent-filter>
         </receiver>
     </application>
 </manifest>
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
index 33f8c2c..0ed84dc 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
@@ -51,253 +51,253 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * Creates credentials from manual user input for storage.
  */
 public class CreateCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "CreateCredential";
 
     private static final int MIN_ID_LENGTH = 1;
     private static final int MIN_PASS_LENGTH = 1;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.headerToolbar)
     Toolbar mToolbar;
 
     @BindView(R.id.appBar)
     AppBarLayout mAppBar;
 
     @BindView(R.id.credential_authority)
     Spinner mCredentialAuthority;
 
     @BindView(R.id.credential_id)
     EditText mCredentialId;
 
     @BindView(R.id.credential_password)
     EditText mCredentialPassword;
 
     private MenuItem mDoneButton;
 
     private CredentialStorageClient mStorageClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.create_credential_layout);
         ButterKnife.bind(this);
         getSupportActionBar();
         setSupportActionBar(mToolbar);
         mToolbar.setNavigationIcon(R.drawable.back);
         mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 finish();
             }
         });
         mCredentialAuthority.setAdapter(new AppAdapter(getInstalledApps()));
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.menu_create, menu);
         mDoneButton = menu.findItem(R.id.action_done);
         onFieldsChanged();
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (super.onOptionsItemSelected(item)) {
             return true;
         }
 
         if (R.id.action_done == item.getItemId()) {
             App app = (App) mCredentialAuthority.getSelectedItem();
             String username = mCredentialId.getText().toString();
             String password = mCredentialPassword.getText().toString();
             new StoreCredentialTask(app.mPackageName, username, password).execute();
         }
 
         return false;
     }
 
     @OnItemSelected(R.id.credential_authority)
     @OnTextChanged({R.id.credential_id, R.id.credential_password})
     void onFieldsChanged() {
         boolean validCredential =
                 mCredentialAuthority.getSelectedItemPosition() != Spinner.INVALID_POSITION
                 && mCredentialId.length() >= MIN_ID_LENGTH
                 && mCredentialPassword.length() >= MIN_PASS_LENGTH;
 
         if (mDoneButton != null) {
             mDoneButton.setEnabled(validCredential);
         }
     }
 
     private List<App> getInstalledApps() {
         List<String> appPackageNames = InstalledAppsUtil.getInstalledAppsList(this);
         ArrayList<App> apps = new ArrayList<>();
         PackageManager pm = getPackageManager();
         for (String packageName : appPackageNames) {
             try {
                 ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                 String appName = pm.getApplicationLabel(info).toString();
                 Drawable appIcon = pm.getApplicationIcon(info);
                 apps.add(new App(packageName, appName, appIcon));
             } catch (PackageManager.NameNotFoundException e) {
                 // skip this app
             }
         }
 
         return apps;
     }
 
     private class StoreCredentialTask extends AsyncTask<Void, Void, Boolean> {
 
         final String mPackageName;
         final String mUsername;
         final String mPassword;
 
         StoreCredentialTask(String packageName, String username, String password) {
             mPackageName = packageName;
             mUsername = username;
             mPassword = password;
         }
 
         @Override
         protected Boolean doInBackground(Void... params) {
             AuthenticationDomain domain = AuthenticationDomain.listForPackage(
                     CreateCredentialActivity.this,
                     mPackageName)
                     .get(0);
 
             Credential credential = Credential.newBuilder()
                     .setId(mUsername)
                     .setAuthDomain(domain.toString())
-                    .setAuthMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
+                    .setAuthMethod(AuthenticationMethods.EMAIL.toString())
                     .setPassword(mPassword)
                     .build();
             try {
                 mStorageClient.upsertCredential(credential);
                 return true;
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to upsert credential to database");
             }
             return null;
         }
 
         @Override
         protected void onPostExecute(Boolean success) {
             if (success) {
                 finish();
             } else {
                 Snackbar.make(
                         mRootView,
                         R.string.save_failed,
                         Snackbar.LENGTH_SHORT).show();
             }
         }
     }
 
     private class App implements Comparable<App> {
         @NonNull String mName;
         @NonNull String mPackageName;
         @Nullable Drawable mIcon;
 
         App(@NonNull String packageName, @NonNull String name, @Nullable Drawable icon) {
             mPackageName = packageName;
             mName = name;
             mIcon = icon;
         }
 
         @Override
         public int compareTo(@NonNull App app) {
             return mName.compareTo(app.mName);
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (!(obj instanceof App)) {
                 return false;
             }
 
             App other = (App) obj;
             return mPackageName.equals(other.mPackageName);
         }
 
         @Override
         public int hashCode() {
             return mPackageName.hashCode();
         }
     }
 
     private class AppAdapter extends BaseAdapter {
 
         private final List<App> mApps;
         private final LayoutInflater mInflater;
 
         AppAdapter(@NonNull List<App> apps) {
             mApps = apps;
             mInflater = LayoutInflater.from(CreateCredentialActivity.this);
         }
 
         @Override
         public int getCount() {
             return mApps.size();
         }
 
         @Override
         public Object getItem(int index) {
             return mApps.get(index);
         }
 
         @Override
         public long getItemId(int index) {
             return mApps.get(index).hashCode();
         }
 
         @Override
         public View getView(int index, View view, ViewGroup viewGroup) {
             App app = mApps.get(index);
             if (view == null) {
                 view = mInflater.inflate(R.layout.app_item, viewGroup, false);
             }
 
             ImageView iconView = (ImageView) view.findViewById(R.id.app_icon);
             if (app.mIcon != null) {
                 iconView.setImageDrawable(app.mIcon);
                 iconView.setVisibility(View.VISIBLE);
             } else {
                 iconView.setVisibility(View.INVISIBLE);
             }
 
             TextView nameView = (TextView) view.findViewById(R.id.app_name);
             nameView.setText(app.mName);
 
             return view;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
deleted file mode 100644
index c337c77..0000000
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.demoprovider.barbican;
-
-import android.net.Uri;
-import android.support.annotation.DrawableRes;
-import android.support.annotation.NonNull;
-import android.util.Patterns;
-import java.util.Collection;
-import java.util.regex.Pattern;
-import org.openyolo.protocol.IdentifierTypes;
-import org.openyolo.protocol.Protobufs.Credential;
-
-/**
- * Heuristically identifies the "type" of a password credential based on the ID value.
- */
-public final class CredentialClassifier {
-
-    private static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9]+");
-
-    /**
-     * Determines whether the credential identifier is an email address.
-     */
-    public static boolean isEmailCredential(Credential credential) {
-        return isEmailIdentifier(credential.getId());
-    }
-
-    /**
-     * Determines whether the provided identifier is an email address.
-     */
-    public static boolean isEmailIdentifier(String identifier) {
-        return Patterns.EMAIL_ADDRESS.matcher(identifier).matches();
-    }
-
-    /**
-     * Determines whether the credential identifier is a phone number.
-     */
-    public static boolean isPhoneCredential(Credential credential) {
-        return isPhoneIdentifier(credential.getId());
-    }
-
-    /**
-     * Determines whether the provided identifier is a phone number.
-     */
-    public static boolean isPhoneIdentifier(String identifier) {
-        return Patterns.PHONE.matcher(identifier).matches();
-    }
-
-    /**
-     * Determines whether the provided identifier contains alphanumeric characters only.
-     */
-    public static boolean isAlphanumericIdentifier(String identifier) {
-        return ALPHANUMERIC_PATTERN.matcher(identifier).matches();
-    }
-
-    /**
-     * Determines whether the provided identifier matches any of the provided types.
-     *
-     * @see {@link IdentifierTypes}
-     */
-    public static boolean identifierMatchesOneOf(
-            @NonNull String identifier,
-            @NonNull Collection<Uri> identifierTypes) {
-        for (Uri identifierType : identifierTypes) {
-            if (IdentifierTypes.EMAIL.equals(identifierType) && isEmailIdentifier(identifier)) {
-                return true;
-            }
-
-            if (IdentifierTypes.PHONE.equals(identifierType) && isPhoneIdentifier(identifier)) {
-                return true;
-            }
-
-            if (IdentifierTypes.ALPHANUMERIC.equals(identifierType)
-                    && isAlphanumericIdentifier(identifier)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns a drawable resource which can be used as a default profile picture for a
-     * credential.
-     */
-    @DrawableRes
-    public static int getDefaultIconForCredential(Credential credential) {
-        if (isEmailCredential(credential)) {
-            return R.drawable.email;
-        } else if (isPhoneCredential(credential)) {
-            return R.drawable.phone;
-        }
-
-        return R.drawable.person;
-    }
-}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
index 8c05be0..14b60eb 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
@@ -16,2 +16,3 @@ package org.openyolo.demoprovider.barbican;
 
+import android.net.Uri;
 import android.support.annotation.Nullable;
@@ -24,83 +25,83 @@ import org.openyolo.protocol.Protobufs.Credential;
 /**
  * Derives quality scores for credentials and hints that can help to order lists of them based on
  * how useful they are to an application.
  */
 public class CredentialQualityScore {
 
     /**
      * A comparator which orders credentials in descending order of quality score, i.e. those with
      * the highest quality score first.
      */
     public static final Comparator<Credential> QUALITY_SORT = new CredentialQualityComparator();
 
     /**
      * Generates the score for the user data in an account hint.
      */
     public static int getScore(AccountHint hint) {
         return getQualityScore(
             hint.getIdentifier(),
             hint.getAuthMethod(),
             hint.getName(),
             hint.getPictureUri());
     }
 
     /**
      * Generates the score for the user data in a credential.
      */
     public static int getScore(Credential credential) {
         return getQualityScore(
                 credential.getId(),
                 credential.getAuthMethod(),
                 credential.getDisplayName(),
                 credential.getDisplayPictureUri());
     }
 
     private static int getQualityScore(
             @Nullable String id,
             @Nullable String authMethod,
             @Nullable String name,
             @Nullable String pictureUri) {
 
         int score = 1;
 
         // email identifiers are recognisable and useful for ID token acquisition
-        if (CredentialClassifier.isEmailIdentifier(id)) {
+        if (AuthenticationMethods.EMAIL.toString().equals(authMethod)) {
             score <<= 1;
         }
 
-        // prefer credentials that don't use passwords
-        if (!AuthenticationMethods.ID_AND_PASSWORD.equals(authMethod)) {
+        // prefer federated authentication methods, which generally have an HTTPS scheme
+        if ("https".equals(Uri.parse(authMethod).getScheme())) {
             score <<= 1;
         }
 
         // prefer credentials that have a human readable name
         if (!TextUtils.isEmpty(name)) {
             score <<= 1;
         }
 
         // prefer credentials that have a profile picture
         if (!TextUtils.isEmpty(pictureUri)) {
             score <<= 1;
         }
 
         return score;
     }
 
     private static final class CredentialQualityComparator implements Comparator<Credential> {
 
         @Override
         public int compare(Credential c1, Credential c2) {
             int c1Score = getScore(c1);
             int c2Score = getScore(c2);
 
             // higher scores (more information) come first
             if (c1Score > c2Score) {
                 return -1;
             } else if (c1Score == c2Score) {
                 return 0;
             }
 
             return 1;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index 2308bf4..7314954 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -38,5 +38,5 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.demoprovider.barbican.CredentialClassifier;
 import org.openyolo.demoprovider.barbican.CredentialQualityScore;
 import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.protocol.AuthenticationMethods;
 import org.openyolo.protocol.Protobufs.Credential;
@@ -46,138 +46,145 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(Context context, List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
         intent.putExtra(EXTRA_CREDENTIALS,
                 CredentialList.newBuilder()
                         .addAllCredentials(credentials)
                         .build()
                         .toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResult(RESULT_CANCELED);
             finish();
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Credential> credentials =
                     new ArrayList<>(CredentialList.parseFrom(credentialBytes).getCredentialsList());
             Collections.sort(credentials, CredentialQualityScore.QUALITY_SORT);
             return credentials;
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new CredentialViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(CredentialViewHolder holder, int position) {
             holder.bind(mCredentials.get(position));
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
     }
 
     private final class CredentialViewHolder extends RecyclerView.ViewHolder {
 
         private ImageView mProfileIcon;
         private TextView mPrimaryLabel;
         private TextView mSecondaryLabel;
 
         CredentialViewHolder(View itemView) {
             super(itemView);
 
             mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
             mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
             mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
         }
 
         void bind(final Credential credential) {
 
-            int iconId = CredentialClassifier.getDefaultIconForCredential(credential);
+            int iconId;
+            if (AuthenticationMethods.EMAIL.toString().equals(credential.getAuthMethod())) {
+                iconId = R.drawable.email;
+            } else if (AuthenticationMethods.PHONE.toString().equals(credential.getAuthMethod())) {
+                iconId = R.drawable.phone;
+            } else {
+                iconId = R.drawable.person;
+            }
 
             if (credential.getDisplayPictureUri() != null) {
                 Uri displayPictureUri = Uri.parse(credential.getDisplayPictureUri());
                 Glide.with(CredentialPickerActivity.this)
                         .load(displayPictureUri)
                         .fitCenter()
                         .fallback(iconId)
                         .into(mProfileIcon);
             } else {
                 mProfileIcon.setImageResource(iconId);
             }
 
             if (credential.getDisplayName() != null) {
                 mPrimaryLabel.setText(credential.getDisplayName());
                 mSecondaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.VISIBLE);
             } else {
                 mPrimaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.GONE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     Intent responseData =
                             RetrieveIntentResultUtil.createResponseData(credential);
                     setResult(RESULT_OK, responseData);
                     finish();
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
index 2c36f5b..df62fb9 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
@@ -28,3 +28,2 @@ import java.util.List;
 import java.util.Set;
-import org.openyolo.demoprovider.barbican.CredentialClassifier;
 import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
@@ -38,146 +37,138 @@ import org.openyolo.protocol.ProtocolConstants;
 public class HintActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "HintActivity";
 
     private HintRequest mRequest;
     private AuthenticationDomain mCallerAuthDomain;
     private CredentialStorageClient mClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (!getIntent().hasExtra(ProtocolConstants.EXTRA_HINT_REQUEST)) {
             Log.w(LOG_TAG, "No hint request object found in the intent");
             finish(RESULT_CANCELED);
             return;
         }
 
         try {
             mRequest = HintRequest.fromProtoBytes(
                     getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_HINT_REQUEST));
         } catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
             finish(RESULT_CANCELED);
             return;
         }
 
         if (!extractCallerAuthDomain()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
             finish(RESULT_CANCELED);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
 
         if (!mClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
             finish(RESULT_CANCELED);
             return;
         }
 
         // some credential provider implementations may require an unlock to retrieve the
         // information required for hints, but for Barbican we instead choose to store basic
         // profile information usable for hints in plain text. With root access, this information
         // would be retrievable by malicious applications on the device, representing a privacy
         // risk. However, full credentials and associations between account identifiers
         // remain encrypted.
 
         List<AccountHint> hints;
         try {
             hints = mClient.getHints();
         } catch (IOException ex) {
             Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
             finish(RESULT_CANCELED);
             return;
         }
 
         // filter the credentials to just those which are pertinent to the request. For those
         // selected, turn them into credentials. Order the hints by the amount of information
         // they contain (so more complete items are displayed first), and then alphabetically.
         ArrayList<Credential> filteredHints = new ArrayList<>();
         for (AccountHint hint : hints) {
             Set<Uri> authMethods = mRequest.getAuthenticationMethods();
             if (!authMethods.contains(Uri.parse(hint.getAuthMethod()))) {
                 continue;
             }
 
-            Set<Uri> identifierTypes = mRequest.getIdentifierTypes();
-            if (!identifierTypes.isEmpty()
-                    && !CredentialClassifier.identifierMatchesOneOf(
-                            hint.getIdentifier(),
-                            identifierTypes)) {
-                continue;
-            }
-
             Credential.Builder hintCredentialBuilder = Credential.newBuilder()
                     .setId(hint.getIdentifier())
                     .setAuthMethod(hint.getAuthMethod())
                     .setAuthDomain(mCallerAuthDomain.toString())
                     .setDisplayName(hint.getName())
                     .setDisplayPictureUri(hint.getPictureUri());
 
             // include a generated password if appropriate
-            if (hint.getAuthMethod().equals(AuthenticationMethods.ID_AND_PASSWORD.toString())) {
+            if (hint.getAuthMethod().equals(AuthenticationMethods.EMAIL.toString())) {
                 hintCredentialBuilder.setPassword(mRequest.getPasswordSpecification().generate());
             }
 
             filteredHints.add(hintCredentialBuilder.build());
         }
 
         // if there are no hints, immediately end the request
         if (filteredHints.isEmpty()) {
             finish(RESULT_CANCELED);
             return;
         }
 
         // otherwise, display the standard credential picker.
         Intent pickerIntent = CredentialPickerActivity.createIntent(
                 this,
                 filteredHints);
         pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(pickerIntent);
         finish();
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private boolean extractCallerAuthDomain() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         String callingPackage = callingActivity.getPackageName();
         List<AuthenticationDomain> authDomains =
                 AuthenticationDomain.listForPackage(this, callingPackage);
 
         if (authDomains.isEmpty()) {
             return false;
         }
 
         mCallerAuthDomain = authDomains.get(0);
         return true;
     }
 
     @UiThread
     private void finish(int resultCode) {
         setResult(resultCode);
         finish();
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
index 1db3ddc..3524338 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -30,48 +30,48 @@ import org.openyolo.protocol.internal.IntentUtil;
 import org.openyolo.spi.BaseCredentialQueryReceiver;
 
 /**
  * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
  * we respond to all requests with an intent as long as the
- * {@link org.openyolo.protocol.AuthenticationMethods#ID_AND_PASSWORD id and password}
- * authentication method is supported.
+ * {@link org.openyolo.protocol.AuthenticationMethods#EMAIL email} authentication method is
+ * supported.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         Log.i(LOG_TAG, "Processing retrieve query from claimed caller: "
                 + query.getRequestingApp());
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
-        // Ensure the caller supports the Id and Password authentication method
-        if (!request.getAuthenticationMethods().contains(AuthenticationMethods.ID_AND_PASSWORD)) {
+        // Ensure the caller supports the email authentication method
+        if (!request.getAuthenticationMethods().contains(AuthenticationMethods.EMAIL)) {
             responseSender.sendResponse(query,  null /* response */);
             return;
         }
 
         Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
         CredentialRetrieveResponse response = CredentialRetrieveResponse.newBuilder()
                 .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
                 .build();
 
         Log.i(LOG_TAG, "Accepting credential request for claimed caller: "
                 + query.getRequestingApp());
         responseSender.sendResponse(query, response.toByteArray());
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
index c5915e3..09cba04 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -32,68 +32,68 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
  */
 public class RetrieveActivity extends AppCompatActivity {
 
     private static final int PIN_SIZE = 6;
 
     private static final String LOG_TAG = "TrapdoorRetrieve";
 
     private AuthenticationDomain mDomain;
 
     /**
      * Creates an Intent to start this activity.
      */
     public static Intent createIntent(Context context) {
         return new Intent(context, RetrieveActivity.class);
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
             setResult(RESULT_CANCELED);
             finish();
             return;
         }
 
         mDomain = new TreeSet<>(
                 AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
         Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
 
         setContentView(R.layout.dialog_layout);
         ((PinEntryView)findViewById(R.id.pin_entry_field))
                 .addTextChangedListener(new PinChangedWatcher());
     }
 
     private class PinChangedWatcher implements TextWatcher {
         @Override
         public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
 
         @Override
         public void onTextChanged(CharSequence seq, int start, int before, int count) {}
 
         @Override
         public void afterTextChanged(Editable pin) {
             if (pin.length() != PIN_SIZE) {
                 return;
             }
             String userName = UserDataStore.getUserName(RetrieveActivity.this);
             String password = PasswordGenerator.generatePassword(
                     userName,
                     pin.toString(),
                     mDomain.toString());
 
             Credential credential = Credential.newBuilder()
-                    .setAuthMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
+                    .setAuthMethod(AuthenticationMethods.EMAIL.toString())
                     .setAuthDomain(mDomain.toString())
                     .setId(UserDataStore.getUserName(RetrieveActivity.this))
                     .setPassword(password)
                     .build();
 
             setResult(RESULT_OK, RetrieveIntentResultUtil.createResponseData(credential));
             finish();
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/AuthenticationMethods.java b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
index 32d181d..386618e 100644
--- a/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
@@ -20,56 +20,51 @@ import org.openyolo.protocol.Credential.Builder;
 /**
  * A set of well-known authentication method URIs for use with
  * {@link Builder#setAuthenticationMethod(String)}.
  */
 public final class AuthenticationMethods {
 
     /**
-     * Identifier and password based authentication.
+     * Email address based authentication, optionally with a password. This authentication type
+     * is typically for accounts which have an email address as the primary (user facing)
+     * identifier. Authentication typically occurs using the email address and a password, but
+     * is also possible using the email address as a recovery method.
      */
-    public static final Uri ID_AND_PASSWORD = Uri.parse("openyolo://id-and-password");
+    public static final Uri EMAIL = Uri.parse("openyolo://email");
+
+    /**
+     * Phone number based authentication, optionally with a password. This authentication type
+     * is typically for accounts which have a phone number as the primary (user facing)
+     * identifier. Authentication typically occurs by sending a code to the phone number, and
+     * possible also requiring the entry of a password or pin.
+     *
+     * <p>When used to request a hint, OpenYOLO providers _MUST_ return the selected phone number
+     * in E.164 format.
+     */
+    public static final Uri PHONE = Uri.parse("openyolo://phone");
+
+    /**
+     * User name and password based authentication. This authentication type requires the entry
+     * of a unicode identifier string and a password.
+     */
+    public static final Uri USER_NAME = Uri.parse("openyolo://username");
 
     /**
      * Google Sign-in authentication.
      *
      * @see <a href="https://developers.google.com/identity/sign-in/android/">Google Sign-in for
      *     Android</a>.
      */
     public static final Uri GOOGLE = Uri.parse("https://accounts.google.com");
 
     /**
      * Facebook Login authentication.
      *
      * @see <a href="https://developers.facebook.com/docs/facebook-login/android">Facebook Login
      *     for Android</a>.
      */
     public static final Uri FACEBOOK = Uri.parse("https://www.facebook.com");
 
-    /**
-     * LinkedIn OAuth2 authentication.
-     *
-     * @see <a href="https://developer.linkedin.com/docs/oauth2">"Authenticating with OAuth2"</a>
-     * @see <a href="https://developer.linkedin.com/docs/android-sdk-auth">Authenticating with
-     *     the Mobile SDK for Android</a>
-     */
-    public static final Uri LINKEDIN = Uri.parse("https://www.linkedin.com");
-
-    /**
-     * Microsoft OpenID Connect authentication.
-     */
-    public static final Uri MICROSOFT = Uri.parse("https://login.live.com");
-
-    /**
-     * Paypal OpenID Connect authentication.
-     *
-     * @see <a href="https://developer.paypal.com/docs/integration/direct/identity/log-in-with-paypal/">
-     *     Integrate login with Paypal</a>
-     */
-    public static final Uri PAYPAL = Uri.parse("https://www.paypal.com");
-
-    /**
-     * Yahoo OAuth2 authentication.
-     *
-     * @see <a href="https://developer.yahoo.com/oauth2/guide/">Yahoo OAuth 2.0 Guide</a>
-     */
-    public static final Uri YAHOO = Uri.parse("https://login.yahoo.com");
+    private AuthenticationMethods() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
 }
diff --git a/protocol/java/org/openyolo/protocol/HintRequest.java b/protocol/java/org/openyolo/protocol/HintRequest.java
index cd6086d..d8e03ad 100644
--- a/protocol/java/org/openyolo/protocol/HintRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRequest.java
@@ -22,3 +22,2 @@ import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticatio
 import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
-import static org.openyolo.protocol.internal.CustomMatchers.isValidIdentifierType;
 import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
@@ -45,436 +44,349 @@ import org.openyolo.protocol.internal.UriConverters;
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
 public class HintRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<Uri> mAuthMethods;
 
-    @NonNull
-    private final Set<Uri> mIdTypes;
-
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
     public static HintRequest forEmailAndPasswordAccount() {
-        return new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes(IdentifierTypes.EMAIL)
+        return new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws IOException if the hint request could not be decoded.
      *
      * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws IOException {
         if (hintRequestProtoBytes == null) {
             throw new IOException("Unable to decode hint request from null array");
         }
         return new HintRequest.Builder(
                 Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
                 .build();
     }
 
     private HintRequest(
             @NonNull Set<Uri> authMethods,
-            @NonNull Set<Uri> idTypes,
             @NonNull PasswordSpecification passwordSpec,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
-        mIdTypes = idTypes;
         mPasswordSpec = passwordSpec;
         mAdditionalProperties = additionalParams;
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<Uri> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
-    /**
-     * The set of identifier types that the requester uses. This is used to filter the
-     * set of hints to just those which are potentially usable. If no identifier type is
-     * specified, then any identifier string can be returned.
-     */
-    @NonNull
-    public Set<Uri> getIdentifierTypes() {
-        return mIdTypes;
-    }
-
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
         return mAdditionalProperties;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8
      * encoded string.
      */
     @Nullable
     public String getAdditionalPropertyAsString(@NonNull String key) {
         require(key, notNullValue());
         if (mAdditionalProperties.containsKey(key)) {
             return new String(mAdditionalProperties.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalProperty(@NonNull String key) {
         require(key, notNullValue());
         return mAdditionalProperties.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
     public Protobufs.HintRetrieveRequest toProtocolBuffer() {
         return Protobufs.HintRetrieveRequest.newBuilder()
                 .addAllAuthMethods(
                         CollectionConverter.toList(mAuthMethods, CONVERTER_URI_TO_STRING))
-                .addAllIdTypes(CollectionConverter.toList(mIdTypes, CONVERTER_URI_TO_STRING))
                 .putAllAdditionalProps(
                     CollectionConverter.convertMapValues(
                             mAdditionalProperties,
                         ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRequest} instances.
      */
     public static final class Builder {
 
         private Set<Uri> mAuthMethods = new HashSet<>();
         private Set<Uri> mIdTypes = new HashSet<>();
         private Map<String, byte[]> mAdditionalProps = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          *
          * @see HintRequest#toProtocolBuffer()
          */
         public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
             setAuthenticationMethods(CollectionConverter.toSet(
                     requestProto.getAuthMethodsList(),
                     CONVERTER_STRING_TO_URI));
-            setIdentifierTypes(CollectionConverter.toSet(
-                    requestProto.getIdTypesList(),
-                    CONVERTER_STRING_TO_URI));
             setPasswordSpecification(
                     new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
             setAdditionalProperties(
                     CollectionConverter.convertMapValues(
                             requestProto.getAdditionalPropsMap(),
                             ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Uri authMethod, @NonNull Uri... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull String authMethod, @NonNull String... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
          * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<Uri> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
                 @NonNull Uri authMethod,
                 Uri... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             NoopValueConverter.<Uri>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester, in string form. At
          * least one authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         public Builder setAuthenticationMethods(
                 @NonNull String authMethod,
                 @NonNull String... additionalAuthMethods) {
             setAuthenticationMethods(
                     CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             UriConverters.CONVERTER_STRING_TO_URI));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
             require(authMethods, notNullValue());
             require(!authMethods.isEmpty(), "At least one authentication method must be specified");
             require(authMethods, everyItem(isValidAuthenticationMethod()));
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method (in string form) supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull String authMethodStr) {
             require(authMethodStr, notNullOrEmptyString());
             addAuthenticationMethod(Uri.parse(authMethodStr));
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
          * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull Uri authenticationMethod) {
             require(authenticationMethod, isValidAuthenticationDomain());
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
-        /**
-         * Specifies the identifier types that the requester supports. If no identifier types
-         * are specified, then credentials with any form of identifier can be returned.
-         *
-         * @see IdentifierTypes
-         */
-        @NonNull
-        public Builder setIdentifierTypes(@NonNull String... idTypes) {
-            setIdentifierTypes(
-                    CollectionConverter.toSet(
-                            idTypes,
-                            UriConverters.CONVERTER_STRING_TO_URI));
-            return this;
-        }
-
-        /**
-         * Specifies the identifier types that the requester supports. If no identifier types
-         * are specified, then credentials with any form of identifier can be returned.
-         *
-         * @see IdentifierTypes
-         */
-        @NonNull
-        public Builder setIdentifierTypes(@NonNull Uri... idTypes) {
-            setIdentifierTypes(
-                    CollectionConverter.toSet(idTypes, NoopValueConverter.<Uri>getInstance()));
-            return this;
-        }
-
-        /**
-         * Specifies the identifier types that the requester supports. If no identifier types
-         * are specified, then credentials with any form of identifier can be returned.
-         *
-         * @see IdentifierTypes
-         */
-        @NonNull
-        public Builder setIdentifierTypes(@NonNull Set<Uri> identifierTypes) {
-            require(identifierTypes, notNullValue());
-            require(identifierTypes, everyItem(isValidIdentifierType()));
-            mIdTypes = identifierTypes;
-            return this;
-        }
-
-        /**
-         * Adds a supported identifier type to the hint request.
-         *
-         * @see IdentifierTypes
-         */
-        @NonNull
-        public Builder addIdentifierType(@NonNull String identifierTypeStr) {
-            require(identifierTypeStr, notNullOrEmptyString());
-            addIdentifierType(Uri.parse(identifierTypeStr));
-            return this;
-        }
-
-        /**
-         * Adds a supported identifier type to the hint request.
-         *
-         * @see IdentifierTypes
-         */
-        @NonNull
-        public Builder addIdentifierType(@NonNull Uri identifierType) {
-            require(identifierType, isValidIdentifierType());
-            mIdTypes.add(identifierType);
-            return this;
-        }
-
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
         public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
             mAdditionalProps = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request with a string value, that
          * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
          * key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
             require(value, notNullValue());
             addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request, that will be encoded as
          * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
          */
         @NonNull
         public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
             mAdditionalProps.put(name, value);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             require(passwordSpec, notNullValue());
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRequest build() {
             return new HintRequest(
                     unmodifiableSet(mAuthMethods),
-                    unmodifiableSet(mIdTypes),
                     mPasswordSpec,
                     unmodifiableMap(mAdditionalProps));
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRequest> {
         @Override
         public HintRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new HintRequest.Builder(
                         Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRequest[] newArray(int size) {
             return new HintRequest[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/IdentifierTypes.java b/protocol/java/org/openyolo/protocol/IdentifierTypes.java
deleted file mode 100644
index f70e4b8..0000000
--- a/protocol/java/org/openyolo/protocol/IdentifierTypes.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.protocol;
-
-import android.net.Uri;
-
-/**
- * The standard identifier types defined in the OpenYOLO specification. Any URI of form
- * {@code scheme://authority} can be used as an identifier type, but the values defined here
- * have a common meaning across all credential providers.
- */
-public final class IdentifierTypes {
-
-    /**
-     * Designates identifiers which are composed of alphanumeric characters only. This is typical
-     * of sites with "usernames" instead of email addresses as the primary identifier, e.g.
-     * "bob" instead of "bob@example.com".
-     */
-    public static final Uri ALPHANUMERIC = Uri.parse("openyolo://alphanumeric-identifier");
-
-    /**
-     * Designates email address based identifiers.
-     */
-    public static final Uri EMAIL = Uri.parse("openyolo://email-identifier");
-
-    /**
-     * Designates phone number based identifiers.
-     */
-    public static final Uri PHONE = Uri.parse("openyolo://phone-identifier");
-
-    private IdentifierTypes() {
-        throw new IllegalStateException("Not intended to be constructed");
-    }
-}
diff --git a/protocol/javatests/org/openyolo/protocol/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
index a66facf..8ba9281 100644
--- a/protocol/javatests/org/openyolo/protocol/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -19,3 +19,3 @@ package org.openyolo.protocol;
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.openyolo.protocol.AuthenticationMethods.ID_AND_PASSWORD;
+import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
 
@@ -30,248 +30,248 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     public static final String EMAIL_ID = "alice@example.com";
     public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain(AUTH_DOMAIN_STR);
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
-        new Credential.Builder(null, ID_AND_PASSWORD, AUTH_DOMAIN);
+        new Credential.Builder(null, EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
-        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, null);
+        new Credential.Builder(EMAIL_ID, EMAIL, null);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyIdentifier() {
-        new Credential.Builder("", ID_AND_PASSWORD, AUTH_DOMAIN);
+        new Credential.Builder("", EMAIL, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyAuthMethod() {
         new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, Uri.parse("www.example.com"), AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com/path"), AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com?a=b"), AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com#a"), AUTH_DOMAIN);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
-                ID_AND_PASSWORD,
+                EMAIL,
                 AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
-        assertThat(cr.getAuthenticationMethod()).isEqualTo(ID_AND_PASSWORD);
+        assertThat(cr.getAuthenticationMethod()).isEqualTo(EMAIL);
         assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
-        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_setIdentifier_toEmpty() {
-        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
     @Test
     public void testBuilder_setPassword_toEmpty() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName_toEmpty() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
 
         assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
-        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, EMAIL, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
-                ID_AND_PASSWORD,
+                EMAIL,
                 new AuthenticationDomain("https://www.example.com")).build();
         Protobufs.Credential proto = cr.getProto();
         assertThat(proto).isNotNull();
     }
 
     @Test
     public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
-                ID_AND_PASSWORD,
+                EMAIL,
                 new AuthenticationDomain("https://www.example.com"))
                 .setDisplayName("Alice")
                 .setPassword("h4ckm3")
                 .setDisplayPicture("https://www.robohash.org/alice")
                 .build();
 
         // TODO: add some additional props and ensure these are preserved
 
         Parcel p = Parcel.obtain();
         cr.writeToParcel(p, 0);
         p.setDataPosition(0);
         Credential readCredential = Credential.CREATOR.createFromParcel(p);
 
         assertThat(readCredential.getIdentifier())
                 .isEqualTo(cr.getIdentifier());
         assertThat(readCredential.getAuthenticationMethod())
                 .isEqualTo(cr.getAuthenticationMethod());
         assertThat(readCredential.getAuthenticationDomain())
                 .isEqualTo(cr.getAuthenticationDomain());
         assertThat(readCredential.getDisplayName())
                 .isEqualTo(cr.getDisplayName());
         assertThat(readCredential.getDisplayPicture())
                 .isEqualTo(cr.getDisplayPicture());
         assertThat(readCredential.getPassword())
                 .isEqualTo(cr.getPassword());
     }
 }
diff --git a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
index 35a2bb9..5c372a6 100644
--- a/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
@@ -27,7 +27,2 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.HintRequest;
-import org.openyolo.protocol.IdentifierTypes;
-import org.openyolo.protocol.PasswordSpecification;
-import org.openyolo.protocol.Protobufs;
 import org.robolectric.RobolectricTestRunner;
@@ -37,434 +32,317 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link HintRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRequest request = new HintRequest.Builder(
-                AuthenticationMethods.ID_AND_PASSWORD,
+                AuthenticationMethods.EMAIL,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
-                .setIdentifierTypes(IdentifierTypes.EMAIL)
-                .addIdentifierType(IdentifierTypes.PHONE)
                 .addAdditionalProperty("a", new byte[] { 1, 2, 3})
                 .addAdditionalProperty("b", "hello")
                 .setPasswordSpecification(originalSpec)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
-                        AuthenticationMethods.ID_AND_PASSWORD,
+                        AuthenticationMethods.EMAIL,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
-        assertThat(request.getIdentifierTypes())
-                .containsOnly(
-                        IdentifierTypes.EMAIL,
-                        IdentifierTypes.PHONE);
 
         assertThat(request.getAdditionalProperties())
                 .containsOnly(
                         entry("a", new byte[] {1, 2, 3}),
                         entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
 
         assertThat(request.getAdditionalProperty("a")).isEqualTo(new byte[] {1, 2, 3});
         assertThat(request.getAdditionalPropertyAsString("b")).isEqualTo("hello");
 
         assertThat(request.getAdditionalProperty("c")).isNull();
         assertThat(request.getAdditionalPropertyAsString("d")).isNull();
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
-        HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        HintRequest request = new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
-    @Test
-    public void testBuild_overwriteIdentityTypes() {
-        HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes(IdentifierTypes.PHONE)
-                .setIdentifierTypes(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC)
-                .build();
-
-        assertThat(request.getIdentifierTypes())
-                .containsOnly(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC);
-    }
-
     @Test
     public void testForEmailAndPasswordAccount() {
         HintRequest request = HintRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
-                .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
-        assertThat(request.getIdentifierTypes())
-                .containsOnly(IdentifierTypes.EMAIL);
+                .containsOnly(AuthenticationMethods.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
         assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testSerialize() {
         HintRequest request = new HintRequest.Builder(
-                AuthenticationMethods.ID_AND_PASSWORD,
+                AuthenticationMethods.EMAIL,
                 AuthenticationMethods.FACEBOOK)
-                .setIdentifierTypes(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRequest read = HintRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
-            assertThat(read.getIdentifierTypes())
-                    .containsOnlyElementsOf(request.getIdentifierTypes());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullRequestProto() {
         new HintRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRequest.Builder((Uri) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullString() {
         new HintRequest.Builder((String) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRequest.Builder((Set<Uri>) null).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRequest.Builder(
-                AuthenticationMethods.ID_AND_PASSWORD,
+                AuthenticationMethods.EMAIL,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullStringInVarargs() {
         new HintRequest.Builder(
                 "custom://auth-method",
                 null,
                 "custom://another-auth-method")
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_invalidAuthMethodString() {
         new HintRequest.Builder("notAnAuthMethod").build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_emptySet() {
         new HintRequest.Builder(new HashSet<Uri>()).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<Uri> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Uri) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
-                        AuthenticationMethods.ID_AND_PASSWORD,
+                        AuthenticationMethods.EMAIL,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullStringInVarargs() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(
                         "custom://auth-method",
                         null,
                         "custom://another-auth-method")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods((Set<Uri>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(new HashSet<Uri>())
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<Uri> authMethods = new HashSet<>();
         authMethods.add(null);
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod((Uri) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod((String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_emptyString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod("")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_invalidString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAuthenticationMethod("notAnAuthMethod")
                 .build();
     }
 
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setIdentifierTypes_nullUri() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes((Uri) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setIdentifierTypes_nullUriInVarargs() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes(
-                        IdentifierTypes.EMAIL,
-                        null,
-                        IdentifierTypes.PHONE)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setIdentifierTypes_nullString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes((String) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setIdentifierTypes_nullStringInVarargs() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes(
-                        "custom://id-type",
-                        null,
-                        "custom://another-id-type")
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setIdentifierTypes_nullSet() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes((Set<Uri>) null)
-                .build();
-    }
-
-    public void testBuild_setIdentifierTypes_emptySet() {
-        HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes(new HashSet<Uri>())
-                .build();
-
-        assertThat(request.getIdentifierTypes()).isEmpty();
-    }
-
-    @Test(expected = RequireViolation.class)
-    public void testBuild_setIdentifierTypes_setContainingNull() {
-        HashSet<Uri> idTypes = new HashSet<>();
-        idTypes.add(null);
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setIdentifierTypes(idTypes)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addIdentifierType_nullUri() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addIdentifierType((Uri) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addIdentifierType_nullString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addIdentifierType((String) null)
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addIdentifierType_emptyString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addIdentifierType("")
-                .build();
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    @Test(expected = RequireViolation.class)
-    public void testBuild_addIdentifierType_invalidString() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addIdentifierType("notAnIdTpye")
-                .build();
-    }
-
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullMap() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(null)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperties_nullKey() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put(null, new byte[0]);
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAdditionalProperty_nullValue() {
         HashMap<String, byte[]> additionalProps = new HashMap<>();
         additionalProps.put("a", null);
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullKey() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty(null, "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_emptyKey() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("", "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullByteArrayValue() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (byte[]) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAdditionalProperty_nullStringValue() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("key", (String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setPasswordSpecification_null() {
-        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        new HintRequest.Builder(AuthenticationMethods.EMAIL)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
index e70cef4..3300fe5 100644
--- a/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
@@ -31,5 +31,2 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.protocol.AuthenticationMethods;
-import org.openyolo.protocol.Protobufs;
-import org.openyolo.protocol.RetrieveRequest;
 import org.robolectric.RobolectricTestRunner;
@@ -38,98 +35,98 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveRequestTest {
 
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
     private RetrieveRequest request;
 
     @Before
     public void setUp() {
-        request = new RetrieveRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+        request = new RetrieveRequest.Builder(AuthenticationMethods.EMAIL)
                 .addAdditionalProperty("a", "b")
                 .addAdditionalProperty("c", testBytes)
                 .build();
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
                     deserialized.getAdditionalProperties(),
                     request.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new RetrieveRequest.Builder(new HashSet<Uri>()  /* authenticationMethods */);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
         new RetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         RetrieveRequest request = RetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<Uri> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testGetAdditionalProperties() {
         assertThat(request.getAdditionalProperties()).isNotNull();
         assertThat(request.getAdditionalProperties()).hasSize(2);
         assertThat(request.getAdditionalPropertyAsString("a")).isEqualTo("b");
         assertThat(request.getAdditionalProperty("c")).isEqualTo(testBytes);
     }
 
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
-                .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
+                .containsOnly(AuthenticationMethods.EMAIL);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
         Protobufs.CredentialRetrieveRequest.parseFrom((byte[]) null);
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java b/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
index bfc6f84..5a54e83 100644
--- a/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
+++ b/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
@@ -31,108 +31,108 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for the custom Matchers suite extending hamcrest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CustomMatchersTest {
     @Test
     public void isWebUri_http() throws Exception {
         assertTrue(CustomMatchers.isWebUri().matches(Uri.parse("http://www.blah.com")));
     }
 
     @Test
     public void isWebUri_https() throws Exception {
         assertTrue(CustomMatchers.isWebUri().matches(Uri.parse("https://www.blah.com")));
     }
 
     @Test
     public void isWebUri_noproto() throws Exception {
         assertFalse(CustomMatchers.isWebUri().matches(Uri.parse("www.blah.com")));
     }
 
     @Test
     public void isWebUri_ftp() throws Exception {
         assertFalse(CustomMatchers.isWebUri().matches(Uri.parse("ftp://www.blah.com")));
     }
 
     @Test
     public void isHttpsUri() throws Exception {
         assertTrue(CustomMatchers.isHttpsUri().matches(Uri.parse("https://www.blah.com")));
     }
 
     @Test
     public void isHttpsUri_withPath() {
         assertTrue(CustomMatchers.isHttpsUri().matches(
                 Uri.parse("https://www.blah.com/resource")));
     }
 
     @Test
     public void isHttpsUri_withQuery() {
         assertTrue(CustomMatchers.isHttpsUri().matches(
                 Uri.parse("https://www.blah.com/resource?a=b")));
     }
 
     @Test
     public void isHttpsUri_withFragment() {
         assertTrue(CustomMatchers.isHttpsUri().matches(
                 Uri.parse("https://www.blah.com/resource#entry")));
     }
 
     @Test
     public void isHttpsUri_http() {
         assertFalse(CustomMatchers.isHttpsUri().matches(Uri.parse("http://www.blah.com")));
     }
 
     @Test
     public void isValidAuthenticationDomain_http() throws Exception {
         assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
                 Uri.parse("http://www.blah.com")));
     }
 
     @Test
     public void isValidAuthenticationDomain_https() throws Exception {
         assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
                 Uri.parse("https://www.blah.com")));
     }
 
     @Test
     public void isValidAuthenticationDomain_android() throws Exception {
         assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
                 Uri.parse("android://signature@com.blah.app")));
     }
 
     @Test
     public void isValidAuthenticationDomain() throws Exception {
         assertFalse(CustomMatchers.isValidAuthenticationDomain().matches(
                 Uri.parse("http://www.blah.com/resource")));
     }
 
     @Test
     public void isValidAuthenticationMethod_builtIn() throws Exception {
         assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(
-                AuthenticationMethods.ID_AND_PASSWORD));
+                AuthenticationMethods.EMAIL));
     }
 
     @Test
     public void isValidAuthenticationMethod_custom() {
         assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(
                 Uri.parse("https://www.blah.com")));
     }
 
     @Test
     public void isValidAuthenticationMethod_path() {
         assertFalse(CustomMatchers.isValidAuthenticationMethod().matches(
                 Uri.parse("http://www.blah.com/resource")));
     }
 
     @Test
     public void nullOr_null() {
         Matcher<Uri> matcher = CustomMatchers.nullOr(CustomMatchers.isHttpsUri());
         assertTrue(matcher.matches(null));
     }
 
     @Test
     public void nullOr_Https() {
         Matcher<Uri> matcher = CustomMatchers.nullOr(CustomMatchers.isHttpsUri());
         assertTrue(matcher.matches(Uri.parse("https://www.blah.com")));
     }
 }
\ No newline at end of file
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
index a5388f7..ade34b7 100644
--- a/protocol/proto/openyolo.proto
+++ b/protocol/proto/openyolo.proto
@@ -40,20 +40,8 @@ message CredentialRetrieveResponseList {
 message HintRetrieveRequest {
     // at least one authMethod required
     repeated string authMethods = 1;
 
-    // at least one idType required
-    repeated string idTypes = 2;
-
-    PasswordSpecification passwordSpec = 3;
-    map<string, TokenRequestInfo> supportedTokenProviders = 4;
-    map<string, bytes> additionalProps = 5;
-}
-
-message HintRetrieveResponse {
-    bytes retrieveIntent = 1; // required
-    map<string, bytes> additionalProps = 2;
-}
-
-message HintRetrieveResponseList {
-    repeated HintRetrieveResponse responses = 1;
+    PasswordSpecification passwordSpec = 2;
+    map<string, TokenRequestInfo> supportedTokenProviders = 3;
+    map<string, bytes> additionalProps = 4;
 }
diff --git a/spec/en/saving-credentials.md b/spec/en/saving-credentials.md
index 95a5d82..baeb76e 100644
--- a/spec/en/saving-credentials.md
+++ b/spec/en/saving-credentials.md
@@ -16,21 +16,20 @@ For a credential provider which only supports id-and-password based credentials,
 this would look as follows:
 
 ```xml
 <activity
     android:name="com.example.provider.SaveCredentialActivity"
     android:theme="@style/AppTheme.Dialog"
     android:exported="true"
     android:excludeFromRecents="true">
   <intent-filter>
     <action android:name="org.openyolo.save"/>
     <category android:name="org.openyolo" />
     <!--
-    as this app only supports saving ID and password based credentials, this is
-    declared using a data filter.
+    as this app only supports saving email based credentials, this is declared using a data filter.
     -->
     <data
         android:scheme="openyolo"
-        android:host="id-and-password" />
+        android:host="email" />
   </intent-filter>
 </activity>
 ```
diff --git a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
index 2057405..11f3da2 100644
--- a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
+++ b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
@@ -19,8 +19,4 @@ package org.openyolo.spi;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.openyolo.protocol.AuthenticationMethods.ID_AND_PASSWORD;
-
 import android.content.Intent;
-import android.util.Base64;
+
 import org.junit.Test;
@@ -32,29 +28,37 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
 
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.Assert.assertNull;
+import static org.openyolo.protocol.AuthenticationMethods.EMAIL;
+
 /**
  * Battery of tests for RetrieveIntentResultUtil
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveIntentResultUtilTest {
     public static final String EMAIL_ID = "alice@example.com";
-    private String base64string = "ChFhbGljZUBleGFtcGxlLmNvbRIXaHR0cHM6Ly93d3cuZXhhbXBsZS5jb20aGm9wZW55b2xvOi8v\naWQtYW5kLXBhc3N3b3Jk\n";
 
     @Test
     public void testCreateResponseData() throws Exception {
-        Credential cr = new Credential.Builder( EMAIL_ID, ID_AND_PASSWORD,
-        new AuthenticationDomain("https://www.example.com")).build();
-        Intent reposnse = RetrieveIntentResultUtil.createResponseData(cr.getProto());
-        byte[] bytes = reposnse.getExtras().getByteArray(ProtocolConstants.EXTRA_CREDENTIAL);
-        assertEquals(bytes.length, 72);
-        String data = Base64.encodeToString(bytes, Base64.DEFAULT);
-        assertEquals(base64string, data);
+        Credential cr = new Credential.Builder(
+                EMAIL_ID,
+                EMAIL,
+                new AuthenticationDomain("https://www.example.com"))
+                .build();
+        Intent response = RetrieveIntentResultUtil.createResponseData(cr.getProto());
+
+        assertThat(response.hasExtra(ProtocolConstants.EXTRA_CREDENTIAL)).isTrue();
+        byte[] bytes = response.getExtras().getByteArray(ProtocolConstants.EXTRA_CREDENTIAL);
+        Credential credential = Credential.fromProtoBytes(bytes);
+        assertThat(credential.getIdentifier()).isEqualTo(EMAIL_ID);
+        assertThat(credential.getAuthenticationMethod()).isEqualTo(EMAIL);
     }
 
     @Test
     public void testCreateResponseData_withNull() throws Exception {
-        Intent reposnse = RetrieveIntentResultUtil.createResponseData(null);
-        assertNull(reposnse.getExtras());
+        Intent response = RetrieveIntentResultUtil.createResponseData(null);
+        assertNull(response.getExtras());
     }
 
 }
\ No newline at end of file
diff --git a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
index 09e650d..064dcd4 100644
--- a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
+++ b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
@@ -30,87 +30,87 @@ import org.openyolo.protocol.AuthenticationMethods;
 public final class AuthenticationMethodsInputView extends LinearLayout {
 
     @BindView(R.id.facebook_authentication_method_checkbox)
     CheckBox mFaceBookCheckBox;
 
     @BindView(R.id.google_authentication_method_checkbox)
     CheckBox mGoogleCheckBox;
 
-    @BindView(R.id.id_and_password_authentication_method_checkbox)
-    CheckBox mIdAndPasswordCheckBox;
+    @BindView(R.id.email_authentication_method_checkbox)
+    CheckBox mEmailCheckBox;
 
     @BindView(R.id.custom_authentication_method_checkbox)
     CheckBox mCustomAuthenticationMethodCheckBox;
 
     @BindView(R.id.custom_authentication_method)
     EditText mCustomAuthenticationMethod;
 
     /**
      * Simple constructor to use when creating an authentication method selection view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public AuthenticationMethodsInputView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public AuthenticationMethodsInputView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public AuthenticationMethodsInputView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.authentication_method_input_layout, this);
 
         ButterKnife.bind(view);
     }
 
     /**
      * @return A set of authentication domains that are marked as enabled.
      */
     public Set<Uri> getEnabledAuthenticationMethods() {
         Set<Uri> authenticationMethods = new HashSet<>();
 
         if (mFaceBookCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.FACEBOOK);
         }
 
         if (mGoogleCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.GOOGLE);
         }
 
-        if (mIdAndPasswordCheckBox.isChecked()) {
-            authenticationMethods.add(AuthenticationMethods.ID_AND_PASSWORD);
+        if (mEmailCheckBox.isChecked()) {
+            authenticationMethods.add(AuthenticationMethods.EMAIL);
         }
 
         if (mCustomAuthenticationMethodCheckBox.isChecked()) {
             Uri authenticationMethod = Uri.parse(mCustomAuthenticationMethod.getText().toString());
             authenticationMethods.add(authenticationMethod);
         }
 
         return authenticationMethods;
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 8a788f8..ff8279d 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -37,213 +37,213 @@ import org.openyolo.protocol.PasswordSpecification;
 public final class CredentialView extends LinearLayout {
 
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
-    @BindView(R.id.openyolo_id_and_password_provider_button)
-    ImageButton mIdAndPasswordProviderButton;
+    @BindView(R.id.openyolo_email_provider_button)
+    ImageButton mEmailProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
     /**
      * Simple constructor to use when creating a credential view from code.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      */
     public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
     /**
      * Constructor that is called when inflating a view from XML.
      *
      * @param context The Context the view is running in, through which it can access the current
      *                theme, resources, etc.
      * @param attrs   The attributes of the XML tag that is inflating the view.
      */
     public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
     /**
      * Perform inflation from XML and apply a class-specific base style from a theme attribute.
      *
      * @param context  The Context the view is running in, through which it can access the current
      *                 theme, resources, etc.
      * @param attrs    The attributes of the XML tag that is inflating the view.
      * @param defStyle An attribute in the current theme that contains a reference to a style
      *                 resource that supplies default values for the view. Can be 0 to not look for
      *                 defaults.
      */
     public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
-        mIdAndPasswordProviderButton.setVisibility(visibility);
+        mEmailProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
-    @OnClick(R.id.openyolo_id_and_password_provider_button)
-    void setIdAndPasswordAuthenticationMethod() {
-        mAuthenticationMethodField.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
+    @OnClick(R.id.openyolo_email_provider_button)
+    void setEmailAuthenticationMethod() {
+        mAuthenticationMethodField.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
         Glide.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authenticationMethod = mAuthenticationMethodField.getText().toString();
         Uri authMethodUri = Uri.parse(authenticationMethod);
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethodUri,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
-        if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
+        if (authMethodUri.equals(AuthenticationMethods.EMAIL)) {
             credentialBuilder.setPassword(mPasswordField.getText().toString());
         }
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 2ee72c6..ad5552c 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -37,103 +37,103 @@ import org.openyolo.protocol.HintRequest;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_method_text_input)
     EditText mAuthenticationMethodInput;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         String uriString = mAuthenticationMethodInput.getText().toString();
         if (uriString.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         Uri authMethodUri = Uri.parse(uriString);
 
         HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethodUri);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
-    @OnClick(R.id.openyolo_id_and_password_provider_button)
-    void onIdAndPasswordAuthenticationMethod() {
-        mAuthenticationMethodInput.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
+    @OnClick(R.id.openyolo_email_provider_button)
+    void onEmailAuthenticationMethod() {
+        mAuthenticationMethodInput.setText(AuthenticationMethods.EMAIL.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/res/layout/authentication_method_input_layout.xml b/testapp/res/layout/authentication_method_input_layout.xml
index 02a93dd..574a5ee 100644
--- a/testapp/res/layout/authentication_method_input_layout.xml
+++ b/testapp/res/layout/authentication_method_input_layout.xml
@@ -1,41 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
 
   <android.support.v7.widget.AppCompatCheckBox
     android:id="@+id/facebook_authentication_method_checkbox"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/facebook_authentication_method_checkbox_text"/>
   <android.support.v7.widget.AppCompatCheckBox
     android:id="@+id/google_authentication_method_checkbox"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/google_authentication_method_checkbox_text"/>
   <android.support.v7.widget.AppCompatCheckBox
-    android:id="@+id/id_and_password_authentication_method_checkbox"
+    android:id="@+id/email_authentication_method_checkbox"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:text="@string/id_and_password_authentication_method_checkbox_text"/>
+    android:text="@string/email_authentication_method_checkbox_text"/>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.v7.widget.AppCompatCheckBox
       android:id="@+id/custom_authentication_method_checkbox"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center_vertical"/>
 
     <android.support.design.widget.TextInputEditText
       android:id="@+id/custom_authentication_method"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="@string/custom_authentication_method_hint"
       android:inputType="textNoSuggestions|textVisiblePassword"/>
   </LinearLayout>
 </LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/credential_layout.xml b/testapp/res/layout/credential_layout.xml
index b361a2f..030b4a9 100644
--- a/testapp/res/layout/credential_layout.xml
+++ b/testapp/res/layout/credential_layout.xml
@@ -1,180 +1,180 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/id_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/id_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/id_field_hint"
         android:inputType="textNoSuggestions|textVisiblePassword"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/generate_id_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_id_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/password_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/password_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/password_field_hint"
         android:inputType="textVisiblePassword"
         android:typeface="monospace"/>
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/generate_password_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_password_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/display_name_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/display_name_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/display_name_field_hint"
         android:inputType="textPersonName"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/generate_display_name_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_display_name_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/federation_provider_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/authentication_method_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/authentication_method_field_hint"
         android:inputType="textUri"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
-      android:id="@+id/openyolo_id_and_password_provider_button"
+      android:id="@+id/openyolo_email_provider_button"
       style="@style/SideButton"
-      android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
+      android:contentDescription="@string/open_yolo_email_button_content_description"
       app:srcCompat="@drawable/account_box_24dp"/>
 
     <ImageButton
       android:id="@+id/google_provider_button"
       style="@style/SideButton"
       android:contentDescription="@string/google_provider_button_content_description"
       app:srcCompat="@drawable/google_24dp"/>
 
     <ImageButton
       android:id="@+id/facebook_provider_button"
       style="@style/SideButton"
       android:contentDescription="@string/facebook_provider_button_content_description"
       app:srcCompat="@drawable/facebook_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/profile_picture_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/profile_picture_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/profile_picture_field_hint"
         android:inputType="textUri"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageView
       android:id="@+id/profile_picture_view"
       android:layout_width="48dp"
       android:layout_height="48dp"
       android:layout_gravity="center"
       android:contentDescription="@string/profile_picture_view_content_description"/>
 
     <ImageButton
       android:id="@+id/generate_profile_picture_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_profile_picture_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/hint_test_layout.xml b/testapp/res/layout/hint_test_layout.xml
index 953670f..d805a5a 100644
--- a/testapp/res/layout/hint_test_layout.xml
+++ b/testapp/res/layout/hint_test_layout.xml
@@ -1,87 +1,87 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/request"/>
 
     <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:orientation="horizontal">
 
       <android.support.design.widget.TextInputLayout
         android:id="@+id/id_layout"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1">
 
         <android.support.design.widget.TextInputEditText
           android:id="@+id/authentication_method_text_input"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:hint="@string/authentication_method_field_hint"
           android:inputType="textNoSuggestions|textVisiblePassword"/>
       </android.support.design.widget.TextInputLayout>
 
       <ImageButton
-        android:id="@+id/openyolo_id_and_password_provider_button"
+        android:id="@+id/openyolo_email_provider_button"
         style="@style/SideButton"
-        android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
+        android:contentDescription="@string/open_yolo_email_button_content_description"
         app:srcCompat="@drawable/account_box_24dp"/>
 
       <ImageButton
         android:id="@+id/google_provider_button"
         style="@style/SideButton"
         android:contentDescription="@string/google_provider_button_content_description"
         app:srcCompat="@drawable/google_24dp"/>
 
       <ImageButton
         android:id="@+id/facebook_provider_button"
         style="@style/SideButton"
         android:contentDescription="@string/facebook_provider_button_content_description"
         app:srcCompat="@drawable/facebook_24dp"/>
 
     </LinearLayout>
 
     <Button
       android:id="@+id/hint_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/hint_button_content_description"
       android:text="@string/hint_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/response"/>
 
     <org.openyolo.testapp.CredentialView
       android:id="@+id/hint_credential"
       android:layout_width="match_parent"
       android:layout_height="match_parent">
     </org.openyolo.testapp.CredentialView>
 
   </LinearLayout>
 </android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 8c557e3..2cbf51a 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,57 +1,57 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
     <string name="no_credentials">No credentials available</string>
     <string name="retrieve_cancelled">Credential retrieve cancelled</string>
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
-    <string name="id_and_password_authentication_method_checkbox_text">openyolo://id-and-password</string>
+    <string name="email_authentication_method_checkbox_text">openyolo://email</string>
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_cancelled">Hint retrieve cancelled</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
-    <string name="open_yolo_id_and_password_button_content_description">Set authentication method to Id and password</string>
+    <string name="open_yolo_email_button_content_description">Set authentication method to Email</string>
 
     <!-- Misc -->
     <string name="authentication_field_required">Must select authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
     <string name="no_credential_returned">No credential returned</string>
 </resources>

commit 833fefd3897e733ae5b1e71ac8a32e10cf1060da
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Thu Apr 13 15:20:31 2017 -0700

    The great proto3 migration
    
    In order to ensure we are using libraries that are carefully audited
    for their security properties on a regular basis, this CL moves from
    the Square wire proto library to Google's official proto3 javalite
    implementation.
    
    Furthermore, to resolve the "spi depends on api" problem, the core
    protos and data types have been moved to a new "protocol" module that
    api and spi depend on (in addition to bbq).
    
    This has resulted in widespread changes across the codebase, though
    primarily to imports and protocol buffer interactions. This will
    most likely break service provider implementations, though fixing
    this mostly entails calling the method-form to access proto fields.
    Sorry about this; we felt it was necessary to get this out of the
    way before attempting to ratify an implementer's draft of OpenYOLO
    Android.

diff --git a/api/build.gradle b/api/build.gradle
index 5acfc7b..68e8d94 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -1,5 +1,3 @@
 apply plugin: 'com.android.library'
-
 apply from:'../config/android-common.gradle'
-apply from:'../config/wire-proto.gradle'
 
@@ -14,9 +12,10 @@ android {
 dependencies {
     compile project(":bbq")
+    compile project(":protocol")
     compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
     compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
     compile "org.hamcrest:hamcrest-core:1.3"
     compile "org.valid4j:valid4j:0.5.0"
     apply from:'../config/testdeps.gradle', to:it
 }
diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
index 157619b..94e8874 100644
--- a/api/java/org/openyolo/api/CredentialClient.java
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -16,2 +16,9 @@ package org.openyolo.api;
 
+import static org.openyolo.protocol.ProtocolConstants.CREDENTIAL_DATA_TYPE;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_HINT_REQUEST;
+import static org.openyolo.protocol.ProtocolConstants.HINT_CREDENTIAL_ACTION;
+import static org.openyolo.protocol.ProtocolConstants.OPENYOLO_CATEGORY;
+import static org.openyolo.protocol.ProtocolConstants.SAVE_CREDENTIAL_ACTION;
+
 import android.content.ComponentName;
@@ -33,269 +40,243 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
-import org.openyolo.api.internal.IntentUtil;
 import org.openyolo.api.ui.ProviderPickerActivity;
-import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.RetrieveRequest;
+import org.openyolo.protocol.RetrieveResult;
+import org.openyolo.protocol.internal.IntentUtil;
 
 /**
  * Interact with credential providers on the device which support OpenYOLO.
  */
 public class CredentialClient {
 
-    /**
-     * The data type used for credential queries using the BBQ protocol.
-     */
-    public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
-
-    /**
-     * The extra value key used to store the credential in a retrieve intent response.
-     */
-    public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
-
-    /**
-     * The extra key value used to carry a hint request to a credential provider.
-     */
-    public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
-
-    /**
-     * The category used for all OpenYOLO-related intents.
-     */
-    public static final String OPENYOLO_CATEGORY = "org.openyolo";
-
-    /**
-     * The action used for hint intents.
-     */
-    public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
-
-    /**
-     * The action used for save intents.
-     */
-    public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
-
     private static final String LOG_TAG = "CredentialClient";
 
     private static final AtomicReference<CredentialClient> INSTANCE_REF
             = new AtomicReference<>();
 
     private final Context mApplicationContext;
 
     private final BroadcastQueryClient mQueryClient;
 
     /**
      * Retrieves the singleton credential client instance associated with the application.
      */
     public static CredentialClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         CredentialClient client = new CredentialClient(applicationContext);
         if (!INSTANCE_REF.compareAndSet(null, client)) {
             client = INSTANCE_REF.get();
         }
 
         return client;
     }
 
     CredentialClient(Context applicationContext) {
         mApplicationContext = applicationContext;
         mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
     }
 
     /**
      * Provides an intent to request a login hint. This will target the user's prefered credential
      * provider, if this can be determined. If no providers are available, {@code null} is
      * returned.
      */
     @Nullable
     public Intent getHintRetrieveIntent(final HintRequest request) {
         List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION, null);
 
         if (hintProviders.isEmpty()) {
             return null;
         }
 
-        byte[] encodedRequest = request.toProtocolBuffer().encode();
+        byte[] encodedRequest = request.toProtocolBuffer().toByteArray();
 
         // TODO: if a preferred credential provider is set, directly invoke it.
         ArrayList<Intent> hintIntents = new ArrayList<>();
         for (ComponentName providerActivity : hintProviders) {
             Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
             hintIntent.putExtra(EXTRA_HINT_REQUEST, encodedRequest);
             hintIntents.add(hintIntent);
         }
 
         return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
     }
 
     /**
      * Requests and retrieves any available credentials from the credential providers on the device.
      * @param request  Properties of the credential request
      * @param callback Handler for the result of the credential request.
      */
     public void retrieve(
             final RetrieveRequest request,
             final RetrieveCallback callback) {
         mQueryClient.queryFor(
                 CREDENTIAL_DATA_TYPE,
                 request.toProtocolBuffer(),
                 new CredentialRetrieveQueryCallback(callback));
     }
 
     /**
      * Provides an intent to save the provided credential. If no compatible credential providers
      * exist on the device, {@code null} will be returned. The intent should be started with a
      * call to
      * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
      *
      * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
      * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
      */
     @Nullable
     public Intent getSaveIntent(Credential credentialToSave) {
         List<ComponentName> saveProviders =
                 findProviders(SAVE_CREDENTIAL_ACTION, credentialToSave.getAuthenticationMethod());
 
         if (saveProviders.isEmpty()) {
             return null;
         }
 
         // TODO: if a preferred password manager is set, directly invoke it if it is in the list,
         // otherwise return no intent.
 
-        byte[] encodedCredential = credentialToSave.getProto().encode();
+        byte[] encodedCredential = credentialToSave.getProto().toByteArray();
 
         ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
         for (ComponentName providerActivity : saveProviders) {
             Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
             saveIntent.setData(credentialToSave.getAuthenticationMethod());
             saveIntent.putExtra(EXTRA_CREDENTIAL, encodedCredential);
             saveIntents.add(saveIntent);
         }
 
         return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
     }
 
     private Intent createIntent(ComponentName component, String action) {
         Intent intent = new Intent(action);
         intent.setClassName(
                 component.getPackageName(),
                 component.getClassName());
         intent.addCategory(OPENYOLO_CATEGORY);
         return intent;
     }
 
     /**
      * Extracts a credential from the data returned via
      * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
      * after a credential retrieve intent completes.
      */
     @Nullable
-    public Credential getCredentialFromActivityResult(@NonNull Intent resultData) {
+    public Credential getCredentialFromActivityResult(@Nullable Intent resultData) {
         if (resultData == null) {
-            Log.e(LOG_TAG, "resultData is null, exiting (returning null)");
+            Log.i(LOG_TAG, "resultData is null, exiting (returning null)");
             return null;
         }
 
         if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
             Log.i(LOG_TAG, "credential data missing from response");
             return null;
         }
 
         byte[] credentialBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
         if (credentialBytes == null) {
             Log.i(LOG_TAG, "No credential found in response");
             return null;
         }
 
-        org.openyolo.proto.Credential credentialProto;
+        Protobufs.Credential credentialProto;
         try {
-            credentialProto = org.openyolo.proto.Credential.ADAPTER.decode(credentialBytes);
+            credentialProto = Protobufs.Credential.parseFrom(credentialBytes);
         } catch (IOException ex) {
             Log.e(LOG_TAG, "failed to decode credential from response data");
             return null;
         }
 
         try {
             return new Credential.Builder(credentialProto).build();
         } catch (IllegalArgumentException ex) {
             Log.e(LOG_TAG, "validation of received credential failed", ex);
             return null;
         }
     }
 
     private List<ComponentName> findProviders(
             @NonNull String action,
             @Nullable Uri data) {
         Intent saveIntent = new Intent(action);
         saveIntent.addCategory(OPENYOLO_CATEGORY);
         if (data != null) {
             saveIntent.setData(data);
         }
 
         List<ResolveInfo> resolveInfos =
                 mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
 
         ArrayList<ComponentName> responders = new ArrayList<>();
         for (ResolveInfo info : resolveInfos) {
             responders.add(new ComponentName(
                     info.activityInfo.packageName,
                     info.activityInfo.name));
         }
 
         return responders;
     }
 
     private class CredentialRetrieveQueryCallback implements QueryCallback {
 
         private final RetrieveCallback mCallback;
 
         CredentialRetrieveQueryCallback(RetrieveCallback callback) {
             mCallback = callback;
         }
 
         @Override
         public void onResponse(long queryId, List<QueryResponse> queryResponses) {
             ArrayList<Intent> retrieveIntents = new ArrayList<>();
-            Map<String, CredentialRetrieveResponse> protoResponses = new HashMap<>();
+            Map<String, Protobufs.CredentialRetrieveResponse> protoResponses = new HashMap<>();
             for (QueryResponse queryResponse : queryResponses) {
-                CredentialRetrieveResponse response;
+                Protobufs.CredentialRetrieveResponse response;
                 try {
-                    response = CredentialRetrieveResponse.ADAPTER.decode(
+                    response = Protobufs.CredentialRetrieveResponse.parseFrom(
                             queryResponse.responseMessage);
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to decode credential retrieve response");
                     continue;
                 }
 
                 protoResponses.put(queryResponse.responderPackage, response);
 
-                if (response.retrieveIntent != null) {
+                if (!response.getRetrieveIntent().isEmpty()) {
                     // TODO: handle failure to decode retrieve intent gracefully
                     // (i.e. ignore the response)
                     Intent retrieveIntent =
-                            IntentUtil.fromBytes(response.retrieveIntent.toByteArray());
+                            IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
 
                     if (!queryResponse.responderPackage.equals(
                             retrieveIntent.getComponent().getPackageName())) {
                         Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
                         continue;
                     }
 
                     retrieveIntents.add(retrieveIntent);
                 }
             }
 
             Intent retrieveIntent = null;
             if (retrieveIntents.size() == 1) {
                 retrieveIntent = retrieveIntents.get(0);
             } else if (retrieveIntents.size() > 1) {
                 retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
                         mApplicationContext,
                         retrieveIntents);
             }
 
             mCallback.onComplete(
                     new RetrieveResult.Builder()
                             .setProtoResponses(protoResponses)
                             .setRetrieveIntent(retrieveIntent)
                             .build(),
                     null);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/KnownProviders.java b/api/java/org/openyolo/api/KnownProviders.java
index cead4db..f4bd536 100644
--- a/api/java/org/openyolo/api/KnownProviders.java
+++ b/api/java/org/openyolo/api/KnownProviders.java
@@ -18,3 +18,2 @@ import android.content.Context;
 import android.support.annotation.VisibleForTesting;
-
 import java.util.Arrays;
@@ -25,8 +24,9 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
+import org.openyolo.protocol.AuthenticationDomain;
 
 /**
  * Manages a list of known providers, identified by their package name and a hash of their
  * signing certificate. This class will attempt to dynamically retrieve a list of known providers
  * from openyolo.org if possible, otherwise it will fall back to the list of known providers at
  * compile time.
  */
diff --git a/api/java/org/openyolo/api/RetrieveCallback.java b/api/java/org/openyolo/api/RetrieveCallback.java
index b1d5c80..1785b9d 100644
--- a/api/java/org/openyolo/api/RetrieveCallback.java
+++ b/api/java/org/openyolo/api/RetrieveCallback.java
@@ -15,5 +15,7 @@
 package org.openyolo.api;
 
+import org.openyolo.protocol.RetrieveResult;
+
 /**
  * Asyncronous callback type for credential retrieval.
  */
diff --git a/api/java/org/openyolo/api/internal/KeyValuePairConverters.java b/api/java/org/openyolo/api/internal/KeyValuePairConverters.java
deleted file mode 100644
index 35e7e53..0000000
--- a/api/java/org/openyolo/api/internal/KeyValuePairConverters.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openyolo.api.internal;
-
-import android.util.Pair;
-import java.util.Collection;
-import java.util.Map;
-import okio.ByteString;
-import org.openyolo.proto.KeyValuePair;
-
-/**
- * Utility methods for converting between the {@link KeyValuePair} type used in OpenYOLO protocol
- * buffers and {@link Pair} as a more generic equivalent.
- */
-public final class KeyValuePairConverters {
-
-    private KeyValuePairConverters() {
-        throw new IllegalStateException("not intended to be constructed");
-    }
-
-    /**
-     * Converts {@link KeyValuePair} instances to {@link Pair} instances, typically for use by
-     * {@link CollectionConverter#toMap(Collection, ValueConverter)}.
-     */
-    public static final ValueConverter<KeyValuePair, Pair<String, byte[]>> CONVERTER_KVP_TO_PAIR =
-            new ValueConverter<KeyValuePair, Pair<String, byte[]>>() {
-                @Override
-                public Pair<String, byte[]> convert(KeyValuePair value) {
-                    return new Pair<>(value.name, value.value.toByteArray());
-                }
-            };
-
-    /**
-     * Converts {@link java.util.Map.Entry} instances to {@link KeyValuePair} instances.
-     */
-    public static final ValueConverter<Map.Entry<String, byte[]>, KeyValuePair>
-            CONVERTER_ENTRY_TO_KVP =
-            new ValueConverter<Map.Entry<String, byte[]>, KeyValuePair>() {
-                @Override
-                public KeyValuePair convert(Map.Entry<String, byte[]> value) {
-                    return new KeyValuePair(value.getKey(), ByteString.of(value.getValue()));
-                }
-            };
-}
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
index 7959249..f3d3c7d 100644
--- a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -50,166 +50,166 @@ import org.openyolo.api.R;
 /**
  * Activity which presents the list of providers that claim to have a credential available.
  * The user can select one of these options, which fires the associated intent for that provider,
  * or cancel the whole operation.
  */
 public class ProviderPickerActivity extends AppCompatActivity {
 
     private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
     private static final String EXTRA_TITLE_RES = "titleRes";
     private static final String LOG_TAG = "ProviderPicker";
 
     private CredentialClient mClient;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.picker_layout);
 
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         Resources res = getResources();
         @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = res.getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
 
         TextView titleView = (TextView) findViewById(R.id.picker_title);
         @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
         if (titleRes != 0) {
             //robotium has an issue recovering resources in the shadow classes.
             titleView.setText(titleRes);
         }
 
         ListView providerView = (ListView) findViewById(R.id.provider_list);
         List<Intent> retrieveIntents =
                 getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
         if (retrieveIntents == null) {
-            retrieveIntents = Collections.EMPTY_LIST;
+            retrieveIntents = Collections.emptyList();
         }
         providerView.setAdapter(new ProviderAdapter(retrieveIntents));
     }
 
     /**
      * Creates an intent for the picker activity, showing the user the list of credential providers
      * that can be used for the operation identified by the specified title text.
      */
     private static Intent createIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> providerIntents,
             @StringRes int titleRes) {
         require(context, notNullValue());
         Intent intent = new Intent(context, ProviderPickerActivity.class);
         intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
         intent.putExtra(EXTRA_TITLE_RES, titleRes);
         return intent;
     }
 
     /**
      * Creates an intent for displaying a list of providers that claim to have a credential for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createRetrieveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.retrieve_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can save a credential for the
      * user.
      */
     public static Intent createSaveIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> retrieveIntents) {
         return createIntent(context, retrieveIntents, R.string.save_picker_prompt);
     }
 
     /**
      * Creates an intent for displaying a list of providers that can provide a login hint for
      * the current app, allowing the user to choose which to use.
      */
     public static Intent createHintIntent(
             @NonNull Context context,
             @NonNull ArrayList<Intent> hintIntents) {
         return createIntent(context, hintIntents, R.string.hint_picker_prompt);
     }
 
     private final class ProviderAdapter extends ArrayAdapter<Intent> {
 
         private final List<Drawable> mProviderIcons;
         private final List<String> mProviderNames;
         private final List<Boolean> mProviderKnown;
 
         ProviderAdapter(List<Intent> providerIntents) {
             super(ProviderPickerActivity.this, 0, providerIntents);
             mProviderIcons = new ArrayList<>(providerIntents.size());
             mProviderNames = new ArrayList<>(providerIntents.size());
             mProviderKnown = new ArrayList<>(providerIntents.size());
 
             KnownProviders knownProviders = KnownProviders.getApplicationBoundInstance(
                     ProviderPickerActivity.this.getApplicationContext());
             PackageManager pm = getPackageManager();
             for (Intent providerIntent : providerIntents) {
                 try {
                     String packageName = providerIntent.getComponent().getPackageName();
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     mProviderIcons.add(info.loadIcon(pm));
                     mProviderNames.add(pm.getApplicationLabel(info).toString());
                     mProviderKnown.add(knownProviders.isKnown(packageName));
                 } catch (PackageManager.NameNotFoundException e) {
                     Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
                 }
             }
         }
 
         @Override
         public View getView(int position, View itemView, ViewGroup parent) {
             final Intent providerIntent = getItem(position);
             if (itemView == null) {
                 itemView = LayoutInflater.from(ProviderPickerActivity.this)
                         .inflate(R.layout.provider_item, parent, false);
             }
 
             ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
             TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
             TextView providerUnsafe =
                     (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
 
             providerIconView.setImageDrawable(mProviderIcons.get(position));
             providerNameView.setText(mProviderNames.get(position));
 
             if (mProviderKnown.get(position)) {
                 providerUnsafe.setVisibility(View.GONE);
             } else {
                 providerUnsafe.setVisibility(View.VISIBLE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     providerIntent.setFlags(
                             providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(providerIntent);
                     finish();
                 }
             });
             return itemView;
         }
 
         @SuppressWarnings("deprecation")
         private int getColor(@ColorRes int colorRes) {
             if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
                 return getResources().getColor(colorRes, null);
             } else {
                 return getResources().getColor(colorRes);
             }
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
index 14426ec..17e869d 100644
--- a/api/javatests/org/openyolo/api/CredentialClientTest.java
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -27,4 +27,5 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.openyolo.api.AuthenticationMethods.ID_AND_PASSWORD;
-import static org.openyolo.api.CredentialClient.EXTRA_CREDENTIAL;
+import static org.openyolo.protocol.AuthenticationMethods.ID_AND_PASSWORD;
+import static org.openyolo.protocol.ProtocolConstants.EXTRA_CREDENTIAL;
+
 import android.content.Context;
@@ -34,3 +35,2 @@ import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
-import java.io.IOException;
 import java.util.ArrayList;
@@ -42,2 +42,4 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Credential;
 import org.robolectric.RobolectricTestRunner;
@@ -46,71 +48,71 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for CredentialClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialClientTest {
     @Mock
     private Context mockContext;
 
     private CredentialClient underTest;
     public static final String EMAIL_ID = "alice@example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
             new AuthenticationDomain("https://www.example.com");
     private Credential testCredentials;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         underTest = new CredentialClient(mockContext);
         when(mockContext.getApplicationContext()).thenReturn(mockContext);
         testCredentials = new Credential.Builder(
                 EMAIL_ID,
                 ID_AND_PASSWORD,
                 new AuthenticationDomain("https://www.example.com")).build();
-
     }
 
     @Test
     public void testGetApplicationBoundInstance() throws Exception {
         CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
         assertNotNull(test);
     }
 
+    @SuppressWarnings("WrongConstant")
     @Test
     public void getSaveIntent() throws Exception {
         PackageManager mockPackageManager = mock(PackageManager.class);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
         List<ResolveInfo> response = new ArrayList<>();
         ResolveInfo info = new ResolveInfo();
         ActivityInfo mockActivityInfo = new ActivityInfo();
         mockActivityInfo.packageName =  "com.dashlane";
         mockActivityInfo.name =  "Dashlane";
         info.activityInfo = mockActivityInfo;
         response.add(info);
         when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(response);
 
         Intent i = underTest.getSaveIntent(testCredentials);
         assertNotNull(i);
         assertTrue(i.getExtras().getParcelableArrayList("providerIntents").size()==1);
 
     }
 
     @Test
     public void getCredentialFromActivityResult_noExtras() throws Exception {
         Intent intent = new Intent();
 
         Credential result = underTest.getCredentialFromActivityResult(intent);
         assertNull(result);
     }
 
     @Test
     public void getCredentialFromActivityResult_withExtras() throws Exception {
         Intent intent = new Intent();
-        byte[] array = org.openyolo.proto.Credential.ADAPTER.encode(testCredentials.getProto());
+        byte[] array = testCredentials.getProto().toByteArray();
         intent.putExtra(EXTRA_CREDENTIAL, array);
         Credential result = underTest.getCredentialFromActivityResult(intent);
         assertEquals(result.getIdentifier(), "alice@example.com");
         assertEquals(result.getAuthenticationMethod().toString(), "openyolo://id-and-password");
         assertEquals(result.getAuthenticationDomain().toString(), "https://www.example.com");
     }
 }
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/KnownProvidersTest.java b/api/javatests/org/openyolo/api/KnownProvidersTest.java
index 3992645..93d1709 100644
--- a/api/javatests/org/openyolo/api/KnownProvidersTest.java
+++ b/api/javatests/org/openyolo/api/KnownProvidersTest.java
@@ -26,2 +26,3 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import android.content.Context;
@@ -40,11 +41,11 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.openyolo.protocol.AuthenticationDomain;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
-import org.valid4j.errors.RequireViolation;
 
 /**
  * Battery of tests for KnownProviders.
  * Future-proofing the predefined values for the hardcoded providers.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java b/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
deleted file mode 100644
index f664711..0000000
--- a/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.openyolo.api.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import okio.ByteString;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openyolo.api.internal.CollectionConverter;
-import org.openyolo.api.internal.KeyValuePairConverters;
-import org.openyolo.proto.KeyValuePair;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-
-/**
- * Battery of tests for KeyValuePairConverters
- */
-@RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public class KeyValuePairConvertersTest {
-    @Test
-    public void convertToMap() throws Exception {
-        List<KeyValuePair> dataPairs = new ArrayList<>();
-
-        String first = "first";
-        String second = "second";
-        String third = "third";
-
-        dataPairs.add(new KeyValuePair(first, ByteString.of(first.getBytes())));
-        dataPairs.add(new KeyValuePair(second, ByteString.of(second.getBytes())));
-        dataPairs.add(new KeyValuePair(third, ByteString.of(third.getBytes())));
-
-        Map<String, byte[]> dataMap =
-                CollectionConverter.toMap(dataPairs, KeyValuePairConverters.CONVERTER_KVP_TO_PAIR);
-
-        assertThat(dataMap).hasSize(3);
-        assertThat(dataMap).containsOnlyKeys(first, second, third);
-        assertThat(dataMap.get(first)).isEqualTo(first.getBytes());
-        assertThat(dataMap.get(second)).isEqualTo(second.getBytes());
-        assertThat(dataMap.get(third)).isEqualTo(third.getBytes());
-    }
-
-    @Test
-    public void convertToMap_nullList() throws Exception {
-        Map<String, byte[]> dataMap =
-                CollectionConverter.toMap(null, KeyValuePairConverters.CONVERTER_KVP_TO_PAIR);
-        assertThat(dataMap).isEmpty();
-        assertThat(dataMap).isEmpty();
-    }
-
-    @Test
-    public void convertToList() throws Exception {
-        String first = "first";
-        String second = "second";
-        String third = "third";
-
-        Map<String, byte[]> data = new HashMap<>();
-        data.put(first, first.getBytes());
-        data.put(second, second.getBytes());
-        data.put(third, third.getBytes());
-
-        List<KeyValuePair> pairs =
-                CollectionConverter.toList(
-                        data.entrySet(),
-                        KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP);
-
-        assertThat(pairs).hasSize(3);
-        assertThat(pairs).contains(
-                new KeyValuePair(first, ByteString.of(first.getBytes())),
-                new KeyValuePair(second, ByteString.of(second.getBytes())),
-                new KeyValuePair(third, ByteString.of(third.getBytes())));
-    }
-
-    public void convertToList_nullEntrySet() throws Exception {
-        List<Map.Entry<String, byte[]>> nullEntrySet = null;
-        List<KeyValuePair> list =
-                CollectionConverter.toList(
-                        nullEntrySet,
-                        KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP);
-        assertThat(list).isEmpty();
-    }
-}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java b/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
index 072f5be..9550d28 100644
--- a/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
+++ b/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
@@ -20,2 +20,3 @@ package org.openyolo.api.ui;
 import static junit.framework.TestCase.assertNotNull;
+
 import android.app.Activity;
diff --git a/api/proto/openyolo.proto b/api/proto/openyolo.proto
deleted file mode 100644
index 3c5cf5e..0000000
--- a/api/proto/openyolo.proto
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-syntax = "proto2";
-
-package org.openyolo;
-
-option java_package = "org.openyolo.proto";
-
-message CredentialRetrieveRequest {
-    /**
-     * Deprecated since 03/07/17
-     * Filtering credentials by authentication domains has been deprecated. The
-     * authentication domain must instead be determined implicitly by via the
-     * calling package name.
-     * @see <a href="https://github.com/openid/OpenYOLO-Android/issues/5">
-     *     Original discussion to deprecate</a>
-     */
-    repeated string       authDomains        = 1 [deprecated=true];
-    repeated string       authMethods        = 2; // at least one required
-    repeated KeyValuePair additionalParams   = 3;
-}
-
-message CredentialRetrieveResponse {
-    optional bytes        retrieveIntent   = 1; // required
-    repeated KeyValuePair additionalParams = 2;
-}
-
-message CredentialRetrieveResponseList {
-    repeated CredentialRetrieveResponse responses = 1;
-}
-
-message HintRetrieveRequest {
-    repeated string                authMethods      = 1; // at least one required
-    repeated string                idTypes          = 2; // at least one required
-    repeated KeyValuePair          additionalParams = 3;
-    optional PasswordSpecification passwordSpec     = 4;
-}
-
-message HintRetrieveResponse {
-    optional bytes        retrieveIntent = 1; // required
-    repeated KeyValuePair additionalParams = 2;
-}
-
-message HintRetrieveResponseList {
-    repeated HintRetrieveResponse responses = 1;
-}
-
-message Credential {
-    optional string       id                    = 1; // required
-    optional string       authDomain            = 2; // required
-    optional string       authMethod            = 3; // required
-    optional string       displayName           = 4;
-    optional string       displayPictureUri     = 5;
-    optional string       password              = 6;
-    repeated KeyValuePair additionalProps       = 7;
-}
-
-message CredentialList {
-    repeated Credential credentials = 1;
-}
-
-message KeyValuePair {
-    optional string name  = 1; // required
-    optional bytes  value = 2;
-}
-
-message PasswordSpecification {
-    optional string          allowed      = 1; // required
-    optional uint32          minSize      = 2; // required
-    optional uint32          maxSize      = 3; // required
-    repeated RequiredCharSet requiredSets = 4;
-}
-
-message RequiredCharSet {
-    optional string chars = 1; // required
-    optional uint32 count = 2; // required
-}
\ No newline at end of file
diff --git a/api/res/layout/provider_item.xml b/api/res/layout/provider_item.xml
index 517a9fd..e454adf 100644
--- a/api/res/layout/provider_item.xml
+++ b/api/res/layout/provider_item.xml
@@ -1,46 +1,45 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="48dp"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:clickable="true"
     android:background="?attr/selectableItemBackground"
     android:orientation="horizontal"
     android:gravity="center_vertical">
 
     <ImageView
         android:id="@+id/provider_icon"
         android:layout_width="24dp"
         android:layout_height="24dp"
         android:contentDescription="@string/provider_icon_contentDescription" />
 
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:layout_marginLeft="32dp"
         android:layout_marginStart="32dp"
         android:orientation="vertical">
 
         <TextView
             android:id="@+id/provider_name"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
             tools:text="Provider Name"/>
 
         <TextView
             android:id="@+id/unsafe_provider_warning"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:drawableLeft="@drawable/warning_icon_compat_wrapper"
             android:drawableStart="@drawable/warning_icon_compat_wrapper"
             android:drawablePadding="4dp"
             android:text="@string/possibly_unsafe"
             android:textAppearance="@style/TextAppearance.AppCompat.Caption"
             android:textColor="@color/amber_700_54pc"/>
     </LinearLayout>
 
 </LinearLayout>
diff --git a/bbq/AndroidManifest.xml b/bbq/AndroidManifest.xml
index 8069ad0..f17942b 100644
--- a/bbq/AndroidManifest.xml
+++ b/bbq/AndroidManifest.xml
@@ -1,3 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.google.bbq" />
+<manifest package="com.google.bbq" />
diff --git a/bbq/build.gradle b/bbq/build.gradle
index cc6894d..48a53c3 100644
--- a/bbq/build.gradle
+++ b/bbq/build.gradle
@@ -3,3 +3,3 @@ apply plugin: 'com.android.library'
 apply from:'../config/android-common.gradle'
-apply from:'../config/wire-proto.gradle'
+apply from:'../config/protobuf.gradle'
 apply from:'../config/third-party.gradle'
diff --git a/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java b/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java
index a158eff..d801f74 100644
--- a/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java
+++ b/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java
@@ -22,3 +22,3 @@ import android.support.annotation.NonNull;
 import android.util.Log;
-import com.google.bbq.proto.BroadcastQuery;
+import com.google.bbq.Protobufs.BroadcastQuery;
 import java.io.IOException;
@@ -26,45 +26,45 @@ import java.io.IOException;
 /**
  * Partial BBQ query receiver implementation, that should be extended by providers.
  * This implementation handles some basic validation and decoding of the request before
  * handing the request to {@link #processQuery(Context, BroadcastQuery)}.
  */
 public abstract class BaseBroadcastQueryReceiver extends BroadcastReceiver {
 
     protected final String mLogTag;
 
     /**
      * Creates a query receiver, using the specified log tag for warning messages in parsing
      * received requests.
      */
     public BaseBroadcastQueryReceiver(String logTag) {
         mLogTag = logTag;
     }
 
     @Override
     public void onReceive(final Context context, final Intent intent) {
         byte[] queryBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_QUERY_MESSAGE);
         if (queryBytes == null) {
             Log.w(mLogTag, "Received message without query data");
             return;
         }
 
         final BroadcastQuery query;
         try {
-            query = BroadcastQuery.ADAPTER.decode(queryBytes);
+            query = BroadcastQuery.parseFrom(queryBytes);
         } catch (IOException e) {
             Log.w(mLogTag, "Unable to decode query data");
             return;
         }
 
         try {
-            context.getPackageManager().getPackageInfo(query.requestingApp, 0);
+            context.getPackageManager().getPackageInfo(query.getRequestingApp(), 0);
         } catch (PackageManager.NameNotFoundException ex) {
-            Log.w(mLogTag, "Received query from non-existent app: " + query.requestingApp);
+            Log.w(mLogTag, "Received query from non-existent app: " + query.getRequestingApp());
             return;
         }
 
         processQuery(context, query);
     }
 
     protected abstract void processQuery(@NonNull Context context, @NonNull BroadcastQuery query);
 }
diff --git a/bbq/java/com/google/bbq/BroadcastQueryClient.java b/bbq/java/com/google/bbq/BroadcastQueryClient.java
index 9dd3e2a..f6960f0 100644
--- a/bbq/java/com/google/bbq/BroadcastQueryClient.java
+++ b/bbq/java/com/google/bbq/BroadcastQueryClient.java
@@ -27,5 +27,6 @@ import android.text.TextUtils;
 import android.util.Log;
-import com.google.bbq.proto.BroadcastQuery;
-import com.google.bbq.proto.BroadcastQueryResponse;
-import com.squareup.wire.Message;
+import com.google.bbq.Protobufs.BroadcastQuery;
+import com.google.bbq.Protobufs.BroadcastQueryResponse;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.MessageLite;
 import java.io.IOException;
@@ -45,319 +46,318 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
-import okio.ByteString;
 
 /**
  * Dispatches broadcast queries to available data providers.
  */
 public final class BroadcastQueryClient {
 
     /**
      * The default amount of time that this client will wait for responses from providers, before
      * ignoring them.
      */
     public static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2);
 
     private static final String LOG_TAG = "BroadcastQueryClient";
 
     private static final AtomicReference<BroadcastQueryClient> INSTANCE =
             new AtomicReference<>();
 
     @NonNull
     private final Context mContext;
 
     @NonNull
     private final SecureRandom mSecureRandom;
 
     @NonNull
     private final ConcurrentHashMap<Long, PendingQuery> mPendingQueries;
 
     @NonNull
     private final ScheduledExecutorService mExecutorService;
 
     @NonNull
     private final AtomicBoolean mDisposed;
 
     /**
      * Retrieves the global instance of the broadcast query client for the application
      * associated to the provided context.
      */
     @NonNull
     public static BroadcastQueryClient getApplicationBoundInstance(Context context) {
         Context applicationContext = context.getApplicationContext();
         BroadcastQueryClient client = new BroadcastQueryClient(applicationContext);
         if (!INSTANCE.compareAndSet(null, client)) {
             client.dispose();
             client = INSTANCE.get();
         }
 
         return client;
     }
 
     BroadcastQueryClient(@NonNull Context context) {
         mContext = context;
         mSecureRandom = new SecureRandom();
         mPendingQueries = new ConcurrentHashMap<>();
         mExecutorService = Executors.newSingleThreadScheduledExecutor();
         mDisposed = new AtomicBoolean(false);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified protocol buffer
      * message (if required). The response to this query will be provided to the specified callback.
      * A {@link #DEFAULT_TIMEOUT_MS default timeout} will be used.
      */
     public void queryFor(
             @NonNull String dataType,
-            @Nullable Message queryMessage,
+            @Nullable MessageLite queryMessage,
             @NonNull QueryCallback callback) {
         queryFor(dataType,
                 queryMessage,
                 DEFAULT_TIMEOUT_MS,
                 callback);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified protocol buffer
      * message (if required). The response to this query will be provided to the specified callback.
      */
     public void queryFor(
             @NonNull String dataType,
-            @Nullable Message queryMessage,
+            @Nullable MessageLite queryMessage,
             long timeoutInMs,
             @NonNull QueryCallback callback) {
         queryFor(dataType,
-                queryMessage != null ? queryMessage.encode() : null,
+                queryMessage != null ? queryMessage.toByteArray() : null,
                 timeoutInMs,
                 callback);
     }
 
     /**
      * Dispatches a query for the specified data type, carrying the specified message (if required).
      * The response to this query will be provided to the specified callback.
      */
     public void queryFor(
             @NonNull String dataType,
             @Nullable byte[] queryMessage,
             long timeoutInMs,
             @NonNull QueryCallback callback) {
         require(!TextUtils.isEmpty(dataType), "dataType must not be null or empty");
         require(timeoutInMs > 0, "Timeout must be greater than zero");
         require(callback, notNullValue());
         require(!isDisposed(), "BroadcastQueryClient has been disposed");
 
         PendingQuery pq = new PendingQuery(
                 dataType,
                 queryMessage,
                 timeoutInMs,
                 callback);
 
         long queryId;
         do {
             queryId = mSecureRandom.nextLong();
         } while (mPendingQueries.putIfAbsent(queryId, pq) != null);
         pq.dispatch(queryId);
     }
 
     /**
      * Disposes all leakable resources associated with this client.
      */
     private void dispose() {
         if (!mDisposed.compareAndSet(false, true)) {
             return;
         }
 
         mExecutorService.shutdownNow();
         for (PendingQuery pq : mPendingQueries.values()) {
             mContext.unregisterReceiver(pq.mResponseReceiver);
         }
     }
 
     /**
      * Determines whether this client has been disposed, and therefore should no longer be used.
      */
     private boolean isDisposed() {
         return mDisposed.get();
     }
 
     private Intent createQueryIntent(
             PendingQuery pendingQuery,
             String responderPackage,
             long responseId) {
         Intent queryIntent = QueryUtil.createEmptyQueryIntent(pendingQuery.mDataType);
         queryIntent.setPackage(responderPackage);
         queryIntent.putExtra(QueryUtil.EXTRA_QUERY_MESSAGE,
-                new BroadcastQuery.Builder()
-                        .requestingApp(mContext.getPackageName())
-                        .dataType(pendingQuery.mDataType)
-                        .requestId(pendingQuery.mQueryId)
-                        .responseId(responseId)
-                        .queryMessage(pendingQuery.mQueryMessage != null
-                                ? ByteString.of(pendingQuery.mQueryMessage)
+                BroadcastQuery.newBuilder()
+                        .setRequestingApp(mContext.getPackageName())
+                        .setDataType(pendingQuery.mDataType)
+                        .setRequestId(pendingQuery.mQueryId)
+                        .setResponseId(responseId)
+                        .setQueryMessage(pendingQuery.mQueryMessage != null
+                                ? ByteString.copyFrom(pendingQuery.mQueryMessage)
                                 : null)
                         .build()
-                        .encode());
+                        .toByteArray());
         return queryIntent;
     }
 
     private final class PendingQuery {
         final String mDataType;
         final byte[] mQueryMessage;
         final Map<Long, String> mRespondersById;
         final CopyOnWriteArraySet<Long> mPendingResponses;
         final ConcurrentHashMap<String, QueryResponse> mResponses;
         final QueryCallback mQueryCallback;
         final long mTimeoutInMs;
 
         long mQueryId;
         ScheduledFuture<Void> mTimeoutFuture;
         BroadcastReceiver mResponseReceiver;
 
         PendingQuery(
                 String dataType,
                 byte[] queryMessage,
                 long timeoutInMs,
                 QueryCallback queryCallback) {
             mDataType = dataType;
             mQueryMessage = queryMessage;
             mTimeoutInMs = timeoutInMs;
 
             mRespondersById = buildRespondersById();
             mPendingResponses = new CopyOnWriteArraySet<>();
             for (long responderId : mRespondersById.keySet()) {
                 mPendingResponses.add(responderId);
             }
             mResponses = new ConcurrentHashMap<>();
             mQueryCallback = queryCallback;
         }
 
         Map<Long, String> buildRespondersById() {
             Set<String> responders = QueryUtil.getRespondersForDataType(mContext, mDataType);
             HashMap<Long, String> tempRespondersById = new HashMap<>();
             for (String responderPackage : responders) {
                 long responderId;
                 do {
                     responderId = mSecureRandom.nextLong();
                 } while (tempRespondersById.containsKey(responderId));
 
                 tempRespondersById.put(responderId, responderPackage);
             }
             return tempRespondersById;
         }
 
         void dispatch(long queryId) {
             mQueryId = queryId;
 
             if (mRespondersById.isEmpty()) {
                 complete();
                 return;
             }
 
             mResponseReceiver = new ResponseHandler(this);
             mContext.registerReceiver(mResponseReceiver, getResponseFilter());
 
             for (Map.Entry<Long, String> responderEntry : mRespondersById.entrySet()) {
                 long responseId = responderEntry.getKey();
                 String responderPackage = responderEntry.getValue();
                 mContext.sendBroadcast(createQueryIntent(this, responderPackage, responseId));
             }
 
             mTimeoutFuture = mExecutorService.schedule(
                     new QueryTimeoutHandler(this),
                     mTimeoutInMs,
                     TimeUnit.MILLISECONDS);
         }
 
         void complete() {
             if (!mPendingQueries.remove(mQueryId, this)) {
                 // response already delivered
                 return;
             }
 
             if (mTimeoutFuture != null) {
                 mTimeoutFuture.cancel(false);
             }
 
             if (mResponseReceiver != null) {
                 mContext.unregisterReceiver(mResponseReceiver);
             }
 
             mQueryCallback.onResponse(mQueryId, new ArrayList<>(mResponses.values()));
         }
 
         IntentFilter getResponseFilter() {
             IntentFilter filter = new IntentFilter();
             filter.addAction(QueryUtil.createResponseAction(mDataType, mQueryId));
             filter.addCategory(QueryUtil.BBQ_CATEGORY);
             return filter;
         }
     }
 
     /**
      * Forcibly completes a pending query when a timeout is reached.
      */
     private final class QueryTimeoutHandler implements Callable<Void> {
 
         final PendingQuery mPendingQuery;
 
         QueryTimeoutHandler(PendingQuery pendingQuery) {
             mPendingQuery = pendingQuery;
         }
 
         @Override
         public Void call() throws Exception {
             mPendingQuery.complete();
             return null;
         }
     }
 
     /**
      * Captures broadcast responses for queries.
      */
     private final class ResponseHandler extends BroadcastReceiver {
 
         final PendingQuery mPendingQuery;
 
         ResponseHandler(PendingQuery pendingQuery) {
             mPendingQuery = pendingQuery;
         }
 
         @Override
         public void onReceive(Context context, Intent intent) {
             byte[] responseBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
             if (responseBytes == null) {
                 Log.w(LOG_TAG, "Received query response without a defined message");
                 return;
             }
 
             BroadcastQueryResponse response;
             try {
-                response = BroadcastQueryResponse.ADAPTER.decode(responseBytes);
+                response = BroadcastQueryResponse.parseFrom(responseBytes);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Unable to parse query response message");
                 return;
             }
 
-            String responder = mPendingQuery.mRespondersById.get(response.responseId);
+            String responder = mPendingQuery.mRespondersById.get(response.getResponseId());
             if (responder == null) {
                 Log.w(LOG_TAG, "Received response from unknown responder");
                 return;
             }
 
-            if (!mPendingQuery.mPendingResponses.remove(response.responseId)) {
+            if (!mPendingQuery.mPendingResponses.remove(response.getResponseId())) {
                 Log.w(LOG_TAG, "Duplicate response received; ignoring");
                 return;
             }
 
-            if (response.responseMessage != null) {
+            if (response.getResponseMessage() != null) {
                 QueryResponse queryResponse = new QueryResponse(
                         responder,
-                        response.responseId,
-                        response.responseMessage.toByteArray());
+                        response.getResponseId(),
+                        response.getResponseMessage().toByteArray());
                 mPendingQuery.mResponses.put(responder, queryResponse);
             }
 
             if (mPendingQuery.mPendingResponses.isEmpty()) {
                 mPendingQuery.complete();
             }
         }
     }
 }
diff --git a/bbq/java/com/google/bbq/QueryResponseSender.java b/bbq/java/com/google/bbq/QueryResponseSender.java
index 8fae24c..cc46888 100644
--- a/bbq/java/com/google/bbq/QueryResponseSender.java
+++ b/bbq/java/com/google/bbq/QueryResponseSender.java
@@ -24,60 +24,62 @@ import android.support.annotation.Nullable;
 import android.support.annotation.VisibleForTesting;
-import com.google.bbq.proto.BroadcastQuery;
-import com.google.bbq.proto.BroadcastQueryResponse;
-import okio.ByteString;
+import com.google.bbq.Protobufs.BroadcastQuery;
+import com.google.bbq.Protobufs.BroadcastQueryResponse;
+import com.google.protobuf.ByteString;
 
 
 /**
  * A utility for data providers that encodes and sends query responses.
  */
 public class QueryResponseSender {
 
     private static final String LOG_TAG = "QueryResponseSender";
 
     private final Context mContext;
 
     /**
      * Creates a response sender.
      */
     public QueryResponseSender(@NonNull Context context) {
         mContext = require(context, notNullValue());
     }
 
     /**
      * Dispatches a query response message for the specified query.
      */
     public void sendResponse(
             @NonNull BroadcastQuery query,
             @Nullable byte[] responseMessage) {
         require(query, notNullValue());
 
         BroadcastQueryResponse.Builder responseBuilder = createResponseBuilder(query);
         if (responseMessage != null) {
-            responseBuilder.responseMessage = ByteString.of(responseMessage);
+            responseBuilder.setResponseMessage(ByteString.copyFrom(responseMessage));
         }
 
         Intent responseBroadcast = getIntentForQuery(query, responseBuilder);
 
         mContext.sendBroadcast(responseBroadcast);
     }
 
     @VisibleForTesting
     @NonNull
     Intent getIntentForQuery(@NonNull BroadcastQuery query,
                              BroadcastQueryResponse.Builder responseBuilder) {
         Intent responseBroadcast =
-                new Intent(QueryUtil.createResponseAction(query.dataType, query.requestId));
+                new Intent(QueryUtil.createResponseAction(
+                        query.getDataType(),
+                        query.getRequestId()));
         responseBroadcast.addCategory(QueryUtil.BBQ_CATEGORY);
-        responseBroadcast.setPackage(query.requestingApp);
+        responseBroadcast.setPackage(query.getRequestingApp());
         responseBroadcast.putExtra(
                 QueryUtil.EXTRA_RESPONSE_MESSAGE,
-                responseBuilder.build().encode());
+                responseBuilder.build().toByteArray());
         return responseBroadcast;
     }
 
     private BroadcastQueryResponse.Builder createResponseBuilder(BroadcastQuery query) {
-        return new BroadcastQueryResponse.Builder()
-                .requestId(query.requestId)
-                .responseId(query.responseId);
+        return BroadcastQueryResponse.newBuilder()
+                .setRequestId(query.getRequestId())
+                .setResponseId(query.getResponseId());
     }
 }
diff --git a/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java b/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java
index 5947570..87f2c28 100644
--- a/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java
+++ b/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java
@@ -21,2 +21,3 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
+
 import android.content.Context;
@@ -24,3 +25,3 @@ import android.content.Intent;
 import android.support.annotation.NonNull;
-import com.google.bbq.proto.BroadcastQuery;
+import com.google.bbq.Protobufs.BroadcastQuery;
 import org.junit.Before;
diff --git a/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java b/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
index cb4e799..c85611a 100644
--- a/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
+++ b/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
@@ -25,2 +25,3 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import android.content.BroadcastReceiver;
@@ -44,107 +45,108 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for BroadcastQueryClient
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class BroadcastQueryClientTest {
     @Mock
     private Context mockContext;
     @Mock
     private PackageManager mockPackageManager;
 
     private BroadcastQueryClient underTest;
     private ArrayList<ResolveInfo> mPackageinfos;
 
     @org.junit.Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
+        when(mockContext.getPackageName()).thenReturn("com.example.app");
         underTest = new BroadcastQueryClient(mockContext);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
 
         ResolveInfo mockinfo1=new ResolveInfo();
         mockinfo1.activityInfo = new ActivityInfo();
         mockinfo1.activityInfo.packageName= "com.openyolo";
 
         ResolveInfo mockinfo2=new ResolveInfo();
         mockinfo2.activityInfo = new ActivityInfo();
         mockinfo2.activityInfo.packageName= "com.google";
 
         mPackageinfos = new ArrayList<>(2);
         mPackageinfos.add(mockinfo1);
         mPackageinfos.add(mockinfo2);
 
         when(mockPackageManager.queryBroadcastReceivers(any(Intent.class),
                 anyInt())).thenReturn(mPackageinfos);
     }
 
     @Test
     public void queryFor() throws Exception {
         String dataType = "datatype";
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = 500L;
         QueryCallback callback = new QueryCallback() {
             @Override
             public void onResponse(long queryId, List<QueryResponse> responses) {
                 //not expecting the callback as this is happening through broadcasts.
                 //if we get here, fail so it raises some eyebrows...
                 fail();
             }
         };
 
         underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
         verify(mockContext, times(1)).registerReceiver(any(BroadcastReceiver.class),
                 any(IntentFilter.class));
         verify(mockContext, times(mPackageinfos.size())).sendBroadcast(any(Intent.class));
 
     }
 
     @Test(expected = RequireViolation.class)
     public void queryFor_negative_timestamp() throws Exception {
         String dataType = "datatype";
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = -500L;
         QueryCallback callback = new QueryCallback() {
             @Override
             public void onResponse(long queryId, List<QueryResponse> responses) {
                 //not expecting the callback as this is happening through broadcasts.
                 //if we get here, fail so it raises some eyebrows...
                 fail();
             }
         };
 
         underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
     }
 
     @Test(expected = RequireViolation.class)
     public void queryFor_pushNullDatatype() throws Exception {
         String dataType = null;
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = 500L;
         QueryCallback callback = new QueryCallback() {
             @Override
             public void onResponse(long queryId, List<QueryResponse> responses) {
             }
         };
 
         underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
 
     }
 
     @Test(expected = RequireViolation.class)
     public void queryFor_pushNullCallback() throws Exception {
         String dataType = "datatype";
         byte[] queryMessage = new byte[64];
         SecureRandom sr = new SecureRandom();
         sr.nextBytes(queryMessage);
         long timeoutInMs = 500L;
         underTest.queryFor(dataType, queryMessage, timeoutInMs, null);
 
     }
 
 }
\ No newline at end of file
diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
index c9ef20c..a98f503 100644
--- a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
@@ -20,2 +20,3 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.internal.verification.VerificationModeFactory.times;
+
 import android.content.Context;
@@ -23,8 +24,4 @@ import android.content.Intent;
 import android.support.annotation.NonNull;
-import com.google.bbq.proto.BroadcastQuery;
-import com.google.bbq.proto.BroadcastQueryResponse;
-import com.google.bbq.proto.Parameter;
-import java.util.LinkedList;
-import java.util.List;
-import okio.ByteString;
+import com.google.bbq.Protobufs.BroadcastQuery;
+import com.google.bbq.Protobufs.BroadcastQueryResponse;
 import org.junit.Before;
@@ -37,42 +34,46 @@ import org.valid4j.errors.RequireViolation;
 /**
  * This class contains a set of tests for QueryResponseSenderTest.
  */
 public class QueryResponseSenderTest {
     @Mock
     Context mockContext;
     @Mock
     Intent mockIntent;
 
     BroadcastQuery mockQuery;
 
     private QueryResponseSender underTest;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         //set mock values.
-        List<Parameter> additionalArgs = new LinkedList<>();
-        mockQuery = new BroadcastQuery("dataType", "requestingApp", 128L, 256L, ByteString.EMPTY, additionalArgs);
+        mockQuery = BroadcastQuery.newBuilder()
+            .setDataType("dataType")
+            .setRequestingApp("requestingApp")
+            .setRequestId(128L)
+            .setResponseId(256L)
+            .build();
 
         //Create a test object for the QueryResponseSender using the mock
         underTest = new QueryResponseSender(mockContext) {
             @NonNull
             @Override
             Intent getIntentForQuery(@NonNull BroadcastQuery query, BroadcastQueryResponse.Builder responseBuilder) {
                 return mockIntent;
             }
         };
     }
 
     @Test
     public void sendResponse_nonNullQuery_nullReponse() throws Exception {
         underTest.sendResponse(mockQuery, null);
         verify(mockContext, times(1)).sendBroadcast(mockIntent);
     }
 
     @Test(expected = RequireViolation.class)
     public void sendResponse_nullQuery_nullReponse() throws Exception {
         underTest.sendResponse(null, null);
     }
 }
\ No newline at end of file
diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
index 091add1..b0bac5b 100644
--- a/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
@@ -23,2 +23,3 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.internal.verification.VerificationModeFactory.times;
+
 import android.os.Parcel;
diff --git a/bbq/proto/bbq.proto b/bbq/proto/bbq.proto
index b8b55ec..47b4935 100644
--- a/bbq/proto/bbq.proto
+++ b/bbq/proto/bbq.proto
@@ -16,3 +16,3 @@
 
-syntax = "proto2";
+syntax = "proto3";
 
@@ -20,11 +20,13 @@ package com.google.bbq;
 
-option java_package = "com.google.bbq.proto";
+option java_package = "com.google.bbq";
+option java_outer_classname = "Protobufs";
 
 message BroadcastQuery {
-	optional string       dataType         = 1; // required
-	optional string       requestingApp    = 2; // required
-	optional sfixed64     requestId        = 3; // required
-	optional sfixed64     responseId       = 4; // required
-	optional bytes        queryMessage     = 5;
-	repeated Parameter    additionalParams = 6;
+    string   dataType      = 1; // required
+    string   requestingApp = 2; // required
+    sfixed64 requestId     = 3; // required
+    sfixed64 responseId    = 4; // required
+    bytes    queryMessage  = 5;
+
+    map<string, bytes> additionalProps = 6;
 }
@@ -32,6 +34,7 @@ message BroadcastQuery {
 message BroadcastQueryResponse {
-	optional sfixed64  requestId             = 1; // required
-	optional sfixed64  responseId            = 2; // required
-	optional bytes     responseMessage       = 3;
-	repeated Parameter additionalParams      = 4;
+    sfixed64 requestId       = 1; // required
+    sfixed64 responseId      = 2; // required
+    bytes    responseMessage = 3;
+
+    map<string, bytes> additionalProps = 4;
 }
@@ -39,4 +42,4 @@ message BroadcastQueryResponse {
 message Parameter {
-	optional string name  = 1; // required
-	optional bytes  value = 2;
+    string name  = 1; // required
+    bytes  value = 2;
 }
diff --git a/build.gradle b/build.gradle
index c692498..1f84691 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,13 +4,15 @@ apply from: 'config/keystore.gradle'
 buildscript {
     repositories {
         jcenter()
     }
 
     dependencies {
         classpath 'com.android.tools.build:gradle:2.3.1'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
         classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
+        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
+        classpath 'com.google.protobuf:protoc-gen-javalite:3.0.0'
     }
 }
@@ -35,6 +37,8 @@ try {
 
-task showVersion << {
-    logger.lifecycle("Version ID: " + project.versionNum)
-    logger.lifecycle("Version Date: " + project.versionDate)
-    logger.lifecycle("Version Name: " + project.versionName)
+task showVersion {
+    doLast {
+        logger.lifecycle("Version ID: " + project.versionNum)
+        logger.lifecycle("Version Date: " + project.versionDate)
+        logger.lifecycle("Version Name: " + project.versionName)
+    }
 }
diff --git a/config/android-common.gradle b/config/android-common.gradle
index 4a3fe96..77c67c7 100644
--- a/config/android-common.gradle
+++ b/config/android-common.gradle
@@ -1,33 +1,38 @@
 android {
     compileSdkVersion rootProject.compileSdkVersion
     buildToolsVersion rootProject.buildToolsVersion
 
     defaultConfig {
         minSdkVersion rootProject.minSdkVersion
         targetSdkVersion rootProject.compileSdkVersion
         versionCode rootProject.versionNum
         versionName rootProject.versionName
     }
 
+    compileOptions {
+        sourceCompatibility = JavaVersion.VERSION_1_7
+        targetCompatibility = JavaVersion.VERSION_1_7
+    }
+
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
         main.java.srcDirs = ['java']
         main.aidl.srcDirs = ['java']
         main.res.srcDir 'res'
         main.assets.srcDir 'assets'
         main.resources.srcDir 'java'
 
         test.setRoot('javatests');
         test.java.srcDir('javatests');
     }
 
     lintOptions {
         warningsAsErrors true
         disable 'InvalidPackage', 'TrulyRandom', 'GradleDependency'
     }
 
     packagingOptions {
         exclude 'META-INF/LICENSE.txt'
         exclude 'META-INF/NOTICE.txt'
     }
 }
diff --git a/config/protobuf.gradle b/config/protobuf.gradle
new file mode 100644
index 0000000..42998ca
--- /dev/null
+++ b/config/protobuf.gradle
@@ -0,0 +1,101 @@
+import java.nio.file.Files
+import java.nio.file.attribute.PosixFilePermission
+
+/**
+ * Adds simple protocol buffer compilation task that compiles protos from a "proto" folder of the
+ * module, into a "java_gen" folder. Code here is inspired by the Google protobuf gradle plugin,
+ * but is simpler and caused less issues with IDE integration and test execution.
+ */
+
+apply plugin: 'com.google.osdetector'
+
+/**
+ * The protocol buffer compiler and javalite plugin are pulled as dynamic dependencies, so that
+ * they do not need to be pre-installed by the developer.
+ */
+Configuration protoDepsConfig = project.configurations.create("protobufDeps") {
+    visible = false
+    transitive = false
+    extendsFrom = []
+}
+
+Dependency protocDep = project.dependencies.add(protoDepsConfig.name, [
+        group: "com.google.protobuf",
+        name: "protoc",
+        version: "3.2.0",
+        classifier: project.osdetector.classifier,
+        ext: 'exe'
+])
+
+Dependency javaliteDep = project.dependencies.add(protoDepsConfig.name, [
+        group: "com.google.protobuf",
+        name: "protoc-gen-javalite",
+        version: "3.0.0",
+        classifier: project.osdetector.classifier,
+        ext: 'exe'
+])
+
+def makeExecutable = { file ->
+    Files.setPosixFilePermissions(
+            file.toPath(),
+            [
+                    PosixFilePermission.OWNER_EXECUTE,
+                    PosixFilePermission.GROUP_EXECUTE
+            ].toSet())
+}
+
+/**
+ * Compiles the protocol buffers in the "proto" folder of the project, into the "java_gen" folder.
+ */
+task compileProtos {
+    doLast {
+        def protocFile = protoDepsConfig.fileCollection(protocDep).singleFile
+        def javaliteFile = protoDepsConfig.fileCollection(javaliteDep).singleFile
+
+        makeExecutable(protocFile)
+        makeExecutable(javaliteFile)
+
+        def protoFiles = fileTree(dir: "${projectDir}/proto").matching { include "**/*.proto"}.sort()
+        logger.lifecycle("proto files: " + protoFiles)
+
+        def outDir = file("${projectDir}/java_gen")
+        if (!outDir.exists()) {
+            outDir.mkdir()
+        }
+
+        def cmd = [ protocFile ]
+        cmd += "--proto_path=${projectDir}/proto"
+        cmd += "--plugin=protoc-gen-javalite=" + javaliteFile.absolutePath
+        cmd += "--javalite_out=${projectDir}/java_gen"
+        cmd.addAll(protoFiles)
+
+        logger.lifecycle("protoc command: " + cmd.toString())
+
+        def stdout = new StringBuffer()
+        def stderr = new StringBuffer()
+        Process compileProcess = cmd.execute()
+        compileProcess.waitForProcessOutput(stdout, stderr)
+
+        if (compileProcess.exitValue() != 0) {
+            def error = "protobuf compilation failed: stdout: ${stdout}. stderr: ${stderr}"
+            throw new GradleException(error)
+        }
+    }
+}
+
+/**
+ * javalite compiled protos require this runtime dependency.
+ */
+dependencies {
+    compile 'com.google.protobuf:protobuf-lite:3.0.1'
+}
+
+/**
+ * Ensure that the generated code is included in the source set of the library / app
+ */
+android.sourceSets.main.java.srcDirs += 'java_gen'
+
+/**
+ * Ensure that protos are compiled before any other compilation steps.
+ */
+preBuild.dependsOn compileProtos
diff --git a/config/wire-proto.gradle b/config/wire-proto.gradle
deleted file mode 100644
index 5aaf81f..0000000
--- a/config/wire-proto.gradle
+++ /dev/null
@@ -1,26 +0,0 @@
-android.sourceSets.main.java.srcDirs += 'java_gen'
-
-configurations {
-    protoCompileDeps
-}
-
-dependencies {
-    compile 'com.squareup.wire:wire-runtime:2.1.2'
-    protoCompileDeps 'com.squareup.wire:wire-compiler:2.1.2'
-}
-
-task protoCompile(type: JavaExec) {
-    main = 'com.squareup.wire.WireCompiler'
-    classpath configurations.protoCompileDeps
-    args = [
-            '--proto_path=' + file('proto').getAbsolutePath(),
-            '--java_out=' + file('java_gen').getAbsolutePath(),
-            '--excludes=google.protobuf.*'
-    ]
-}
-
-preBuild.dependsOn protoCompile
-
-clean {
-    delete 'java_gen'
-}
diff --git a/demoproviders/barbican/build.gradle b/demoproviders/barbican/build.gradle
index 59270b5..b658c07 100644
--- a/demoproviders/barbican/build.gradle
+++ b/demoproviders/barbican/build.gradle
@@ -5,16 +5,16 @@ apply plugin: 'com.neenbedankt.android-apt'
 apply from: "${rootDir}/config/android-common.gradle"
-apply from: "${rootDir}/config/wire-proto.gradle"
+apply from: "${rootDir}/config/protobuf.gradle"
 
 android {
     defaultConfig {
         applicationId 'org.openyolo.demoprovider.barbican'
         project.archivesBaseName = 'openyolo-demoprovider-barbican'
         vectorDrawables.useSupportLibrary = true
     }
     buildTypes {
         release {
             minifyEnabled true
-            proguardFiles getDefaultProguardFile('proguard-android.txt')
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
         }
     }
 }
@@ -22,16 +22,18 @@ android {
 dependencies {
     compile project(':spi')
     compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
     compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
     compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     compile "com.android.support:design:${rootProject.supportLibVersion}"
     compile "com.android.support:recyclerview-v7:${rootProject.supportLibVersion}"
     compile 'com.madgag.spongycastle:core:1.54.0.0'
+    compile 'com.google.guava:guava:20.0'
 
     compile 'com.jakewharton:butterknife:8.5.1'
     compile 'com.github.bumptech.glide:glide:3.7.0'
     apt 'com.jakewharton:butterknife-compiler:8.5.1'
 
     apply from: "${rootDir}/config/testdeps.gradle", to:it
     testCompile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    testCompile 'com.google.guava:guava:20.0'
 }
diff --git a/demoproviders/barbican/java/okio/BlockCipherSink.java b/demoproviders/barbican/java/okio/BlockCipherSink.java
deleted file mode 100644
index d977c27..0000000
--- a/demoproviders/barbican/java/okio/BlockCipherSink.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package okio;
-
-import java.io.IOException;
-import org.spongycastle.crypto.BlockCipher;
-import org.spongycastle.crypto.paddings.BlockCipherPadding;
-
-/**
- * A {@link Sink} which encrypts data using a block cipher.
- */
-public class BlockCipherSink extends ForwardingSink {
-
-    private final BlockCipher mCipher;
-    private final BlockCipherPadding mPadding;
-    private final int mBlockSize;
-    private byte[] mInBlock;
-    private byte[] mLastBlock;
-    private Buffer mOutBuffer;
-    private int mInBlockOffset;
-
-    /**
-     * Creates a sink which will encrypt written data using the provided block cipher to
-     * the provided output sink, and will pad the end of the data using the provided padding mode.
-     */
-    public BlockCipherSink(BlockCipher cipher, BlockCipherPadding padding, Sink out) {
-        super(out);
-        mCipher = cipher;
-        mPadding = padding;
-        mBlockSize = mCipher.getBlockSize();
-        mInBlock = new byte[mBlockSize];
-        mLastBlock = new byte[mBlockSize];
-        mOutBuffer = new Buffer();
-        mInBlockOffset = 0;
-    }
-
-    @Override
-    public void write(Buffer source, long byteCount) throws IOException {
-        Util.checkOffsetAndCount(source.size, 0, byteCount);
-        while (byteCount > 0) {
-            int readCount = (int)Math.min(byteCount, mInBlock.length - mInBlockOffset);
-            byteCount -= readCount;
-            source.read(mInBlock, mInBlockOffset, readCount);
-            mInBlockOffset += readCount;
-
-            if (mInBlockOffset == mInBlock.length) {
-                processBlock();
-            }
-        }
-    }
-
-    @Override
-    public void close() throws IOException {
-        mPadding.addPadding(mInBlock, mInBlockOffset);
-        processBlock();
-        delegate().close();
-    }
-
-    private void processBlock() throws IOException {
-        mCipher.processBlock(mInBlock, 0, mLastBlock, 0);
-        mOutBuffer.write(mLastBlock);
-        delegate().write(mOutBuffer, mBlockSize);
-        mInBlockOffset = 0;
-    }
-}
diff --git a/demoproviders/barbican/java/okio/BlockCipherSource.java b/demoproviders/barbican/java/okio/BlockCipherSource.java
deleted file mode 100644
index daaae18..0000000
--- a/demoproviders/barbican/java/okio/BlockCipherSource.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package okio;
-
-import java.io.IOException;
-import org.spongycastle.crypto.BlockCipher;
-import org.spongycastle.crypto.InvalidCipherTextException;
-import org.spongycastle.crypto.paddings.BlockCipherPadding;
-
-/**
- * A {@link Source} which decrypts data using a block cipher.
- */
-public class BlockCipherSource extends ForwardingSource {
-
-    private final BlockCipher mCipher;
-    private final BlockCipherPadding mPadding;
-    private final int mBlockSize;
-
-    private final Buffer mInBuffer;
-    private final byte[] mInBlock;
-    private final byte[] mOutBlock;
-    private int mOutBlockOffset;
-    private int mOutBlockEnd;
-
-    /**
-     * Creates a source which will decrypt data from the provided input source, using the
-     * provided block cipher and padding mode.
-     */
-    public BlockCipherSource(BlockCipher cipher, BlockCipherPadding padding, Source in) {
-        super(in);
-        mCipher = cipher;
-        mPadding = padding;
-        mBlockSize = cipher.getBlockSize();
-        mInBuffer = new Buffer();
-        mInBlock = new byte[mBlockSize];
-        mOutBlock = new byte[mBlockSize];
-        mOutBlockOffset = mOutBlock.length;
-        mOutBlockEnd = mOutBlock.length;
-    }
-
-    @Override
-    public long read(Buffer sink, long byteCount) throws IOException {
-        int totalReadCount = 0;
-        while (byteCount > 0) {
-            int available = mOutBlockEnd - mOutBlockOffset;
-            if (available > 0) {
-                int readCount = (int)Math.min(byteCount, available);
-                sink.write(mOutBlock, mOutBlockOffset, readCount);
-                mOutBlockOffset += readCount;
-                available -= readCount;
-                byteCount -= readCount;
-                totalReadCount += readCount;
-            }
-
-            if (available == 0 && byteCount > 0) {
-                if (!decryptBlock()) {
-                    if (totalReadCount == 0) {
-                        return -1;
-                    }
-                    return totalReadCount;
-                }
-            }
-        }
-
-        return totalReadCount;
-    }
-
-    private boolean decryptBlock() throws IOException {
-        if (mInBuffer.exhausted()) {
-            if (!readNextBlock()) {
-                return false;
-            }
-        }
-
-        mInBuffer.read(mInBlock);
-        mCipher.processBlock(mInBlock, 0, mOutBlock, 0);
-
-        mOutBlockOffset = 0;
-        if (!readNextBlock()) {
-            // reached the last block, check for padding
-            try {
-                mOutBlockEnd = mOutBlock.length - mPadding.padCount(mOutBlock);
-            } catch (InvalidCipherTextException ex) {
-                throw new IOException("Corrupted data stream", ex);
-            }
-        } else {
-            mOutBlockEnd = mOutBlock.length;
-        }
-
-        return true;
-    }
-
-    private boolean readNextBlock() throws IOException {
-        long readCount = delegate().read(mInBuffer, mBlockSize);
-        if (readCount == -1) {
-            return false;
-        }
-
-        if (readCount < mBlockSize) {
-            throw new IOException("Corrupted data stream: depleted inside block boundary");
-        }
-
-        return true;
-    }
-}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
index 0c0c61a..33f8c2c 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
@@ -45,259 +45,259 @@ import java.util.ArrayList;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * Creates credentials from manual user input for storage.
  */
 public class CreateCredentialActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "CreateCredential";
 
     private static final int MIN_ID_LENGTH = 1;
     private static final int MIN_PASS_LENGTH = 1;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.headerToolbar)
     Toolbar mToolbar;
 
     @BindView(R.id.appBar)
     AppBarLayout mAppBar;
 
     @BindView(R.id.credential_authority)
     Spinner mCredentialAuthority;
 
     @BindView(R.id.credential_id)
     EditText mCredentialId;
 
     @BindView(R.id.credential_password)
     EditText mCredentialPassword;
 
     private MenuItem mDoneButton;
 
     private CredentialStorageClient mStorageClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.create_credential_layout);
         ButterKnife.bind(this);
         getSupportActionBar();
         setSupportActionBar(mToolbar);
         mToolbar.setNavigationIcon(R.drawable.back);
         mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 finish();
             }
         });
         mCredentialAuthority.setAdapter(new AppAdapter(getInstalledApps()));
     }
 
     @Override
     protected void onStart() {
         super.onStart();
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mStorageClient = client;
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mStorageClient.disconnect(this);
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.menu_create, menu);
         mDoneButton = menu.findItem(R.id.action_done);
         onFieldsChanged();
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (super.onOptionsItemSelected(item)) {
             return true;
         }
 
         if (R.id.action_done == item.getItemId()) {
             App app = (App) mCredentialAuthority.getSelectedItem();
             String username = mCredentialId.getText().toString();
             String password = mCredentialPassword.getText().toString();
             new StoreCredentialTask(app.mPackageName, username, password).execute();
         }
 
         return false;
     }
 
     @OnItemSelected(R.id.credential_authority)
     @OnTextChanged({R.id.credential_id, R.id.credential_password})
     void onFieldsChanged() {
         boolean validCredential =
                 mCredentialAuthority.getSelectedItemPosition() != Spinner.INVALID_POSITION
                 && mCredentialId.length() >= MIN_ID_LENGTH
                 && mCredentialPassword.length() >= MIN_PASS_LENGTH;
 
         if (mDoneButton != null) {
             mDoneButton.setEnabled(validCredential);
         }
     }
 
     private List<App> getInstalledApps() {
         List<String> appPackageNames = InstalledAppsUtil.getInstalledAppsList(this);
         ArrayList<App> apps = new ArrayList<>();
         PackageManager pm = getPackageManager();
         for (String packageName : appPackageNames) {
             try {
                 ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                 String appName = pm.getApplicationLabel(info).toString();
                 Drawable appIcon = pm.getApplicationIcon(info);
                 apps.add(new App(packageName, appName, appIcon));
             } catch (PackageManager.NameNotFoundException e) {
                 // skip this app
             }
         }
 
         return apps;
     }
 
     private class StoreCredentialTask extends AsyncTask<Void, Void, Boolean> {
 
         final String mPackageName;
         final String mUsername;
         final String mPassword;
 
         StoreCredentialTask(String packageName, String username, String password) {
             mPackageName = packageName;
             mUsername = username;
             mPassword = password;
         }
 
         @Override
         protected Boolean doInBackground(Void... params) {
             AuthenticationDomain domain = AuthenticationDomain.listForPackage(
                     CreateCredentialActivity.this,
                     mPackageName)
                     .get(0);
 
-            Credential credential = new Credential.Builder()
-                    .id(mUsername)
-                    .authDomain(domain.toString())
-                    .authMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
-                    .password(mPassword)
+            Credential credential = Credential.newBuilder()
+                    .setId(mUsername)
+                    .setAuthDomain(domain.toString())
+                    .setAuthMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
+                    .setPassword(mPassword)
                     .build();
             try {
                 mStorageClient.upsertCredential(credential);
                 return true;
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to upsert credential to database");
             }
             return null;
         }
 
         @Override
         protected void onPostExecute(Boolean success) {
             if (success) {
                 finish();
             } else {
                 Snackbar.make(
                         mRootView,
                         R.string.save_failed,
                         Snackbar.LENGTH_SHORT).show();
             }
         }
     }
 
     private class App implements Comparable<App> {
         @NonNull String mName;
         @NonNull String mPackageName;
         @Nullable Drawable mIcon;
 
         App(@NonNull String packageName, @NonNull String name, @Nullable Drawable icon) {
             mPackageName = packageName;
             mName = name;
             mIcon = icon;
         }
 
         @Override
         public int compareTo(@NonNull App app) {
             return mName.compareTo(app.mName);
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (!(obj instanceof App)) {
                 return false;
             }
 
             App other = (App) obj;
             return mPackageName.equals(other.mPackageName);
         }
 
         @Override
         public int hashCode() {
             return mPackageName.hashCode();
         }
     }
 
     private class AppAdapter extends BaseAdapter {
 
         private final List<App> mApps;
         private final LayoutInflater mInflater;
 
         AppAdapter(@NonNull List<App> apps) {
             mApps = apps;
             mInflater = LayoutInflater.from(CreateCredentialActivity.this);
         }
 
         @Override
         public int getCount() {
             return mApps.size();
         }
 
         @Override
         public Object getItem(int index) {
             return mApps.get(index);
         }
 
         @Override
         public long getItemId(int index) {
             return mApps.get(index).hashCode();
         }
 
         @Override
         public View getView(int index, View view, ViewGroup viewGroup) {
             App app = mApps.get(index);
             if (view == null) {
                 view = mInflater.inflate(R.layout.app_item, viewGroup, false);
             }
 
             ImageView iconView = (ImageView) view.findViewById(R.id.app_icon);
             if (app.mIcon != null) {
                 iconView.setImageDrawable(app.mIcon);
                 iconView.setVisibility(View.VISIBLE);
             } else {
                 iconView.setVisibility(View.INVISIBLE);
             }
 
             TextView nameView = (TextView) view.findViewById(R.id.app_name);
             nameView.setText(app.mName);
 
             return view;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
index 964d670..8568ae3 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
@@ -30,115 +30,115 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * RecyclerView adapter for displaying stored credentials.
  */
 class CredentialAdapter
         extends RecyclerView.Adapter<CredentialAdapter.ViewHolder> {
 
     private List<Credential> mCredentials;
     private CredentialStorageClient mClient;
 
     CredentialAdapter() {
         mCredentials = Collections.emptyList();
     }
 
     void setCredentials(List<Credential> credentials) {
         mCredentials = credentials;
         notifyDataSetChanged();
     }
 
     @Override
     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
         View credentialView = LayoutInflater.from(parent.getContext())
                 .inflate(R.layout.credential_view, parent, false);
 
         return new ViewHolder(credentialView);
     }
 
     @Override
     public void onBindViewHolder(ViewHolder holder, int position) {
         holder.bind(mCredentials.get(position));
     }
 
     @Override
     public int getItemCount() {
         return mCredentials.size();
     }
 
     void setCredentialStorageClient(CredentialStorageClient credentialStorageClient) {
         mClient = credentialStorageClient;
     }
 
     final class ViewHolder extends RecyclerView.ViewHolder {
 
         private TextView mAuthorityView;
         private ImageView mAuthorityIconView;
         private TextView mIdView;
 
         ViewHolder(View itemView) {
             super(itemView);
 
             mAuthorityView = (TextView) itemView.findViewById(R.id.credential_authority);
             mAuthorityIconView = (ImageView) itemView.findViewById(R.id.credential_authority_icon);
             mIdView = (TextView) itemView.findViewById(R.id.credential_id);
         }
 
         void bind(final Credential credential) {
-            String appLabel = credential.authDomain;
+            String appLabel = credential.getAuthDomain();
             Drawable appIcon = null;
 
-            AuthenticationDomain domain = new AuthenticationDomain(credential.authDomain);
+            AuthenticationDomain domain = new AuthenticationDomain(credential.getAuthDomain());
             if (domain.isAndroidAuthDomain()) {
                 String packageName = domain.getAndroidPackageName();
                 PackageManager pm = itemView.getContext().getPackageManager();
                 try {
                     ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                     appLabel = pm.getApplicationLabel(info).toString();
                     appIcon = pm.getApplicationIcon(info);
                 } catch (PackageManager.NameNotFoundException e) {
                     // will just show the raw info
                 }
             }
 
             mAuthorityView.setText(appLabel);
-            mIdView.setText(credential.id);
+            mIdView.setText(credential.getId());
 
             if (appIcon != null) {
                 mAuthorityIconView.setImageDrawable(appIcon);
                 mAuthorityIconView.setVisibility(View.VISIBLE);
             } else {
                 mAuthorityIconView.setVisibility(View.INVISIBLE);
             }
 
             itemView.setOnLongClickListener(new View.OnLongClickListener() {
                 @Override
                 public boolean onLongClick(View view) {
                     AlertDialog dialog = new AlertDialog.Builder(itemView.getContext())
                             .setTitle(R.string.ask_delete_credential)
                             .setPositiveButton(R.string.openyolo_simple_yes,
                                     new DialogInterface.OnClickListener() {
                                         @Override
                                         public void onClick(DialogInterface dialogInterface,
                                                             int which) {
                                             try {
                                                 mClient.deleteCredential(credential);
                                                 mCredentials.remove(credential);
                                                 notifyDataSetChanged();
                                             } catch (IOException e) {
                                                 e.printStackTrace();
                                             }
                                         }
                                     })
                             .setNegativeButton(R.string.openyolo_simple_no, null)
                             .create();
 
                     dialog.show();
                     return true;
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
index b105746..c337c77 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
@@ -22,87 +22,87 @@ import java.util.Collection;
 import java.util.regex.Pattern;
-import org.openyolo.api.IdentifierTypes;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.IdentifierTypes;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * Heuristically identifies the "type" of a password credential based on the ID value.
  */
 public final class CredentialClassifier {
 
     private static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9]+");
 
     /**
      * Determines whether the credential identifier is an email address.
      */
     public static boolean isEmailCredential(Credential credential) {
-        return isEmailIdentifier(credential.id);
+        return isEmailIdentifier(credential.getId());
     }
 
     /**
      * Determines whether the provided identifier is an email address.
      */
     public static boolean isEmailIdentifier(String identifier) {
         return Patterns.EMAIL_ADDRESS.matcher(identifier).matches();
     }
 
     /**
      * Determines whether the credential identifier is a phone number.
      */
     public static boolean isPhoneCredential(Credential credential) {
-        return isPhoneIdentifier(credential.id);
+        return isPhoneIdentifier(credential.getId());
     }
 
     /**
      * Determines whether the provided identifier is a phone number.
      */
     public static boolean isPhoneIdentifier(String identifier) {
         return Patterns.PHONE.matcher(identifier).matches();
     }
 
     /**
      * Determines whether the provided identifier contains alphanumeric characters only.
      */
     public static boolean isAlphanumericIdentifier(String identifier) {
         return ALPHANUMERIC_PATTERN.matcher(identifier).matches();
     }
 
     /**
      * Determines whether the provided identifier matches any of the provided types.
      *
      * @see {@link IdentifierTypes}
      */
     public static boolean identifierMatchesOneOf(
             @NonNull String identifier,
             @NonNull Collection<Uri> identifierTypes) {
         for (Uri identifierType : identifierTypes) {
             if (IdentifierTypes.EMAIL.equals(identifierType) && isEmailIdentifier(identifier)) {
                 return true;
             }
 
             if (IdentifierTypes.PHONE.equals(identifierType) && isPhoneIdentifier(identifier)) {
                 return true;
             }
 
             if (IdentifierTypes.ALPHANUMERIC.equals(identifierType)
                     && isAlphanumericIdentifier(identifier)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Returns a drawable resource which can be used as a default profile picture for a
      * credential.
      */
     @DrawableRes
     public static int getDefaultIconForCredential(Credential credential) {
         if (isEmailCredential(credential)) {
             return R.drawable.email;
         } else if (isPhoneCredential(credential)) {
             return R.drawable.phone;
         }
 
         return R.drawable.person;
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
index da57775..cfdfa89 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
@@ -34,6 +34,6 @@ import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient.ConnectedCallback;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * Displays the user's stored credentials.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
index 1c74ad3..8c05be0 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
@@ -19,84 +19,88 @@ import android.text.TextUtils;
 import java.util.Comparator;
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.demoprovider.barbican.proto.AccountHint;
-import org.openyolo.proto.Credential;
+import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * Derives quality scores for credentials and hints that can help to order lists of them based on
  * how useful they are to an application.
  */
 public class CredentialQualityScore {
 
     /**
      * A comparator which orders credentials in descending order of quality score, i.e. those with
      * the highest quality score first.
      */
     public static final Comparator<Credential> QUALITY_SORT = new CredentialQualityComparator();
 
     /**
      * Generates the score for the user data in an account hint.
      */
     public static int getScore(AccountHint hint) {
-        return getQualityScore(hint.identifier, hint.authMethod, hint.name, hint.pictureUri);
+        return getQualityScore(
+            hint.getIdentifier(),
+            hint.getAuthMethod(),
+            hint.getName(),
+            hint.getPictureUri());
     }
 
     /**
      * Generates the score for the user data in a credential.
      */
     public static int getScore(Credential credential) {
         return getQualityScore(
-                credential.id,
-                credential.authMethod,
-                credential.displayName,
-                credential.displayPictureUri);
+                credential.getId(),
+                credential.getAuthMethod(),
+                credential.getDisplayName(),
+                credential.getDisplayPictureUri());
     }
 
     private static int getQualityScore(
             @Nullable String id,
             @Nullable String authMethod,
             @Nullable String name,
             @Nullable String pictureUri) {
 
         int score = 1;
 
         // email identifiers are recognisable and useful for ID token acquisition
         if (CredentialClassifier.isEmailIdentifier(id)) {
             score <<= 1;
         }
 
         // prefer credentials that don't use passwords
         if (!AuthenticationMethods.ID_AND_PASSWORD.equals(authMethod)) {
             score <<= 1;
         }
 
         // prefer credentials that have a human readable name
         if (!TextUtils.isEmpty(name)) {
             score <<= 1;
         }
 
         // prefer credentials that have a profile picture
         if (!TextUtils.isEmpty(pictureUri)) {
             score <<= 1;
         }
 
         return score;
     }
 
     private static final class CredentialQualityComparator implements Comparator<Credential> {
 
         @Override
         public int compare(Credential c1, Credential c2) {
             int c1Score = getScore(c1);
             int c2Score = getScore(c2);
 
             // higher scores (more information) come first
             if (c1Score > c2Score) {
                 return -1;
             } else if (c1Score == c2Score) {
                 return 0;
             }
 
             return 1;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java
index 88adefc..02012a7 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java
@@ -35,9 +35,9 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.protocol.AuthenticationDomain;
 
 
 /**
  * RecyclerView adapter for displaying the API implementers for which Barbican picked "never save"
  * when attempting to store a credential.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
index 99e7503..38e201e 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
@@ -29,3 +29,3 @@ import java.io.IOException;
 import org.openyolo.demoprovider.barbican.R;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.Protobufs.Credential;
 import org.openyolo.spi.RetrieveIntentResultUtil;
@@ -33,88 +33,88 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Displays a brief, "snackbar"-like notification to the user indicating that a credential
  * is being returned to a requesting app.
  */
 public class AutoSignInActivity extends AppCompatActivity {
 
     private static final long DISPLAY_TIME_MS = 2000;
 
     private static final String EXTRA_CREDENTIAL = "credential";
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.credential_primary)
     TextView mCredentialPrimary;
 
     @BindView(R.id.credential_secondary)
     TextView mCredentialSecondary;
 
     /**
      * Creates an intent to display this activity with the specified credential.
      */
     public static Intent createIntent(Context context, Credential credential) {
         Intent intent = new Intent(context, AutoSignInActivity.class);
-        intent.putExtra(EXTRA_CREDENTIAL, credential.encode());
+        intent.putExtra(EXTRA_CREDENTIAL, credential.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.auto_sign_in_layout);
         positionWindow();
         ButterKnife.bind(this);
 
         Credential credential = getCredential();
-        if (credential.displayName != null) {
-            mCredentialPrimary.setText(credential.displayName);
-            mCredentialSecondary.setText(credential.id);
+        if (credential.getDisplayName() != null) {
+            mCredentialPrimary.setText(credential.getDisplayName());
+            mCredentialSecondary.setText(credential.getId());
         } else {
-            mCredentialPrimary.setText(credential.id);
+            mCredentialPrimary.setText(credential.getId());
             mCredentialSecondary.setVisibility(View.GONE);
         }
 
         mRootView.postDelayed(new ReturnCredentialTask(), DISPLAY_TIME_MS);
     }
 
     /**
      * Ensures the activity's window fills the full "visible" section of the screen, excluding
      * the status bar. This is a workaround for a size bug when using
      * {@code windowMinWidthMajor / windowMinWidthMinor} that can leave the windows a few pixels
      * off the correct size.
      */
     private void positionWindow() {
         Rect rectangle = new Rect();
         Window window = getWindow();
         window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
 
         int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
         int statusBarHeight = 0;
         if (resourceId > 0) {
             statusBarHeight = getResources().getDimensionPixelSize(resourceId);
         }
 
         getWindow().setLayout(
                 rectangle.width(),
                 rectangle.height() - statusBarHeight);
     }
 
 
     private Credential getCredential() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
-            return Credential.ADAPTER.decode(credentialBytes);
+            return Credential.parseFrom(credentialBytes);
         } catch (IOException e) {
             throw new IllegalStateException("Unable to decode credential");
         }
     }
 
     private class ReturnCredentialTask implements Runnable {
         @Override
         public void run() {
             Intent responseData = RetrieveIntentResultUtil.createResponseData(getCredential());
             setResult(RESULT_OK, responseData);
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index ed4b522..2308bf4 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -41,4 +41,4 @@ import org.openyolo.demoprovider.barbican.CredentialQualityScore;
 import org.openyolo.demoprovider.barbican.R;
-import org.openyolo.proto.Credential;
-import org.openyolo.proto.CredentialList;
+import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.Protobufs.CredentialList;
 import org.openyolo.spi.RetrieveIntentResultUtil;
@@ -46,134 +46,138 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(Context context, List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
-        intent.putExtra(EXTRA_CREDENTIALS, new CredentialList(credentials).encode());
+        intent.putExtra(EXTRA_CREDENTIALS,
+                CredentialList.newBuilder()
+                        .addAllCredentials(credentials)
+                        .build()
+                        .toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
         setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResult(RESULT_CANCELED);
             finish();
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Credential> credentials =
-                    new ArrayList<>(CredentialList.ADAPTER.decode(credentialBytes).credentials);
+                    new ArrayList<>(CredentialList.parseFrom(credentialBytes).getCredentialsList());
             Collections.sort(credentials, CredentialQualityScore.QUALITY_SORT);
             return credentials;
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new CredentialViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(CredentialViewHolder holder, int position) {
             holder.bind(mCredentials.get(position));
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
     }
 
     private final class CredentialViewHolder extends RecyclerView.ViewHolder {
 
         private ImageView mProfileIcon;
         private TextView mPrimaryLabel;
         private TextView mSecondaryLabel;
 
         CredentialViewHolder(View itemView) {
             super(itemView);
 
             mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
             mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
             mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
         }
 
         void bind(final Credential credential) {
 
             int iconId = CredentialClassifier.getDefaultIconForCredential(credential);
 
-            if (credential.displayPictureUri != null) {
-                Uri displayPictureUri = Uri.parse(credential.displayPictureUri);
+            if (credential.getDisplayPictureUri() != null) {
+                Uri displayPictureUri = Uri.parse(credential.getDisplayPictureUri());
                 Glide.with(CredentialPickerActivity.this)
                         .load(displayPictureUri)
                         .fitCenter()
                         .fallback(iconId)
                         .into(mProfileIcon);
             } else {
                 mProfileIcon.setImageResource(iconId);
             }
 
-            if (credential.displayName != null) {
-                mPrimaryLabel.setText(credential.displayName);
-                mSecondaryLabel.setText(credential.id);
+            if (credential.getDisplayName() != null) {
+                mPrimaryLabel.setText(credential.getDisplayName());
+                mSecondaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.VISIBLE);
             } else {
-                mPrimaryLabel.setText(credential.id);
+                mPrimaryLabel.setText(credential.getId());
                 mSecondaryLabel.setVisibility(View.GONE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     Intent responseData =
                             RetrieveIntentResultUtil.createResponseData(credential);
                     setResult(RESULT_OK, responseData);
                     finish();
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
index 0a8ded8..ef9db2c 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
@@ -20,4 +20,5 @@ import android.support.annotation.NonNull;
 import android.util.Log;
+import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import com.google.bbq.proto.BroadcastQuery;
+import com.google.protobuf.ByteString;
 import java.io.IOException;
@@ -25,8 +26,7 @@ import java.util.Iterator;
 import java.util.Set;
-import okio.ByteString;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.RetrieveRequest;
-import org.openyolo.api.internal.IntentUtil;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorage;
-import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveResponse;
+import org.openyolo.protocol.RetrieveRequest;
+import org.openyolo.protocol.internal.IntentUtil;
 import org.openyolo.spi.BaseCredentialQueryReceiver;
@@ -34,63 +34,65 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Implements the OpenYOLO credential query receiver. This receiver is able to determine whether
  * a credential exists for the claimed set of authentication domains without unlocking the
  * password store.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull final Context context,
             @NonNull final BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // NOTE: in a more complete implementation, this is where we would expand the set of
         // authentication domains listed in requestorDomains to all equivalent authentication
         // domains (such as affiliated apps and sites). This potentially larger list would then be
         // matched against the requested set of domains.
 
-        Log.i(LOG_TAG, "Processing query for " + query.requestingApp);
+        Log.i(LOG_TAG, "Processing query for " + query.getRequestingApp());
 
         CredentialStorage storage;
         try {
             storage = new CredentialStorage(context);
         }  catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to open credential storage", ex);
             responseSender.sendResponse(query, null);
             return;
         }
 
         boolean credentialsFound = false;
         byte[] responseBytes = null;
 
         Iterator<AuthenticationDomain> authDomainIter = requestorDomains.iterator();
         while (!credentialsFound && authDomainIter.hasNext()) {
             credentialsFound = storage.hasCredentialFor(authDomainIter.next().toString());
         }
 
-        Log.d(LOG_TAG, "Credentials found for " + query.requestingApp + ": " + credentialsFound);
+        Log.d(LOG_TAG, "Credentials found for "
+                + query.getRequestingApp() + ": "
+                + credentialsFound);
 
         if (credentialsFound) {
             Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context);
-            CredentialRetrieveResponse response = new CredentialRetrieveResponse.Builder()
-                    .retrieveIntent(ByteString.of(IntentUtil.toBytes(retrieveIntent)))
+            CredentialRetrieveResponse response = CredentialRetrieveResponse.newBuilder()
+                    .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
                     .build();
-            responseBytes = response.encode();
+            responseBytes = response.toByteArray();
         }
 
         responseSender.sendResponse(query, responseBytes);
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
index f1ce507..2c36f5b 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
@@ -28,156 +28,156 @@ import java.util.List;
 import java.util.Set;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.api.CredentialClient;
-import org.openyolo.api.HintRequest;
 import org.openyolo.demoprovider.barbican.CredentialClassifier;
-import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.ProtocolConstants;
 
 public class HintActivity
         extends AppCompatActivity
         implements CredentialStorageClient.ConnectedCallback {
 
     private static final String LOG_TAG = "HintActivity";
 
     private HintRequest mRequest;
     private AuthenticationDomain mCallerAuthDomain;
     private CredentialStorageClient mClient;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        if (!getIntent().hasExtra(CredentialClient.EXTRA_HINT_REQUEST)) {
+        if (!getIntent().hasExtra(ProtocolConstants.EXTRA_HINT_REQUEST)) {
             Log.w(LOG_TAG, "No hint request object found in the intent");
             finish(RESULT_CANCELED);
             return;
         }
 
         try {
             mRequest = HintRequest.fromProtoBytes(
-                    getIntent().getByteArrayExtra(CredentialClient.EXTRA_HINT_REQUEST));
+                    getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_HINT_REQUEST));
         } catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
             finish(RESULT_CANCELED);
             return;
         }
 
         if (!extractCallerAuthDomain()) {
             Log.w(LOG_TAG, "Unable to identify calling app");
             finish(RESULT_CANCELED);
             return;
         }
 
         CredentialStorageClient.connect(this, this);
     }
 
     @Override
     public void onStorageConnected(CredentialStorageClient client) {
         mClient = client;
 
         if (!mClient.isCreated()) {
             Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
             finish(RESULT_CANCELED);
             return;
         }
 
         // some credential provider implementations may require an unlock to retrieve the
         // information required for hints, but for Barbican we instead choose to store basic
         // profile information usable for hints in plain text. With root access, this information
         // would be retrievable by malicious applications on the device, representing a privacy
         // risk. However, full credentials and associations between account identifiers
         // remain encrypted.
 
         List<AccountHint> hints;
         try {
             hints = mClient.getHints();
         } catch (IOException ex) {
             Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
             finish(RESULT_CANCELED);
             return;
         }
 
         // filter the credentials to just those which are pertinent to the request. For those
         // selected, turn them into credentials. Order the hints by the amount of information
         // they contain (so more complete items are displayed first), and then alphabetically.
         ArrayList<Credential> filteredHints = new ArrayList<>();
         for (AccountHint hint : hints) {
             Set<Uri> authMethods = mRequest.getAuthenticationMethods();
-            if (!authMethods.contains(Uri.parse(hint.authMethod))) {
+            if (!authMethods.contains(Uri.parse(hint.getAuthMethod()))) {
                 continue;
             }
 
             Set<Uri> identifierTypes = mRequest.getIdentifierTypes();
             if (!identifierTypes.isEmpty()
                     && !CredentialClassifier.identifierMatchesOneOf(
-                            hint.identifier,
+                            hint.getIdentifier(),
                             identifierTypes)) {
                 continue;
             }
 
-            Credential.Builder hintCredentialBuilder = new Credential.Builder()
-                    .id(hint.identifier)
-                    .authMethod(hint.authMethod)
-                    .authDomain(mCallerAuthDomain.toString())
-                    .displayName(hint.name)
-                    .displayPictureUri(hint.pictureUri);
+            Credential.Builder hintCredentialBuilder = Credential.newBuilder()
+                    .setId(hint.getIdentifier())
+                    .setAuthMethod(hint.getAuthMethod())
+                    .setAuthDomain(mCallerAuthDomain.toString())
+                    .setDisplayName(hint.getName())
+                    .setDisplayPictureUri(hint.getPictureUri());
 
             // include a generated password if appropriate
-            if (hint.authMethod.equals(AuthenticationMethods.ID_AND_PASSWORD.toString())) {
-                hintCredentialBuilder.password(mRequest.getPasswordSpecification().generate());
+            if (hint.getAuthMethod().equals(AuthenticationMethods.ID_AND_PASSWORD.toString())) {
+                hintCredentialBuilder.setPassword(mRequest.getPasswordSpecification().generate());
             }
 
             filteredHints.add(hintCredentialBuilder.build());
         }
 
         // if there are no hints, immediately end the request
         if (filteredHints.isEmpty()) {
             finish(RESULT_CANCELED);
             return;
         }
 
         // otherwise, display the standard credential picker.
         Intent pickerIntent = CredentialPickerActivity.createIntent(
                 this,
                 filteredHints);
         pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(pickerIntent);
         finish();
     }
 
     @Override
     protected void onStop() {
         super.onStop();
         mClient.disconnect(this);
     }
 
     private boolean extractCallerAuthDomain() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         String callingPackage = callingActivity.getPackageName();
         List<AuthenticationDomain> authDomains =
                 AuthenticationDomain.listForPackage(this, callingPackage);
 
         if (authDomains.isEmpty()) {
             return false;
         }
 
         mCallerAuthDomain = authDomains.get(0);
         return true;
     }
 
     @UiThread
     private void finish(int resultCode) {
         setResult(resultCode);
         finish();
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
index 2b7618b..6f100c1 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -24,12 +24,12 @@ import java.io.IOException;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
 import org.openyolo.demoprovider.barbican.UnlockActivity;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * A UI-less activity that determines how to retrieve a requested credential. If the credential
  * store is locked, an unlock activity is started before proceeding. If the store is unlocked
  * and a single credential exists for the request, an auto sign-in activity is displayed.
  * If more than one credential exists, a picker is displayed.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
index 088567d..965ba95 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
@@ -24,66 +24,65 @@ import java.io.IOException;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.Protobufs.Credential;
 
 
 /**
  * Writes a credential to the credential store after it is unlocked.
  */
 public class SaveAfterUnlockActivity extends AppCompatActivity {
 
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final String LOG_TAG = "SaveAfterUnlock";
 
     private Credential mCredential;
 
     /**
      * Creates an intent to save the provided credential after the store is unlocked.
      */
     public static Intent createIntent(Context context, Credential credentialProto) {
         Intent intent = new Intent(context, SaveAfterUnlockActivity.class);
-        intent.putExtra(EXTRA_CREDENTIAL, credentialProto.encode());
+        intent.putExtra(EXTRA_CREDENTIAL, credentialProto.toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
         try {
-            mCredential =
-                    org.openyolo.proto.Credential.ADAPTER.decode(credentialBytes);
+            mCredential = Credential.parseFrom(credentialBytes);
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to decode credential to save");
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 final boolean success;
                 try {
                     client.upsertCredential(mCredential);
                     runOnUiThread(new SendResultRunnable(RESULT_OK));
                 } catch (IOException e) {
                     Log.w(LOG_TAG, "Failed to store credential after save", e);
                     runOnUiThread(new SendResultRunnable(RESULT_CANCELED));
                 }
 
                 client.disconnect(SaveAfterUnlockActivity.this);
             }
         });
     }
 
     private class SendResultRunnable implements Runnable {
         private int mResultCode;
 
         SendResultRunnable(int resultCode) {
             mResultCode = resultCode;
         }
 
         @Override
         public void run() {
             setResult(mResultCode);
             finish();
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
index 25f39d3..e687872 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -25,116 +25,116 @@ import java.io.IOException;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.Credential;
-import org.openyolo.api.CredentialClient;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.ProtocolConstants;
 
 /**
  * Verifies the rights to save a credential, before proceeding to
  * {@link SaveCredentialConfirmationActivity}.
  */
 public class SaveCredentialActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
 
     private Credential mCredential;
     private String mCallingPackage;
     private List<AuthenticationDomain> mAuthDomainsForApp;
     private CredentialStorageClient mClient;
 
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        if (!getIntent().hasExtra(CredentialClient.EXTRA_CREDENTIAL)) {
+        if (!getIntent().hasExtra(ProtocolConstants.EXTRA_CREDENTIAL)) {
             Log.w(LOG_TAG, "No credential included in request");
             finish(RESULT_CANCELED);
             return;
         }
 
         try {
             mCredential = Credential.fromProtoBytes(
-                    getIntent().getByteArrayExtra(CredentialClient.EXTRA_CREDENTIAL));
+                    getIntent().getByteArrayExtra(ProtocolConstants.EXTRA_CREDENTIAL));
         } catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to decode credential for save request");
             finish(RESULT_CANCELED);
             return;
         }
 
         if (!verifyCaller()) {
             Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
                     + mCredential.getAuthenticationDomain());
             finish(RESULT_CANCELED);
             return;
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(final CredentialStorageClient client) {
                 mClient = client;
                 runOnUiThread(new AfterStorageConnect());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         if (mClient != null) {
             mClient.disconnect(this);
         }
     }
 
     @UiThread
     private void finish(int resultCode) {
         setResult(resultCode);
         finish();
     }
 
     private boolean verifyCaller() {
         ComponentName callingActivity = getCallingActivity();
         if (callingActivity == null) {
             Log.w(LOG_TAG, "No calling activity found for save call");
             return false;
         }
 
         // TODO: a more complete implementation would need to expand this to the full set of
         // affiliated apps and sites, though it is generally unusual for an app to save a
         // credential for any authentication domain other than those it can directly identify as.
         mCallingPackage = callingActivity.getPackageName();
         mAuthDomainsForApp = AuthenticationDomain.listForPackage(this, mCallingPackage);
 
         if (!mAuthDomainsForApp.contains(mCredential.getAuthenticationDomain())) {
             Log.w(LOG_TAG, "App " + mCallingPackage
                     + " is not provably associated to authentication domain "
                     + mCredential.getAuthenticationDomain()
                     + " for the credential to be saved.");
             return false;
         }
 
 
         return true;
     }
 
     private final class AfterStorageConnect implements Runnable {
         @Override
         public void run() {
             try {
                 if (mClient.isOnNeverSaveList(mAuthDomainsForApp)) {
                     finish(RESULT_CANCELED);
                 } else {
                     // start confirm activity
                     Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
                             SaveCredentialActivity.this,
                             mCallingPackage,
                             mCredential);
                     confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                     startActivity(confirmIntent);
                     finish();
                 }
             } catch (IOException ex) {
                 finish(RESULT_CANCELED);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
index 6fbae75..5ff69e6 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -32,3 +32,2 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
-import org.openyolo.api.Credential;
 import org.openyolo.demoprovider.barbican.R;
@@ -36,140 +35,141 @@ import org.openyolo.demoprovider.barbican.UnlockActivity;
 import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.protocol.Credential;
 
 /**
  * Confirms with the user whether they want to save a credential provided by the
  * calling app. Verification of the app's right to save such a credential occurs
  * in {@link SaveCredentialActivity} before reaching this point.
  */
 public class SaveCredentialConfirmationActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "SaveCredential";
     private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
     private static final String EXTRA_CREDENTIAL = "credential";
     private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
 
     @BindView(R.id.save_prompt)
     TextView mSavePromptView;
 
     private Credential mCredential;
     private String mCallingAppName;
 
     private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
     private final CountDownLatch mClientConnected = new CountDownLatch(1);
 
     /**
      * Creates an intent to confirm whether the user wishes to save the specified credential.
      */
     public static Intent createIntent(
             Context context,
             String callingPackage,
             Credential credential) {
         Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
         intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
-        intent.putExtra(EXTRA_CREDENTIAL, credential.getProto().encode());
+        intent.putExtra(EXTRA_CREDENTIAL, credential.getProto().toByteArray());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         try {
             mCredential = Credential.fromProtoBytes(
                     getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
         } catch (IOException e) {
             Log.e(LOG_TAG, "Unable to decode credential", e);
             finish(RESULT_CANCELED);
         }
 
         try {
             PackageManager pm = getPackageManager();
             ApplicationInfo info = pm.getApplicationInfo(getCallingPackage(), 0);
             mCallingAppName = pm.getApplicationLabel(info).toString();
         } catch (PackageManager.NameNotFoundException e) {
             e.printStackTrace();
         }
 
         CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
             @Override
             public void onStorageConnected(CredentialStorageClient client) {
                 mClient.set(client);
                 mClientConnected.countDown();
             }
         });
 
         setContentView(R.layout.save_layout);
         ButterKnife.bind(this);
 
         String savePromptTemplate = getString(R.string.save_prompt_template);
         mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
     }
 
     private void finish(int resultCode) {
         setResult(resultCode);
         finish();
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         CredentialStorageClient client = mClient.get();
         if (client != null) {
             client.disconnect(this);
         }
     }
 
     @OnClick(R.id.save_button)
     void onSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
             finish(RESULT_CANCELED);
             return;
         }
 
         if (client.isUnlocked()) {
             try {
                 client.upsertCredential(mCredential.getProto());
                 finish(RESULT_OK);
             } catch (IOException e) {
                 Log.w(LOG_TAG, "Failed to write credential to storage");
                 finish(RESULT_CANCELED);
             }
         } else {
             Intent saveAfterUnlock = UnlockActivity.createIntent(
                     this,
                     true,
                     SaveAfterUnlockActivity.createIntent(this, mCredential.getProto()));
             saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
             startActivity(saveAfterUnlock);
             finish();
         }
     }
 
     @OnClick(R.id.never_save_button)
     void onNeverSaveClicked() {
         CredentialStorageClient client = getStorageClient();
         if (client == null) {
             finish(RESULT_CANCELED);
             return;
         }
 
         try {
             client.addToNeverSaveList(mCredential.getAuthenticationDomain());
         } catch (IOException e) {
             Log.w(LOG_TAG, "Failed to add app to never save list", e);
         }
 
         finish(RESULT_CANCELED);
     }
 
     private CredentialStorageClient getStorageClient() {
         try {
             mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
             return mClient.get();
         } catch (InterruptedException e) {
             Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
             return null;
         }
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
index 30b2ccc..dd54ebc 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
@@ -20,3 +20,6 @@ import android.support.annotation.Nullable;
 import android.util.Log;
+import com.google.protobuf.ByteString;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
@@ -30,600 +33,605 @@ import java.util.ListIterator;
 import java.util.TreeSet;
-import okio.BufferedSink;
-import okio.BufferedSource;
-import okio.ByteString;
-import okio.Okio;
-import org.openyolo.api.AuthenticationDomain;
 import org.openyolo.demoprovider.barbican.CredentialQualityScore;
-import org.openyolo.demoprovider.barbican.proto.AccountHint;
-import org.openyolo.demoprovider.barbican.proto.CredentialMeta;
-import org.openyolo.proto.Credential;
-import org.openyolo.proto.CredentialList;
+import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
+import org.openyolo.demoprovider.barbican.Protobufs.CredentialMeta;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.Protobufs.CredentialList;
 import org.spongycastle.crypto.digests.Blake2bDigest;
 import org.spongycastle.crypto.generators.BCrypt;
+import org.spongycastle.crypto.io.CipherInputStream;
+import org.spongycastle.crypto.io.CipherOutputStream;
 
 /**
  * An encrypted file-system based credential store. Uses bcrypt to derive an encryption key from
  * a password. Creates a directory for each authentication domain (using a hash of the domain)
  * under which the set of credentials for that domain is stored. This allows determining whether
  * a credential is available for a given authentication domain without the encryption key, which
  * is useful for answering OpenYOLO requests.
  */
 public final class CredentialStorage {
 
     private static final String LOG_TAG = "CredentialStorage";
 
     private static final int SALT_SIZE = 16;
     private static final int BCRYPT_COST = 10;
 
     private static final int AUTH_DOMAIN_HASH_SIZE = 32;
 
     private static final char[] HEX_CHARS =
             { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
     private static final byte[] KEY_VERIFICATION_BYTES =
             { 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0 };
     private static final int HALF_BYTE_WIDTH = 4;
     private static final int HALF_BYTE_MASK = 0xF;
 
     @NonNull
     private SecureRandom mRandom;
 
     @NonNull
     private File mStoreDir;
 
     private byte[] mSalt;
 
     @Nullable
     private byte[] mKey;
 
     /**
      * Initializes a credential store in the default location for the application.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(Context context) throws IOException {
         this(new SecureRandom(), new File(context.getFilesDir(), "store"));
     }
 
     /**
      * Initializes a credential store in the specified location.
      * @throws IOException if the store could not be initialized.
      */
     public CredentialStorage(
             @NonNull SecureRandom random,
             @NonNull File storeDir)
             throws IOException {
         mRandom = random;
         mStoreDir = storeDir;
 
         if (mStoreDir.exists()) {
             CredentialMeta credentialMeta = readCredentialMeta();
-            mSalt = credentialMeta.salt.toByteArray();
+            mSalt = credentialMeta.getSalt().toByteArray();
         }
     }
 
     /**
      * Determines whether a credential store exists in the initialized location.
      */
     public boolean isCreated() {
         return mStoreDir.exists();
     }
 
     /**
      * Determines whether the credential store is unlocked, meaning that the encryption key has
      * been derived from the password and is resident in memory.
      */
     public boolean isUnlocked() {
         return mKey != null;
     }
 
     /**
      * Locks the credential store, meaning that the derived encryption key is released from
      * memory if necessary.
      */
     public void lock() {
         // overwrite the key with random data, then release it for garbage collection
         mRandom.nextBytes(mKey);
         mKey = null;
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     @Nullable
     public List<String> retrieveNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
-        return meta.neverSave;
+        return meta.getNeverSaveList();
     }
 
     /**
      * Clears the "never save" list.
      * @throws IOException - in the case when the storage fails to be written
      */
     public void clearNeverSaveList() throws IOException {
         CredentialMeta meta = readCredentialMeta();
-        writeCredentialMeta(meta.newBuilder().neverSave(new ArrayList<String>()).build());
+        writeCredentialMeta(meta.toBuilder().clearNeverSave().build());
     }
 
     /**
      * Determines whether any of the specified authentication domains are on the never save list.
      * This operation can be performed without unlocking the credential store.
      * @throws IOException if the credential storage metadata cannot be read.
      */
     public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
-        if (meta.neverSave == null) {
+        if (meta.getNeverSaveCount() < 1) {
             return false;
         }
 
         HashSet<String> authDomainsAsStrings = new HashSet<>();
         for (AuthenticationDomain authDomain : authDomains) {
             authDomainsAsStrings.add(authDomain.toString());
         }
 
-        for (String neverSaveDomain : meta.neverSave) {
+        for (String neverSaveDomain : meta.getNeverSaveList()) {
             if (authDomainsAsStrings.contains(neverSaveDomain)) {
                 return true;
             }
         }
 
         return false;
     }
 
     /**
      * Adds the specified authentication domain to the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
-        if (meta.neverSave != null) {
-            for (String neverSaveDomain : meta.neverSave) {
-                neverSaveDomains.add(neverSaveDomain);
-            }
+        for (String neverSaveDomain : meta.getNeverSaveList()) {
+            neverSaveDomains.add(neverSaveDomain);
         }
 
         neverSaveDomains.add(authDomain.toString());
 
         writeCredentialMeta(
-                meta.newBuilder().neverSave(new ArrayList<>(neverSaveDomains)).build());
+                meta.toBuilder()
+                    .clearNeverSave()
+                    .addAllNeverSave(neverSaveDomains)
+                    .build());
     }
 
     /**
      * Removes the specified list of authentication domains from the never save list.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
         CredentialMeta meta = readCredentialMeta();
 
         TreeSet<String> neverSaveDomains = new TreeSet<>();
-        if (meta.neverSave != null) {
-            for (String neverSaveDomain : meta.neverSave) {
-                neverSaveDomains.add(neverSaveDomain);
-            }
+        for (String neverSaveDomain : meta.getNeverSaveList()) {
+            neverSaveDomains.add(neverSaveDomain);
         }
 
         for (AuthenticationDomain authDomain : authDomains) {
             neverSaveDomains.remove(authDomain.toString());
         }
 
         writeCredentialMeta(
-                meta.newBuilder().neverSave(new ArrayList<>(neverSaveDomains)).build());
+                meta.toBuilder()
+                    .clearNeverSave()
+                    .addAllNeverSave(neverSaveDomains)
+                    .build());
     }
 
     /**
      * Returns all account hints. The list of hints is automatically maintained as part of the
      * other credential save / delete operations.
      * @throws IOException if the credential storage metadata cannot be modified.
      */
     public List<AccountHint> getHints() throws IOException {
         CredentialMeta meta = readCredentialMeta();
-        return meta.hints;
+        return meta.getHintsList();
     }
 
     /**
      * Determines whether any credentials are stored for the given authentication domain. This
      * does not require the credential store to be unlocked.
      */
     public boolean hasCredentialFor(@NonNull String authDomain) {
         return getAuthDomainDir(authDomain).exists();
     }
 
     /**
      * Returns a list of all stored credentials. Requires that the credential store is unlocked.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listAllCredentials() throws IOException {
         ArrayList<Credential> allCredentials = new ArrayList<>();
         checkUnlocked();
         for (File authDomainDir : mStoreDir.listFiles()) {
             if (!authDomainDir.isDirectory()) {
                 continue;
             }
 
             List<Credential> credentials = readCredentials(authDomainDir);
             allCredentials.addAll(credentials);
         }
 
         return allCredentials;
     }
 
     /**
      * Returns a list of credentials for the specified authentication domain. Requires
      * that the credential store is unlocked. May be empty.
      * @throws IOException if the credentials could not be read.
      */
     @NonNull
     public List<Credential> listCredentials(String authDomain) throws IOException {
         checkUnlocked();
         return readCredentials(authDomain);
     }
 
     /**
      * Writes (or overwrites) the provided credential to the store. Requires that the credential
      * store is unlocked. May be empty.
      * @throws IOException if the credential could not be written.
      */
     public void upsertCredential(Credential credential) throws IOException {
         checkUnlocked();
-        List<Credential> credentials = new ArrayList<>(readCredentials(credential.authDomain));
+        List<Credential> credentials = new ArrayList<>(readCredentials(credential.getAuthDomain()));
 
         // replace any existing equivalent
         ListIterator<Credential> it = credentials.listIterator();
         boolean existingFound = false;
         while (it.hasNext() && !existingFound) {
             Credential existing = it.next();
-            if (credential.id.equals(existing.id)
-                    && eq(credential.authDomain, existing.authDomain)) {
+            if (credential.getId().equals(existing.getId())
+                    && eq(credential.getAuthDomain(), existing.getAuthDomain())) {
                 existingFound = true;
                 it.set(credential);
             }
         }
 
         if (!existingFound) {
             it.add(credential);
         }
 
-        writeCredentials(credential.authDomain, credentials);
+        writeCredentials(credential.getAuthDomain(), credentials);
         upsertHint(credential);
     }
 
     /**
      * Removes the specified credential (or one with the same authentication domain, identifier
      * and "type") from the store. Requires that the store is unlocked.
      * @throws IOException if the credential could not be deleted.
      */
     public void deleteCredential(Credential credential) throws IOException {
         checkUnlocked();
-        List<Credential> credentials = new ArrayList<>(readCredentials(credential.authDomain));
+        List<Credential> credentials = new ArrayList<>(readCredentials(credential.getAuthDomain()));
 
         ListIterator<Credential> it = credentials.listIterator();
         boolean existingFound = false;
         while (it.hasNext() && !existingFound) {
             Credential existing = it.next();
             if (credentialsAreEquivalent(credential, existing)) {
                 existingFound = true;
                 it.remove();
             }
         }
 
         if (existingFound) {
-            writeCredentials(credential.authDomain, credentials);
+            writeCredentials(credential.getAuthDomain(), credentials);
         }
     }
 
     private boolean credentialsAreEquivalent(Credential c1, Credential c2) {
         if (c1 == null) {
             return c2 == null;
         }
 
         if (c2 == null) {
             return false;
         }
 
-        return c1.id.equals(c2.id)
-                && c1.authDomain.equals(c2.authDomain)
-                && c1.authMethod.equals(c2.authMethod);
+        return c1.getId().equals(c2.getId())
+                && c1.getAuthDomain().equals(c2.getAuthDomain())
+                && c1.getAuthMethod().equals(c2.getAuthMethod());
     }
 
     private boolean areEqual(Object o1, Object o2) {
         return o1 == null ? o2 == null : o1.equals(o2);
     }
 
     /* **************************** store initialization ******************************************/
 
     /**
      * Creates a credential store at the initialized location, deriving an encryption key from
      * the specified password.
      * @throws IOException if the store could not be created.
      */
     public void create(String password) throws IOException {
         if (!mStoreDir.mkdirs()) {
             throw new IllegalStateException("unable to create credential store directory");
         }
 
         CredentialMeta meta = generateCredentialMeta();
         writeCredentialMeta(meta);
 
-        mSalt = meta.salt.toByteArray();
-        mKey = keyFromPassword(password, meta.cost);
+        mSalt = meta.getSalt().toByteArray();
+        mKey = keyFromPassword(password, meta.getCost());
         generateKeyTestFile();
     }
 
     /**
      * Unlocks the credential store, deriving an encryption key from the specified password and
      * validates it.
      * @throws IOException if the store could not be unlocked.
      */
     public boolean unlock(String password) throws IOException {
         if (!isCreated()) {
             throw new IllegalStateException("Store has not been created");
         }
 
         CredentialMeta credentialMeta = readCredentialMeta();
-        mSalt = credentialMeta.salt.toByteArray();
-        mKey = keyFromPassword(password, credentialMeta.cost);
+        mSalt = credentialMeta.getSalt().toByteArray();
+        mKey = keyFromPassword(password, credentialMeta.getCost());
         return verifyKey();
     }
 
     /* **************************** credential meta handling **************************************/
 
     private File getCredentialMetaFile() {
         return new File(mStoreDir, "meta");
     }
 
     private CredentialMeta generateCredentialMeta() {
-        return new CredentialMeta.Builder()
-                .salt(ByteString.of(generateRandomBytes(SALT_SIZE)))
-                .cost(BCRYPT_COST)
+        return CredentialMeta.newBuilder()
+                .setSalt(ByteString.copyFrom(generateRandomBytes(SALT_SIZE)))
+                .setCost(BCRYPT_COST)
                 .build();
     }
 
     private void writeCredentialMeta(CredentialMeta meta) throws IOException {
-        BufferedSink sink = null;
+        FileOutputStream stream = null;
         try {
-            sink = Okio.buffer(Okio.sink(getCredentialMetaFile()));
-            meta.encode(sink);
+            stream = new FileOutputStream(getCredentialMetaFile());
+            meta.writeTo(stream);
         } finally {
-            IoUtil.closeQuietly(sink, LOG_TAG);
+            IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private CredentialMeta readCredentialMeta() throws IOException {
-        BufferedSource src = null;
+        FileInputStream stream = null;
         try {
-            src = Okio.buffer(Okio.source(getCredentialMetaFile()));
-            return CredentialMeta.ADAPTER.decode(src);
+            stream = new FileInputStream(getCredentialMetaFile());
+            return CredentialMeta.parseFrom(stream);
         } finally {
-            IoUtil.closeQuietly(src, LOG_TAG);
+            IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private void upsertHint(Credential credential) throws IOException {
         CredentialMeta meta = readCredentialMeta();
-        List<AccountHint> hints = new ArrayList<>(readCredentialMeta().hints);
+
+        // create a copy of the hints list for modification
+        List<AccountHint> hints = new ArrayList<>(readCredentialMeta().getHintsList());
 
         ListIterator<AccountHint> hintIter = hints.listIterator();
         boolean found = false;
         while (!found && hintIter.hasNext()) {
             AccountHint existingHint = hintIter.next();
 
-            if (existingHint.identifier.equals(credential.id)
-                    && existingHint.authMethod.equals(credential.authMethod)
+            if (existingHint.getIdentifier().equals(credential.getId())
+                    && existingHint.getAuthMethod().equals(credential.getAuthMethod())
                     && CredentialQualityScore.getScore(existingHint)
                             <= CredentialQualityScore.getScore(credential)) {
                 hintIter.remove();
                 hintIter.add(convertCredentialToHint(credential));
                 found = true;
             }
         }
 
         if (!found) {
             hintIter.add(convertCredentialToHint(credential));
         }
 
-        writeCredentialMeta(meta.newBuilder().hints(hints).build());
+        writeCredentialMeta(meta.toBuilder()
+                .clearHints()
+                .addAllHints(hints)
+                .build());
     }
 
     private AccountHint convertCredentialToHint(Credential credential) {
-        return new AccountHint.Builder()
-                .identifier(credential.id)
-                .authMethod(credential.authMethod)
-                .name(credential.displayName)
-                .pictureUri(credential.displayPictureUri)
+        return AccountHint.newBuilder()
+                .setIdentifier(credential.getId())
+                .setAuthMethod(credential.getAuthMethod())
+                .setName(credential.getDisplayName())
+                .setPictureUri(credential.getDisplayPictureUri())
                 .build();
     }
 
     /* **************************** key validation ************************************************/
 
     private File getKeyTestFile() {
         return new File(mStoreDir, "test");
     }
 
     private void generateKeyTestFile() throws IOException {
-        BufferedSink sink = null;
+        CipherOutputStream stream = null;
         try {
-            sink = IoUtil.encryptTo(getKeyTestFile(), mKey);
-            sink.write(KEY_VERIFICATION_BYTES);
-            sink.close();
+            stream = IoUtil.encryptTo(getKeyTestFile(), mKey);
+            stream.write(KEY_VERIFICATION_BYTES);
         } finally {
-            IoUtil.closeQuietly(sink, LOG_TAG);
+            IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private boolean verifyKey() throws IOException {
-        BufferedSource source = null;
+        CipherInputStream stream = null;
         try {
-            source = IoUtil.decryptFrom(getKeyTestFile(), mKey);
-            byte[] bytes = source.readByteArray();
-            return bytesEqual(KEY_VERIFICATION_BYTES, bytes);
+            stream = IoUtil.decryptFrom(getKeyTestFile(), mKey);
+            byte[] bytes = new byte[KEY_VERIFICATION_BYTES.length];
+            int numRead = stream.read(bytes);
+            return numRead == KEY_VERIFICATION_BYTES.length
+                && bytesEqual(KEY_VERIFICATION_BYTES, bytes);
         } catch (IOException ex) {
             Log.i(LOG_TAG, "Key verification failed");
             return false;
         } finally {
-            IoUtil.closeQuietly(source, LOG_TAG);
+            IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* ************************** auth domain directory management ********************************/
 
     private File getAuthDomainDir(String authDomain) {
         return new File(mStoreDir, toBlakeHash(authDomain));
     }
 
     private File initAuthDomainDir(String authDomain) throws IOException {
         File authorityDir = getAuthDomainDir(authDomain);
         if (!authorityDir.exists()) {
             if (!authorityDir.mkdirs()) {
                 throw new IOException("failed to create authority dir");
             }
         }
 
         return authorityDir;
     }
 
     private void deleteAuthDomainDir(String authDomain) throws IOException {
         File credsFile = getCredentialsFile(authDomain);
         if (credsFile.exists()) {
             if (!credsFile.delete()) {
                 throw new IOException("failed to delete credentials file");
             }
         }
 
         File authorityDir = getAuthDomainDir(authDomain);
         if (authorityDir.exists()) {
             if (!authorityDir.delete()) {
                 throw new IOException("failed to delete authority directory");
             }
         }
     }
 
     private File getCredentialsFile(String authDomain) {
         return getCredentialsFile(getAuthDomainDir(authDomain));
     }
 
     private File getCredentialsFile(File authDomainDir) {
         return new File(authDomainDir, "creds");
     }
 
     /* **************************** credential manipulation ***************************************/
 
     private void writeCredentials(String authDomain, List<Credential> credentials)
             throws IOException {
         if (credentials.size() == 0) {
             deleteAuthDomainDir(authDomain);
             return;
         }
 
         initAuthDomainDir(authDomain);
-        BufferedSink credentialsSink = null;
+        CipherOutputStream stream = null;
         try {
-            credentialsSink = IoUtil.encryptTo(
-                    getCredentialsFile(authDomain),
-                    mKey);
+            stream = IoUtil.encryptTo(getCredentialsFile(authDomain), mKey);
+            CredentialList proto = CredentialList.newBuilder()
+                    .addAllCredentials(credentials)
+                    .build();
 
-            CredentialList proto = new CredentialList.Builder().credentials(credentials).build();
-            proto.encode(credentialsSink);
+            proto.writeTo(stream);
         } finally {
-            IoUtil.closeQuietly(credentialsSink, LOG_TAG);
+            IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     private List<Credential> readCredentials(String authDomain) throws IOException {
         return readCredentials(getAuthDomainDir(authDomain));
     }
 
     private List<Credential> readCredentials(File authDomain) throws IOException {
         File credentialsFile = getCredentialsFile(authDomain);
         if (!credentialsFile.exists()) {
             return Collections.emptyList();
         }
 
-        BufferedSource credentialsSource = null;
+        CipherInputStream stream = null;
         try {
-            credentialsSource = IoUtil.decryptFrom(credentialsFile, mKey);
-            CredentialList proto = CredentialList.ADAPTER.decode(credentialsSource);
-            return proto.credentials;
+            stream = IoUtil.decryptFrom(credentialsFile, mKey);
+            return CredentialList.parseFrom(stream).getCredentialsList();
         } finally {
-            IoUtil.closeQuietly(credentialsSource, LOG_TAG);
+            IoUtil.closeQuietly(stream, LOG_TAG);
         }
     }
 
     /* *********************************** utils **************************************************/
 
     private void checkUnlocked() {
         if (!isUnlocked()) {
             throw new IllegalStateException("credential store is locked");
         }
     }
 
     private byte[] keyFromPassword(String password, int cost) {
         return BCrypt.generate(toUtf8Bytes(password), mSalt, cost);
     }
 
     private static byte[] toUtf8Bytes(String str) {
         try {
             return str.getBytes("UTF-8");
         } catch (UnsupportedEncodingException e) {
             throw new IllegalStateException("UTF-8 character set not supported, against spec");
         }
     }
 
     private byte[] generateRandomBytes(int length) {
         byte[] bytes = new byte[length];
         mRandom.nextBytes(bytes);
         return bytes;
     }
 
     private boolean bytesEqual(byte[] b1, byte[] b2) {
         if (b1 == null) {
             return b2 == null;
         }
 
         if (b2 == null || b1.length != b2.length) {
             return false;
         }
 
         for (int i = 0; i < b1.length; i++) {
             if (b1[i] != b2[i]) {
                 return false;
             }
         }
 
         return true;
     }
 
     private String toBlakeHash(String message) {
         Blake2bDigest digest = new Blake2bDigest(
                 null, /* no key */
                 AUTH_DOMAIN_HASH_SIZE,
                 mSalt,
                 null); /* no personalization of the hashing function */
         byte[] messageBytes = toUtf8Bytes(message);
         digest.update(messageBytes, 0, messageBytes.length);
         byte[] result = new byte[AUTH_DOMAIN_HASH_SIZE];
         digest.doFinal(result, 0);
         return toHexString(result);
     }
 
     private String toHexString(byte[] bytes) {
         char[] result = new char[bytes.length * 2];
         for (int i = 0, j = 0; i < bytes.length; i++, j += 2) {
             byte nextByte = bytes[i];
 
             result[j] = HEX_CHARS[(nextByte >>> HALF_BYTE_WIDTH) & HALF_BYTE_MASK];
             result[j + 1] = HEX_CHARS[nextByte & HALF_BYTE_MASK];
         }
         return new String(result);
     }
 
     private boolean eq(Object o1, Object o2) {
         if (o1 == null) {
             return o2 == null;
         }
         return o2 != null && o1.equals(o2);
     }
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
index fa7b51f..1b2ef9d 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
@@ -18,9 +18,8 @@ import java.io.IOException;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.demoprovider.barbican.proto.AccountHint;
-import org.openyolo.proto.Credential;
-
+import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * Credential storage operations which are available via the service interface.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
index 85cc506..a76f008 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
@@ -26,9 +26,9 @@ import java.util.UUID;
 import java.util.concurrent.TimeUnit;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.demoprovider.barbican.proto.AccountHint;
-import org.openyolo.proto.Credential;
+import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * A client to the {@link CredentialStorageService}, allowing activities to access the
  * retained instance of the credential store.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
index 0c7c9f1..c8950f6 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
@@ -28,13 +28,13 @@ import java.util.ArrayList;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
 import org.openyolo.demoprovider.barbican.CredentialListActivity;
 import org.openyolo.demoprovider.barbican.LockActivity;
+import org.openyolo.demoprovider.barbican.Protobufs.AccountHint;
 import org.openyolo.demoprovider.barbican.R;
-import org.openyolo.demoprovider.barbican.proto.AccountHint;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.Credential;
 
 /**
  * A service which retains an instance of {@link CredentialStorage} beyond the lifecycle of the
  * activities that interact with it. This reduces the frequency at which the user would have
  * to enter their password to unlock the keystore.
  */
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java
index c112263..46e8f94 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java
@@ -16,6 +16,2 @@ package org.openyolo.demoprovider.barbican.storage;
 
-import static okio.Okio.buffer;
-import static okio.Okio.sink;
-import static okio.Okio.source;
-
 import android.support.annotation.NonNull;
@@ -25,52 +21,77 @@ import java.io.Closeable;
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
-import okio.BlockCipherSink;
-import okio.BlockCipherSource;
-import okio.BufferedSink;
-import okio.BufferedSource;
-import okio.Sink;
-import okio.Source;
-import org.spongycastle.crypto.engines.TwofishEngine;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.SecureRandom;
+import org.spongycastle.crypto.engines.AESEngine;
+import org.spongycastle.crypto.io.CipherInputStream;
+import org.spongycastle.crypto.io.CipherOutputStream;
+import org.spongycastle.crypto.modes.SICBlockCipher;
 import org.spongycastle.crypto.paddings.PKCS7Padding;
+import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
 import org.spongycastle.crypto.params.KeyParameter;
+import org.spongycastle.crypto.params.ParametersWithIV;
 
 /**
- * Utilities for reading and writing encrypted data to disk.
+ * Utilities for reading and writing encrypted data to disk. The cipher used for Barbican
+ * is AES-128/CTR/PKCS7Padding.
  */
 class IoUtil {
 
     static final int KEY_SIZE = 16;
 
     static final int BLOCK_SIZE = 16;
 
-    static Sink encryptTo(Sink sink, byte[] key) {
-        TwofishEngine engine = new TwofishEngine();
-        engine.init(true, new KeyParameter(key));
-        return new BlockCipherSink(engine, new PKCS7Padding(), sink);
+    static final SecureRandom RANDOM = new SecureRandom();
+
+    static CipherOutputStream encryptTo(OutputStream stream, byte[] key) throws IOException {
+        byte[] randomIv = new byte[BLOCK_SIZE];
+        RANDOM.nextBytes(randomIv);
+
+        stream.write(randomIv);
+        return new CipherOutputStream(
+                stream,
+                createAes128CtrPkcs7PaddingCipher(true, randomIv, key));
     }
 
-    static BufferedSink encryptTo(File file, byte[] key) throws FileNotFoundException {
-        return buffer(encryptTo(buffer(sink(file)), key));
+    static CipherOutputStream encryptTo(File file, byte[] key) throws IOException {
+        return encryptTo(new FileOutputStream(file), key);
     }
 
-    static Source decryptFrom(Source source, byte[] key) {
-        TwofishEngine engine = new TwofishEngine();
-        engine.init(false, new KeyParameter(key));
-        return new BlockCipherSource(engine, new PKCS7Padding(), source);
+    static CipherInputStream decryptFrom(InputStream stream, byte[] key) throws IOException {
+        byte[] iv = new byte[BLOCK_SIZE];
+        if (stream.read(iv) != BLOCK_SIZE) {
+            throw new IOException("Failed to read IV");
+        }
+        return new CipherInputStream(stream, createAes128CtrPkcs7PaddingCipher(false, iv, key));
     }
 
-    static BufferedSource decryptFrom(File file, byte[] key) throws FileNotFoundException {
-        return buffer(decryptFrom(buffer(source(file)), key));
+    static CipherInputStream decryptFrom(File file, byte[] key) throws IOException {
+        return decryptFrom(new FileInputStream(file), key);
+    }
+
+    static PaddedBufferedBlockCipher createAes128CtrPkcs7PaddingCipher(
+            boolean encrypting,
+            byte[] iv,
+            byte[] key) {
+        AESEngine aes = new AESEngine();
+        SICBlockCipher aesCtr = new SICBlockCipher(aes);
+        PaddedBufferedBlockCipher aesCtrPkcs7 =
+                new PaddedBufferedBlockCipher(aesCtr, new PKCS7Padding());
+        aesCtrPkcs7.init(encrypting, new ParametersWithIV(new KeyParameter(key), iv));
+
+        return aesCtrPkcs7;
     }
 
     static void closeQuietly(@Nullable Closeable resource, @NonNull String logTag) {
         if (resource != null) {
             try {
                 resource.close();
             } catch (IOException ex) {
                 Log.w(logTag, "Failed to close IO stream", ex);
             }
         }
     }
 }
diff --git a/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java b/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
index 94b1bb4..462cfcc 100644
--- a/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
+++ b/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
@@ -20,2 +20,3 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 
+import com.google.common.io.ByteStreams;
 import java.io.ByteArrayInputStream;
@@ -23,7 +24,2 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import okio.BufferedSink;
-import okio.BufferedSource;
-import okio.Okio;
-import okio.Sink;
-import okio.Source;
 import org.junit.Test;
@@ -32,73 +28,74 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
+import org.spongycastle.crypto.io.CipherInputStream;
+import org.spongycastle.crypto.io.CipherOutputStream;
 
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class IoUtilTest {
 
     @Test
     public void testCrypto_emptyMessage() throws Exception {
         byte[] testData = new byte[0];
         assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
     }
 
     @Test
     public void testCrypto_subBlock() throws Exception {
         byte[] testData = generateArray(IoUtil.BLOCK_SIZE - 2);
         assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
     }
 
     @Test
     public void testCrypto_singleBlock() throws Exception {
         byte[] testData = generateArray(IoUtil.BLOCK_SIZE);
         assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
     }
 
     @Test
     public void testCrypto_multiBlock() throws Exception {
         byte[] testData = generateArray(4 * IoUtil.BLOCK_SIZE);
         assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
     }
 
     @Test
     public void testCrypto_multiBlockWithSubBlock() throws Exception {
         byte[] testData = generateArray(4 * IoUtil.BLOCK_SIZE + 3);
         assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
     }
 
     @Test
     public void testCryptoLongStream() throws Exception {
         byte[] longData = generateArray(1024 * 1024);
         assertThat(longData).isEqualTo(writeAndRead(longData, generateTestKey()));
     }
 
     private byte[] writeAndRead(byte[] data, byte[] key) throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        Sink outSink = Okio.sink(baos);
-        BufferedSink cryptoSink = Okio.buffer(IoUtil.encryptTo(outSink, key));
-        cryptoSink.write(data);
-        cryptoSink.close();
+        CipherOutputStream outStream = IoUtil.encryptTo(baos, key);
+        outStream.write(data);
+        outStream.close();
 
         byte[] cipherText = baos.toByteArray();
 
         ByteArrayInputStream bais = new ByteArrayInputStream(cipherText);
-        Source inSource = Okio.source(bais);
-        BufferedSource cryptoSource = Okio.buffer(IoUtil.decryptFrom(inSource, generateTestKey()));
+        CipherInputStream inStream = IoUtil.decryptFrom(bais, key);
 
-        byte[] result = cryptoSource.readByteArray();
-        cryptoSource.close();
+        byte[] result = ByteStreams.toByteArray(inStream);
+
+        inStream.close();
         return result;
     }
 
     private byte[] generateArray(int length) {
         byte[] bytes = new byte[length];
         for (int i = 0; i < bytes.length; i++) {
             bytes[i] = (byte) i;
         }
 
         return bytes;
     }
 
     private byte[] generateTestKey() {
         return generateArray(IoUtil.KEY_SIZE);
     }
 }
diff --git a/demoproviders/barbican/proguard-rules.txt b/demoproviders/barbican/proguard-rules.txt
new file mode 100644
index 0000000..de60ad4
--- /dev/null
+++ b/demoproviders/barbican/proguard-rules.txt
@@ -0,0 +1,17 @@
+-dontwarn sun.misc.Unsafe
+-dontwarn javax.annotation.**
+-dontwarn java.lang.ClassValue
+-dontwarn com.google.j2objc.annotations.**
+-dontwarn com.google.errorprone.annotations.**
+-dontwarn com.google.appengine.**
+-dontwarn com.google.apphosting.**
+-dontwarn com.google.protobuf.Extension
+-dontwarn com.google.protobuf.ExtensionRegistry
+-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
+-dontwarn com.google.protobuf.UnsafeUtil
+
+# ignore dynamic accesses in guava code
+-dontnote com.google.common.**
+
+# ignore dynamic accesses in javalite proto
+-dontnote com.google.protobuf.GeneratedMessageLite
\ No newline at end of file
diff --git a/demoproviders/barbican/proto/credential-meta.proto b/demoproviders/barbican/proto/credential-meta.proto
index 2585032..c09755e 100644
--- a/demoproviders/barbican/proto/credential-meta.proto
+++ b/demoproviders/barbican/proto/credential-meta.proto
@@ -20,3 +20,4 @@ package org.openyolo.demoprovider.barbican;
 
-option java_package = "org.openyolo.demoprovider.barbican.proto";
+option java_package = "org.openyolo.demoprovider.barbican";
+option java_outer_classname = "Protobufs";
 
diff --git a/demoproviders/trapdoor/build.gradle b/demoproviders/trapdoor/build.gradle
index b757c47..f28198b 100644
--- a/demoproviders/trapdoor/build.gradle
+++ b/demoproviders/trapdoor/build.gradle
@@ -7,13 +7,13 @@ apply from: "${rootDir}/config/android-common.gradle"
 android {
     defaultConfig {
         applicationId 'org.openyolo.demoprovider.trapdoor'
         project.archivesBaseName = 'openyolo-demoprovider-trapdoor'
         vectorDrawables.useSupportLibrary = true
     }
     buildTypes {
         release {
             minifyEnabled true
-            proguardFiles getDefaultProguardFile('proguard-android.txt')
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
         }
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
index 8707af9..1db3ddc 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -20,56 +20,58 @@ import android.support.annotation.NonNull;
 import android.util.Log;
+import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import com.google.bbq.proto.BroadcastQuery;
+import com.google.protobuf.ByteString;
 import java.util.Set;
-import okio.ByteString;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.api.RetrieveRequest;
-import org.openyolo.api.internal.IntentUtil;
-import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveResponse;
+import org.openyolo.protocol.RetrieveRequest;
+import org.openyolo.protocol.internal.IntentUtil;
 import org.openyolo.spi.BaseCredentialQueryReceiver;
 
 /**
  * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
  * we respond to all requests with an intent as long as the
- * {@link org.openyolo.api.AuthenticationMethods#ID_AND_PASSWORD id and password} authentication
- * method is supported.
+ * {@link org.openyolo.protocol.AuthenticationMethods#ID_AND_PASSWORD id and password}
+ * authentication method is supported.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
-        Log.i(LOG_TAG, "Processing retrieve query from claimed caller: " + query.requestingApp);
+        Log.i(LOG_TAG, "Processing retrieve query from claimed caller: "
+                + query.getRequestingApp());
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // Ensure the caller supports the Id and Password authentication method
         if (!request.getAuthenticationMethods().contains(AuthenticationMethods.ID_AND_PASSWORD)) {
             responseSender.sendResponse(query,  null /* response */);
             return;
         }
 
         Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
-        CredentialRetrieveResponse response = new CredentialRetrieveResponse.Builder()
-                .retrieveIntent(ByteString.of(IntentUtil.toBytes(retrieveIntent)))
+        CredentialRetrieveResponse response = CredentialRetrieveResponse.newBuilder()
+                .setRetrieveIntent(ByteString.copyFrom(IntentUtil.toBytes(retrieveIntent)))
                 .build();
 
-        Log.i(LOG_TAG, "Accepting credential request for claimed caller: " + query.requestingApp);
-        responseSender.sendResponse(query, response.encode());
+        Log.i(LOG_TAG, "Accepting credential request for claimed caller: "
+                + query.getRequestingApp());
+        responseSender.sendResponse(query, response.toByteArray());
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
index f770785..c5915e3 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -26,5 +26,5 @@ import java.util.TreeSet;
 import me.philio.pinentry.PinEntryView;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Protobufs.Credential;
 import org.openyolo.spi.RetrieveIntentResultUtil;
@@ -32,68 +32,68 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
  */
 public class RetrieveActivity extends AppCompatActivity {
 
     private static final int PIN_SIZE = 6;
 
     private static final String LOG_TAG = "TrapdoorRetrieve";
 
     private AuthenticationDomain mDomain;
 
     /**
      * Creates an Intent to start this activity.
      */
     public static Intent createIntent(Context context) {
         return new Intent(context, RetrieveActivity.class);
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         if (getCallingPackage() == null) {
             Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
             setResult(RESULT_CANCELED);
             finish();
             return;
         }
 
         mDomain = new TreeSet<>(
                 AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
         Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
 
         setContentView(R.layout.dialog_layout);
         ((PinEntryView)findViewById(R.id.pin_entry_field))
                 .addTextChangedListener(new PinChangedWatcher());
     }
 
     private class PinChangedWatcher implements TextWatcher {
         @Override
         public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
 
         @Override
         public void onTextChanged(CharSequence seq, int start, int before, int count) {}
 
         @Override
         public void afterTextChanged(Editable pin) {
             if (pin.length() != PIN_SIZE) {
                 return;
             }
             String userName = UserDataStore.getUserName(RetrieveActivity.this);
             String password = PasswordGenerator.generatePassword(
                     userName,
                     pin.toString(),
                     mDomain.toString());
 
-            Credential credential = new Credential.Builder()
-                    .authMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
-                    .authDomain(mDomain.toString())
-                    .id(UserDataStore.getUserName(RetrieveActivity.this))
-                    .password(password)
+            Credential credential = Credential.newBuilder()
+                    .setAuthMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
+                    .setAuthDomain(mDomain.toString())
+                    .setId(UserDataStore.getUserName(RetrieveActivity.this))
+                    .setPassword(password)
                     .build();
 
             setResult(RESULT_OK, RetrieveIntentResultUtil.createResponseData(credential));
             finish();
         }
     }
 }
diff --git a/demoproviders/trapdoor/proguard-rules.txt b/demoproviders/trapdoor/proguard-rules.txt
new file mode 100644
index 0000000..de60ad4
--- /dev/null
+++ b/demoproviders/trapdoor/proguard-rules.txt
@@ -0,0 +1,17 @@
+-dontwarn sun.misc.Unsafe
+-dontwarn javax.annotation.**
+-dontwarn java.lang.ClassValue
+-dontwarn com.google.j2objc.annotations.**
+-dontwarn com.google.errorprone.annotations.**
+-dontwarn com.google.appengine.**
+-dontwarn com.google.apphosting.**
+-dontwarn com.google.protobuf.Extension
+-dontwarn com.google.protobuf.ExtensionRegistry
+-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
+-dontwarn com.google.protobuf.UnsafeUtil
+
+# ignore dynamic accesses in guava code
+-dontnote com.google.common.**
+
+# ignore dynamic accesses in javalite proto
+-dontnote com.google.protobuf.GeneratedMessageLite
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/values/colors.xml b/demoproviders/trapdoor/res/values/colors.xml
index 54ddb45..2f7370f 100644
--- a/demoproviders/trapdoor/res/values/colors.xml
+++ b/demoproviders/trapdoor/res/values/colors.xml
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <color name="colorPrimary">#8bc34a</color>
     <color name="colorPrimaryDark">#388e3c</color>
     <color name="colorAccent">#2e7d32</color>
 
     <color name="colorLight">#c5e1a5</color>
+    <color name="black_54pc">#8a000000</color>
 </resources>
diff --git a/protocol/AndroidManifest.xml b/protocol/AndroidManifest.xml
new file mode 100644
index 0000000..ced9402
--- /dev/null
+++ b/protocol/AndroidManifest.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest package="org.openyolo.protocol" />
diff --git a/protocol/build.gradle b/protocol/build.gradle
new file mode 100644
index 0000000..200c688
--- /dev/null
+++ b/protocol/build.gradle
@@ -0,0 +1,17 @@
+apply plugin: 'com.android.library'
+
+apply from:'../config/android-common.gradle'
+apply from:'../config/protobuf.gradle'
+
+android.defaultConfig.project.archivesBaseName = 'data'
+
+dependencies {
+    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    compile "org.hamcrest:hamcrest-core:1.3"
+    compile "org.valid4j:valid4j:0.5.0"
+    apply from:'../config/testdeps.gradle', to:it
+}
+
+apply from: '../config/style.gradle'
+apply from: '../config/coverage.gradle'
+apply from: '../config/javadoc.gradle'
\ No newline at end of file
diff --git a/api/java/org/openyolo/api/AuthenticationDomain.java b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
similarity index 92%
rename from api/java/org/openyolo/api/AuthenticationDomain.java
rename to protocol/java/org/openyolo/protocol/AuthenticationDomain.java
index fd58dd6..37743e3 100644
--- a/api/java/org/openyolo/api/AuthenticationDomain.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationDomain.java
@@ -14,6 +14,5 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationDomain;
 import static org.valid4j.Assertive.require;
@@ -35,201 +34,193 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.api.internal.ValueConverter;
+import org.openyolo.protocol.internal.CustomMatchers;
+import org.valid4j.Assertive;
 
 
 /**
  * A URI-based representation of an authentication domain, which determines the scope within which
  * a credential is valid. An authentication domain may have multiple equivalent representations,
  * such as when apps and sites share the same authentication system. The responsibility for
  * determining whether two given authentication domains are equivalent lies with the credential
  * provider.
  *
  * <p>Two broad classes of authentication domain are defined in the OpenYOLO
  * specification : Android authentication domains, of form
  * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
  * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
  * with no path, query or fragment. They must therefore always be of form
  * {@code scheme://authority}.
  */
 @SuppressLint("PackageManagerGetSignatures")
 public final class AuthenticationDomain implements Comparable<AuthenticationDomain> {
 
-    static final ValueConverter<String, AuthenticationDomain> CONVERTER_STRING_TO_DOMAIN =
-            new StringToAuthenticationDomainConverter();
-
     private static final String DIGEST_SHA_512 = "SHA-512";
     private static final String SCHEME_ANDROID = "android";
     private static final String SCHEME_HTTP = "http";
     private static final String SCHEME_HTTPS = "https";
 
     private final Uri mUri;
 
     /**
      * Creates an authentication domain that represents the current package, as identified
      * by the provided context's {@link Context#getPackageName() getPackageName} method.
      */
     @NonNull
     public static AuthenticationDomain getSelfAuthDomain(@NonNull Context context) {
         require(context, notNullValue());
 
         PackageManager pm = context.getPackageManager();
         String packageName = context.getPackageName();
         PackageInfo packageInfo;
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             throw new IllegalStateException("Unable to find package info for " + packageName);
         }
 
         return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
     }
 
     /**
      * Creates the list of all authentication domains that represent the specified package.
      * The list will contain a distinct entry for every signature related to the application.
      */
     @NonNull
     public static List<AuthenticationDomain> listForPackage(
             @NonNull Context context,
             @Nullable String packageName) {
         require(context, notNullValue());
 
         PackageManager pm = context.getPackageManager();
         PackageInfo packageInfo;
         if (TextUtils.isEmpty(packageName)) {
             return Collections.emptyList();
         }
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             return Collections.emptyList();
         }
 
         ArrayList<AuthenticationDomain> authDomains =
                 new ArrayList<>(packageInfo.signatures.length);
         for (Signature signature : packageInfo.signatures) {
             authDomains.add(createAndroidAuthDomain(packageName, signature));
         }
 
         return authDomains;
     }
 
     /**
      * Creates an Android authentication domain (of form {@code android://SIGNATURE@PACKAGE}),
      * given the provided package name and signature.
      */
     @NonNull
     public static AuthenticationDomain createAndroidAuthDomain(
             @NonNull String packageName,
             @NonNull Signature signature) {
         require(!TextUtils.isEmpty(packageName), "packageName must not be null or empty");
         require(signature, notNullValue());
 
         return new AuthenticationDomain(
                 new Uri.Builder()
                         .scheme(SCHEME_ANDROID)
                         .encodedAuthority(generateSignatureHash(signature) + "@" + packageName)
                         .build());
     }
 
     @NonNull
     static String generateSignatureHash(@NonNull Signature signature) {
         try {
             MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_512);
             byte[] hashBytes = digest.digest(signature.toByteArray());
             return Base64.encodeToString(hashBytes, Base64.URL_SAFE).replace("\n", "");
         } catch (NoSuchAlgorithmException e) {
             throw new IllegalStateException(
                     "Platform does not support" + DIGEST_SHA_512 + " hashing");
         }
     }
 
     /**
      * Creates an authentication domain from the provided String representation. If the string
      * provided is not a valid authentication domain, an {@link IllegalArgumentException}
      * will be thrown.
      */
     public AuthenticationDomain(@NonNull String authDomainString) {
-        mUri = require(Uri.parse(authDomainString), isValidAuthenticationDomain());
+        mUri = Assertive.require(
+                Uri.parse(authDomainString),
+                CustomMatchers.isValidAuthenticationDomain());
     }
 
     private AuthenticationDomain(@NonNull Uri authDomainUri) {
         mUri = authDomainUri;
     }
 
     /**
      * Determines whether the authentication domain refers to an Android application.
      */
     public boolean isAndroidAuthDomain() {
         return SCHEME_ANDROID.equals(mUri.getScheme());
     }
 
     /**
      * Determines whether the authentication domain refers to a Web domain.
      */
     public boolean isWebAuthDomain() {
         return SCHEME_HTTP.equals(mUri.getScheme())
                 || SCHEME_HTTPS.equals(mUri.getScheme());
     }
 
     /**
      * Retrieves the Android package name from the authentication domain. If the authentication
      * domain does not represent an Android application, an {@link IllegalStateException} will
      * be thrown.
      */
     @NonNull
     public String getAndroidPackageName() {
         if (!isAndroidAuthDomain()) {
             throw new IllegalStateException("Authentication domain is not an Android domain");
         }
         return mUri.getHost();
     }
 
     /**
      * Retrieves the URI form of the authentication domain.
      */
     @NonNull
     public Uri getUri() {
         return mUri;
     }
 
     /**
      * Retrieves the string form of the authentication domain.
      */
     @NonNull
     public String toString() {
         return mUri.toString();
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (!(obj instanceof AuthenticationDomain)) {
             return false;
         }
 
         AuthenticationDomain other = (AuthenticationDomain) obj;
 
         return mUri.equals(other.getUri());
     }
 
     @Override
     public int hashCode() {
         return mUri.hashCode();
     }
 
     @Override
     public int compareTo(@NonNull AuthenticationDomain authenticationDomain) {
         return mUri.compareTo(authenticationDomain.getUri());
     }
-
-    static class StringToAuthenticationDomainConverter
-            implements ValueConverter<String, AuthenticationDomain> {
-        @Override
-        public AuthenticationDomain convert(String value) {
-            return new AuthenticationDomain(value);
-        }
-    }
 }
diff --git a/api/java/org/openyolo/api/AuthenticationMethods.java b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
similarity index 94%
rename from api/java/org/openyolo/api/AuthenticationMethods.java
rename to protocol/java/org/openyolo/protocol/AuthenticationMethods.java
index fdf020e..32d181d 100644
--- a/api/java/org/openyolo/api/AuthenticationMethods.java
+++ b/protocol/java/org/openyolo/protocol/AuthenticationMethods.java
@@ -14,9 +14,10 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
 import android.net.Uri;
+import org.openyolo.protocol.Credential.Builder;
 
 /**
  * A set of well-known authentication method URIs for use with
- * {@link org.openyolo.api.Credential.Builder#setAuthenticationMethod(String)}.
+ * {@link Builder#setAuthenticationMethod(String)}.
  */
diff --git a/api/java/org/openyolo/api/Credential.java b/protocol/java/org/openyolo/protocol/Credential.java
similarity index 61%
rename from api/java/org/openyolo/api/Credential.java
rename to protocol/java/org/openyolo/protocol/Credential.java
index 5292d02..ee936dc 100644
--- a/api/java/org/openyolo/api/Credential.java
+++ b/protocol/java/org/openyolo/protocol/Credential.java
@@ -14,8 +14,9 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationMethod;
-import static org.openyolo.api.internal.CustomMatchers.isWebUri;
-import static org.openyolo.api.internal.CustomMatchers.nullOr;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.protocol.internal.CustomMatchers.isWebUri;
+import static org.openyolo.protocol.internal.CustomMatchers.nullOr;
+import static org.openyolo.protocol.internal.StringUtil.nullifyEmptyString;
 import static org.valid4j.Assertive.require;
@@ -29,324 +30,353 @@ import android.text.TextUtils;
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.Map;
-import org.openyolo.api.internal.CollectionConverter;
-import org.openyolo.api.internal.KeyValuePairConverters;
-import org.openyolo.proto.KeyValuePair;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
 
 /**
  * A representation of a credential for use in sign-in or sign-up. This provides a
- * higher-level, data-verifying wrapper for the underlying {@link org.openyolo.proto.Credential
+ * higher-level, data-verifying wrapper for the underlying {@link Protobufs.Credential
  * protocol buffer} that is returned by the app.
  *
  * <p>Credentials must have an {@link #getIdentifier() identifier},
  * an {@link #getAuthenticationMethod() authentication method} and an
  * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
  */
 public final class Credential implements Parcelable {
 
     /**
      * Parcelable reader for {@link Credential} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<Credential> CREATOR = new CredentialCreator();
 
     @NonNull
-    private final org.openyolo.proto.Credential mProto;
+    private final Protobufs.Credential mProto;
 
     /**
      * Deserializes and validates a credential protocol buffer.
      * @throws IOException if the credential is invalid.
      */
     public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
         return new Credential.Builder(
-                org.openyolo.proto.Credential.ADAPTER.decode(credentialProtoBytes))
+                Protobufs.Credential.parseFrom(credentialProtoBytes))
                 .build();
     }
 
-    private Credential(@NonNull org.openyolo.proto.Credential proto) {
+    private Credential(@NonNull Protobufs.Credential proto) {
         mProto = proto;
     }
 
     /**
      * The underlying protocol buffer form of the credential.
      */
-    public org.openyolo.proto.Credential getProto() {
+    @NonNull
+    public Protobufs.Credential getProto() {
         return mProto;
     }
 
     /**
      * The credential identifier, which is typically unique within the authentication domain.
      * Must be non-empty.
      */
     @NonNull
     public String getIdentifier() {
-        return mProto.id;
+        return mProto.getId();
     }
 
     /**
      * The authentication domain against which this credential can be used, if specified.
      */
-    @NonNull
+    @Nullable
     public AuthenticationDomain getAuthenticationDomain() {
-        return new AuthenticationDomain(mProto.authDomain);
+        String authDomainStr = nullifyEmptyString(mProto.getAuthDomain());
+        if (authDomainStr == null) {
+            return null;
+        }
+
+        return new AuthenticationDomain(mProto.getAuthDomain());
     }
 
     /**
      * The credential password, if defined. Must be non-empty, but any further restrictions are
      * the responsibility of the authentication domain to define and validate.
      */
     @Nullable
     public String getPassword() {
-        return mProto.password;
+        return nullifyEmptyString(mProto.getPassword());
     }
 
     /**
      * The display name for the credential, if defined. This is typically the user's
      * full name or an alias for the account that will be recognizable and distinguishable between
      * multiple credentials that the user may have.
      */
     @Nullable
     public String getDisplayName() {
-        return mProto.displayName;
+        return nullifyEmptyString(mProto.getDisplayName());
     }
 
     /**
      * The display picture for the credential, if defined. This is typically a picture of the
      * user, or some chosen avatar for the account that will be recognizable and distinguishable
      * between multiple credentials that the user may have.
      */
     @Nullable
     public Uri getDisplayPicture() {
-        return (mProto.displayPictureUri != null)
-                ? Uri.parse(mProto.displayPictureUri)
+        String displayPictureUriStr = nullifyEmptyString(mProto.getDisplayPictureUri());
+        return (displayPictureUriStr != null)
+                ? Uri.parse(displayPictureUriStr)
                 : null;
     }
 
     /**
      * The authentication method for the credential, which describes the mechanism by which
      * it should be verified by the receiving app. This may be any valid URI, but is typically
      * one of the {@link AuthenticationMethods standard values}.
      */
     @NonNull
     public Uri getAuthenticationMethod() {
-        return Uri.parse(mProto.authMethod);
+        return Uri.parse(mProto.getAuthMethod());
     }
 
     /**
      * Additional, non-standard properties associated with the credential.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalProperties() {
-        Map<String, byte[]> additionalProps = new HashMap<>();
-
-        for (KeyValuePair pair : mProto.additionalProps) {
-            byte[] value = pair.value != null ? pair.value.toByteArray() : null;
-            additionalProps.put(pair.name, value);
-        }
-
-        return additionalProps;
+        return CollectionConverter.convertMapValues(
+            mProto.getAdditionalPropsMap(),
+            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
-        byte[] encoded = org.openyolo.proto.Credential.ADAPTER.encode(mProto);
+        byte[] encoded = mProto.toByteArray();
         dest.writeInt(encoded.length);
         dest.writeByteArray(encoded);
     }
 
     /**
      * Creates instances of {@link Credential}.
      */
     public static final class Builder {
 
-        private org.openyolo.proto.Credential.Builder mProtoBuilder;
+        private Protobufs.Credential.Builder mProtoBuilder;
 
         /**
          * Starts the process of creating a credential, based on the properties of the
          * provided protocol buffer representation of the credential. The protocol buffer
          * must contain valid data for a credential.
          */
-        public Builder(@NonNull org.openyolo.proto.Credential proto) {
-            mProtoBuilder = new org.openyolo.proto.Credential.Builder();
+        public Builder(@NonNull Protobufs.Credential proto) {
+            mProtoBuilder = Protobufs.Credential.newBuilder();
 
             // required properties
-            setIdentifier(proto.id);
-            setAuthenticationDomain(new AuthenticationDomain(proto.authDomain));
-            setAuthenticationMethod(proto.authMethod);
+            setIdentifier(proto.getId());
+            setAuthenticationDomain(new AuthenticationDomain(proto.getAuthDomain()));
+            setAuthenticationMethod(proto.getAuthMethod());
 
             // optional properties
-            setDisplayName(proto.displayName);
-            setDisplayPicture(proto.displayPictureUri);
-            setPassword(proto.password);
+            setDisplayName(proto.getDisplayName());
+            setDisplayPicture(proto.getDisplayPictureUri());
+            setPassword(proto.getPassword());
             setAdditionalProperties(
-                    CollectionConverter.toMap(
-                            proto.additionalProps,
-                            KeyValuePairConverters.CONVERTER_KVP_TO_PAIR));
+                    CollectionConverter.convertMapValues(
+                            proto.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of creating a credential, with the mandatory identifier,
          * authentication method and authentication domain. To create a credential for your
          * own application, do:
          *
          * <pre>{@code
          * Credential cr = new Credential.Builder(
          *     id,
          *     authMethod,
          *     AuthenticationDomain.getSelfAuthDomain(context))
          *     .setPassword(pass)
          *     ...
          *     .build();
          * }</pre>
          * @param identifier the identifier for the credential. Must not be null or empty.
          */
         public Builder(
                 @NonNull String identifier,
                 @NonNull Uri authenticationMethod,
                 @NonNull AuthenticationDomain authenticationDomain) {
-            mProtoBuilder = new org.openyolo.proto.Credential.Builder();
+            mProtoBuilder = Protobufs.Credential.newBuilder();
             setIdentifier(identifier);
             setAuthenticationMethod(authenticationMethod);
             setAuthenticationDomain(authenticationDomain);
         }
 
         /**
-         * Specifies the identifier for the credential. The provided value must not be null or
-         * empty.
+         * Starts the process of creating a credential, with the mandatory identifier,
+         * authentication method (as a string) and authentication domain (as a string). To create
+         * a credential for your own application.
+         *
+         * @see #Builder(String, Uri, AuthenticationDomain)
+         */
+        public Builder(
+                @NonNull String identifier,
+                @NonNull String authenticationMethod,
+                @NonNull String authenticationDomain) {
+            this(identifier,
+                    Uri.parse(authenticationMethod),
+                    new AuthenticationDomain(authenticationDomain));
+        }
+
+        /**
+         * Specifies the identifier for the credential. The provided value must be non-null
+         * and non-empty.
          */
         @NonNull
         public Builder setIdentifier(@NonNull String identifier) {
-            require(!TextUtils.isEmpty(identifier), "identifer must not be null or empty");
-            mProtoBuilder.id = identifier;
+            require(!TextUtils.isEmpty(identifier), "identifier must not be null or empty");
+            mProtoBuilder.setId(identifier);
             return this;
         }
 
         /**
-         * Specifies the authentication domain against which this credential is valid.
+         * Specifies the authentication domain against which this credential is valid. The provided
+         * value must be non-null.
          */
         @NonNull
         public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
             require(domain, notNullValue());
-            mProtoBuilder.authDomain = extractString(domain);
+            mProtoBuilder.setAuthDomain(extractString(domain));
             return this;
         }
 
         /**
          * Specifies the authentication method for verifying the credential. This may be any
          * URI of form {@code scheme://authority}, but is typically one of the
          * {@link AuthenticationMethods standard values}.
          */
         @NonNull
-        public Builder setAuthenticationMethod(@NonNull Uri provider) {
-            require(provider, isValidAuthenticationMethod());
-            mProtoBuilder.authMethod = extractString(provider);
+        public Builder setAuthenticationMethod(@NonNull Uri authMethod) {
+            require(authMethod, isValidAuthenticationMethod());
+            mProtoBuilder.setAuthMethod(extractString(authMethod));
             return this;
         }
 
         /**
          * Specifies the authentication method for the credential, in string form for convenience.
+         * The provided value must be non-null and non-empty.
          * @see #setAuthenticationMethod(Uri)
          */
         @NonNull
-        public Builder setAuthenticationMethod(@NonNull String provider) {
-            return setAuthenticationMethod(Uri.parse(provider));
+        public Builder setAuthenticationMethod(@NonNull String authMethod) {
+            require(!TextUtils.isEmpty(authMethod), "authMethod must not be null or empty");
+            return setAuthenticationMethod(Uri.parse(authMethod));
         }
 
         /**
-         * Specifies the password for the credential. If a non-null value is provided, it must
-         * not be empty.
+         * Specifies the password for the credential. If a null or empty value is provided, this
+         * is equivalent to removing the password from the credential.
          */
         @NonNull
         public Builder setPassword(@Nullable String password) {
-            if (password != null) {
-                require(!TextUtils.isEmpty(password), "password must be null or not empty");
+            if (nullifyEmptyString(password) == null) {
+                mProtoBuilder.clearPassword();
+            } else {
+                mProtoBuilder.setPassword(password);
             }
-            mProtoBuilder.password = password;
+
             return this;
         }
 
         /**
-         * Specifies the display name for the credential. If a non-null value is provided, it
-         * must not be empty.
+         * Specifies the display name for the credential. If a null or empty value is provided,
+         * this is equivalent to removing the display name from the credential.
          */
         @NonNull
         public Builder setDisplayName(@Nullable String displayName) {
-            if (displayName != null) {
-                require(!TextUtils.isEmpty(displayName),
-                        "display name must be null or not empty");
+            if (nullifyEmptyString(displayName) == null) {
+                mProtoBuilder.clearDisplayName();
+            } else {
+                mProtoBuilder.setDisplayName(displayName);
             }
-            mProtoBuilder.displayName = displayName;
             return this;
         }
 
         /**
-         * Specifies the display picture for the credential, which must be a HTTP or HTTPS URI
-         * to an image resource.
+         * Specifies the display picture for the credential. If a null value is provided, this
+         * is equivalent to removing the display picture from the credential. If a non-null
+         * value is provided, it must be an HTTP or HTTPS URI to an image resource.
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable Uri displayPicture) {
             require(displayPicture, nullOr(isWebUri()));
-            mProtoBuilder.displayPictureUri = extractString(displayPicture);
+            if (displayPicture == null) {
+                mProtoBuilder.clearDisplayPictureUri();
+            } else {
+                mProtoBuilder.setDisplayPictureUri(extractString(displayPicture));
+            }
             return this;
         }
 
         /**
          * Specifies the display picture for the credential, in string form for convenience.
          * @see #setDisplayPicture(Uri)
          */
         @NonNull
         public Builder setDisplayPicture(@Nullable String displayPicture) {
             return setDisplayPicture(
-                    displayPicture != null ? Uri.parse(displayPicture) : null);
+                    nullifyEmptyString(displayPicture) != null ? Uri.parse(displayPicture) : null);
         }
 
         /**
          * Specifies any additional, non-standard properties associated with the credential.
          */
         public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
-            mProtoBuilder.additionalProps = CollectionConverter.toList(
-                    additionalProps.entrySet(),
-                    KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP);
+            if (mProtoBuilder.getAdditionalPropsCount() > 0) {
+                mProtoBuilder.clearAdditionalProps();
+            }
+            mProtoBuilder.putAllAdditionalProps(
+                    CollectionConverter.convertMapValues(
+                            additionalProps,
+                            ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING));
             return this;
         }
 
         /**
          * Creates the {@link Credential credential} instance with all properties specified.
          */
         @NonNull
         public Credential build() {
             return new Credential(mProtoBuilder.build());
         }
 
         private String extractString(@Nullable Object obj) {
             return (obj != null) ? obj.toString() : null;
         }
     }
 
     static final class CredentialCreator implements Creator<Credential> {
         @Override
         public Credential createFromParcel(Parcel source) {
             int encodedLength = source.readInt();
             byte[] encodedBytes = new byte[encodedLength];
             source.readByteArray(encodedBytes);
 
             try {
-                org.openyolo.proto.Credential proto =
-                        org.openyolo.proto.Credential.ADAPTER.decode(encodedBytes);
+                Protobufs.Credential proto = Protobufs.Credential.parseFrom(encodedBytes);
                 return new Credential(proto);
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to decode credential proto", ex);
             }
         }
 
         @Override
         public Credential[] newArray(int size) {
             return new Credential[0];
         }
     }
 }
diff --git a/api/java/org/openyolo/api/HintRequest.java b/protocol/java/org/openyolo/protocol/HintRequest.java
similarity index 76%
rename from api/java/org/openyolo/api/HintRequest.java
rename to protocol/java/org/openyolo/protocol/HintRequest.java
index 00aa98d..cd6086d 100644
--- a/api/java/org/openyolo/api/HintRequest.java
+++ b/protocol/java/org/openyolo/protocol/HintRequest.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -20,13 +20,8 @@ import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.api.internal.CollectionConverter.toList;
-import static org.openyolo.api.internal.CollectionConverter.toMap;
-import static org.openyolo.api.internal.CollectionConverter.toSet;
-import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationDomain;
-import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationMethod;
-import static org.openyolo.api.internal.CustomMatchers.isValidIdentifierType;
-import static org.openyolo.api.internal.CustomMatchers.notNullOrEmptyString;
-import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP;
-import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_KVP_TO_PAIR;
-import static org.openyolo.api.internal.UriConverters.CONVERTER_STRING_TO_URI;
-import static org.openyolo.api.internal.UriConverters.CONVERTER_URI_TO_STRING;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationDomain;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidIdentifierType;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.openyolo.protocol.internal.UriConverters.CONVERTER_STRING_TO_URI;
+import static org.openyolo.protocol.internal.UriConverters.CONVERTER_URI_TO_STRING;
 import static org.valid4j.Assertive.require;
@@ -44,428 +39,442 @@ import java.util.Map;
 import java.util.Set;
-import org.openyolo.api.internal.NoopValueConverter;
-import org.openyolo.api.internal.UriConverters;
-import org.openyolo.proto.HintRetrieveRequest;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.NoopValueConverter;
+import org.openyolo.protocol.internal.UriConverters;
 
 /**
  * A request for a login hint, to be sent to credential providers on the device. Hints provide
  * the basic set of information that can help with account creation, or re-discovering an
  * existing account.
  */
 public class HintRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link HintRequest} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<HintRequest> CREATOR = new HintRequestCreator();
 
     @NonNull
     private final Set<Uri> mAuthMethods;
 
     @NonNull
     private final Set<Uri> mIdTypes;
 
     @NonNull
     private final PasswordSpecification mPasswordSpec;
 
     @NonNull
-    private final Map<String, byte[]> mAdditionalParams;
+    private final Map<String, byte[]> mAdditionalProperties;
 
     /**
      * Creates a hint request for email and password based accounts.
      */
     public static HintRequest forEmailAndPasswordAccount() {
         return new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes(IdentifierTypes.EMAIL)
                 .build();
     }
 
     /**
      * Reads a hint request from its protocol buffer byte array form.
      * @throws IOException if the hint request could not be decoded.
      *
-     * @see {{@link #toProtocolBuffer()}}.
+     * @see #toProtocolBuffer().
      */
     @NonNull
     public static HintRequest fromProtoBytes(byte[] hintRequestProtoBytes)
             throws IOException {
         if (hintRequestProtoBytes == null) {
             throw new IOException("Unable to decode hint request from null array");
         }
         return new HintRequest.Builder(
-                org.openyolo.proto.HintRetrieveRequest.ADAPTER.decode(hintRequestProtoBytes))
+                Protobufs.HintRetrieveRequest.parseFrom(hintRequestProtoBytes))
                 .build();
     }
 
     private HintRequest(
             @NonNull Set<Uri> authMethods,
             @NonNull Set<Uri> idTypes,
             @NonNull PasswordSpecification passwordSpec,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mIdTypes = idTypes;
         mPasswordSpec = passwordSpec;
-        mAdditionalParams = additionalParams;
+        mAdditionalProperties = additionalParams;
     }
 
     /**
      * The set of authentication methods supported by the client for login.
      */
     @NonNull
     public Set<Uri> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The set of identifier types that the requester uses. This is used to filter the
      * set of hints to just those which are potentially usable. If no identifier type is
      * specified, then any identifier string can be returned.
      */
     @NonNull
     public Set<Uri> getIdentifierTypes() {
         return mIdTypes;
     }
 
     /**
      * A password specification which describes the "shape" of passwords that the requester
      * allows. This can be used for password generation by the credential provider, to
      * facilitate the creation of accounts with secure, unique passwords across all of the
      * user's accounts.
      */
     @NonNull
     public PasswordSpecification getPasswordSpecification() {
         return mPasswordSpec;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
-    public Map<String, byte[]> getAdditionalParameters() {
-        return mAdditionalParams;
+    public Map<String, byte[]> getAdditionalProperties() {
+        return mAdditionalProperties;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8
      * encoded string.
      */
     @Nullable
-    public String getAdditionalParameterAsString(@NonNull String key) {
+    public String getAdditionalPropertyAsString(@NonNull String key) {
         require(key, notNullValue());
-        if (mAdditionalParams.containsKey(key)) {
-            return new String(mAdditionalParams.get(key), Charset.forName("UTF-8"));
+        if (mAdditionalProperties.containsKey(key)) {
+            return new String(mAdditionalProperties.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
-    public byte[] getAdditionalParameter(@NonNull String key) {
+    public byte[] getAdditionalProperty(@NonNull String key) {
         require(key, notNullValue());
-        return mAdditionalParams.get(key);
+        return mAdditionalProperties.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
-        byte[] protoBytes = toProtocolBuffer().encode();
+        byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     @NonNull
-    public HintRetrieveRequest toProtocolBuffer() {
-        return new HintRetrieveRequest.Builder()
-                .authMethods(toList(mAuthMethods, CONVERTER_URI_TO_STRING))
-                .idTypes(toList(mIdTypes, CONVERTER_URI_TO_STRING))
-                .additionalParams(toList(mAdditionalParams.entrySet(), CONVERTER_ENTRY_TO_KVP))
-                .passwordSpec(mPasswordSpec.toProtocolBuffer())
+    public Protobufs.HintRetrieveRequest toProtocolBuffer() {
+        return Protobufs.HintRetrieveRequest.newBuilder()
+                .addAllAuthMethods(
+                        CollectionConverter.toList(mAuthMethods, CONVERTER_URI_TO_STRING))
+                .addAllIdTypes(CollectionConverter.toList(mIdTypes, CONVERTER_URI_TO_STRING))
+                .putAllAdditionalProps(
+                    CollectionConverter.convertMapValues(
+                            mAdditionalProperties,
+                        ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
+                .setPasswordSpec(mPasswordSpec.toProtocolBuffer())
                 .build();
     }
 
     /**
      * Creates {@link HintRequest} instances.
      */
     public static final class Builder {
 
         private Set<Uri> mAuthMethods = new HashSet<>();
         private Set<Uri> mIdTypes = new HashSet<>();
-        private Map<String, byte[]> mAdditionalParams = new HashMap<>();
+        private Map<String, byte[]> mAdditionalProps = new HashMap<>();
         private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
 
         /**
          * Recreates a hint request from its protocol buffer form.
          *
-         * @see {@link HintRequest#toProtocolBuffer()}
+         * @see HintRequest#toProtocolBuffer()
          */
-        public Builder(@NonNull HintRetrieveRequest requestProto) {
+        public Builder(@NonNull Protobufs.HintRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
-            setAuthenticationMethods(toSet(requestProto.authMethods, CONVERTER_STRING_TO_URI));
-            setIdentifierTypes(toSet(requestProto.idTypes, CONVERTER_STRING_TO_URI));
+            setAuthenticationMethods(CollectionConverter.toSet(
+                    requestProto.getAuthMethodsList(),
+                    CONVERTER_STRING_TO_URI));
+            setIdentifierTypes(CollectionConverter.toSet(
+                    requestProto.getIdTypesList(),
+                    CONVERTER_STRING_TO_URI));
             setPasswordSpecification(
-                    new PasswordSpecification.Builder(requestProto.passwordSpec).build());
-            setAdditionalParameters(toMap(requestProto.additionalParams, CONVERTER_KVP_TO_PAIR));
+                    new PasswordSpecification.Builder(requestProto.getPasswordSpec()).build());
+            setAdditionalProperties(
+                    CollectionConverter.convertMapValues(
+                            requestProto.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         public Builder(@NonNull Uri authMethod, @NonNull Uri... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         public Builder(@NonNull String authMethod, @NonNull String... additionalAuthMethods) {
             setAuthenticationMethods(authMethod, additionalAuthMethods);
         }
 
         /**
          * Starts the process of defining a hint request, specifying at least one supported
          * authentication method in string form.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         public Builder(@NonNull Set<Uri> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(
                 @NonNull Uri authMethod,
                 Uri... additionalAuthMethods) {
             setAuthenticationMethods(
-                    toSet(
+                    CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             NoopValueConverter.<Uri>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester, in string form. At
          * least one authentication method must be specified.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         public Builder setAuthenticationMethods(
                 @NonNull String authMethod,
                 @NonNull String... additionalAuthMethods) {
             setAuthenticationMethods(
-                    toSet(
+                    CollectionConverter.toSet(
                             authMethod,
                             additionalAuthMethods,
                             UriConverters.CONVERTER_STRING_TO_URI));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be specified.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
             require(authMethods, notNullValue());
             require(!authMethods.isEmpty(), "At least one authentication method must be specified");
             require(authMethods, everyItem(isValidAuthenticationMethod()));
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Adds an authentication method (in string form) supported by the requester.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull String authMethodStr) {
             require(authMethodStr, notNullOrEmptyString());
             addAuthenticationMethod(Uri.parse(authMethodStr));
             return this;
         }
 
         /**
          * Adds an authentication method supported by the requester.
          *
-         * @see {@link AuthenticationMethods}
+         * @see AuthenticationMethods
          */
         @NonNull
         public Builder addAuthenticationMethod(@NonNull Uri authenticationMethod) {
             require(authenticationMethod, isValidAuthenticationDomain());
             mAuthMethods.add(authenticationMethod);
             return this;
         }
 
         /**
          * Specifies the identifier types that the requester supports. If no identifier types
          * are specified, then credentials with any form of identifier can be returned.
          *
-         * @see {@link IdentifierTypes}
+         * @see IdentifierTypes
          */
         @NonNull
         public Builder setIdentifierTypes(@NonNull String... idTypes) {
             setIdentifierTypes(
-                    toSet(null, idTypes, UriConverters.CONVERTER_STRING_TO_URI));
+                    CollectionConverter.toSet(
+                            idTypes,
+                            UriConverters.CONVERTER_STRING_TO_URI));
             return this;
         }
 
         /**
          * Specifies the identifier types that the requester supports. If no identifier types
          * are specified, then credentials with any form of identifier can be returned.
          *
-         * @see {@link IdentifierTypes}
+         * @see IdentifierTypes
          */
         @NonNull
         public Builder setIdentifierTypes(@NonNull Uri... idTypes) {
             setIdentifierTypes(
-                    toSet(null, idTypes, NoopValueConverter.<Uri>getInstance()));
+                    CollectionConverter.toSet(idTypes, NoopValueConverter.<Uri>getInstance()));
             return this;
         }
 
         /**
          * Specifies the identifier types that the requester supports. If no identifier types
          * are specified, then credentials with any form of identifier can be returned.
          *
-         * @see {@link IdentifierTypes}
+         * @see IdentifierTypes
          */
         @NonNull
         public Builder setIdentifierTypes(@NonNull Set<Uri> identifierTypes) {
             require(identifierTypes, notNullValue());
             require(identifierTypes, everyItem(isValidIdentifierType()));
             mIdTypes = identifierTypes;
             return this;
         }
 
         /**
          * Adds a supported identifier type to the hint request.
          *
-         * @see {@link IdentifierTypes}
+         * @see IdentifierTypes
          */
         @NonNull
         public Builder addIdentifierType(@NonNull String identifierTypeStr) {
             require(identifierTypeStr, notNullOrEmptyString());
             addIdentifierType(Uri.parse(identifierTypeStr));
             return this;
         }
 
         /**
          * Adds a supported identifier type to the hint request.
          *
-         * @see {@link IdentifierTypes}
+         * @see IdentifierTypes
          */
         @NonNull
         public Builder addIdentifierType(@NonNull Uri identifierType) {
             require(identifierType, isValidIdentifierType());
             mIdTypes.add(identifierType);
             return this;
         }
 
         /**
          * Specifies additional, non-standard hint request parameters. The provided map
          * must be non-null, and contain only non-empty keys and non-null values.
          */
         @NonNull
-        public Builder setAdditionalParameters(@NonNull Map<String, byte[]> additionalParams) {
+        public Builder setAdditionalProperties(@NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
-            mAdditionalParams = additionalParams;
+            mAdditionalProps = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request with a string value, that
          * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
          * key must be non-empty.
          */
         @NonNull
-        public Builder addAdditionalParameter(@NonNull String name, @NonNull String value) {
+        public Builder addAdditionalProperty(@NonNull String name, @NonNull String value) {
             require(value, notNullValue());
-            addAdditionalParameter(name, value.getBytes(Charset.forName("UTF-8")));
+            addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional, non-standard parameter to the hint request, that will be encoded as
          * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
          */
         @NonNull
-        public Builder addAdditionalParameter(@NonNull String name, @NonNull byte[] value) {
+        public Builder addAdditionalProperty(@NonNull String name, @NonNull byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
-            mAdditionalParams.put(name, value);
+            mAdditionalProps.put(name, value);
             return this;
         }
 
         /**
          * Specifies the "shape" of passwords that the requester supports. This will be used
          * for password generation by the credential provider. If no value is explicitly provided,
          * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
          */
         @NonNull
         public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
             require(passwordSpec, notNullValue());
             mPasswordSpec = passwordSpec;
             return this;
         }
 
         /**
          * Creates a {@link HintRequest} with the properties specified on the builder.
          */
         @NonNull
         public HintRequest build() {
             return new HintRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableSet(mIdTypes),
                     mPasswordSpec,
-                    unmodifiableMap(mAdditionalParams));
+                    unmodifiableMap(mAdditionalProps));
         }
     }
 
     private static final class HintRequestCreator implements Creator<HintRequest> {
         @Override
         public HintRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new HintRequest.Builder(
-                        HintRetrieveRequest.ADAPTER.decode(protoBytes))
+                        Protobufs.HintRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public HintRequest[] newArray(int size) {
             return new HintRequest[size];
         }
     }
 }
diff --git a/api/java/org/openyolo/api/IdentifierTypes.java b/protocol/java/org/openyolo/protocol/IdentifierTypes.java
similarity index 98%
rename from api/java/org/openyolo/api/IdentifierTypes.java
rename to protocol/java/org/openyolo/protocol/IdentifierTypes.java
index 411e0b4..f70e4b8 100644
--- a/api/java/org/openyolo/api/IdentifierTypes.java
+++ b/protocol/java/org/openyolo/protocol/IdentifierTypes.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
diff --git a/api/java/org/openyolo/api/PasswordSpecification.java b/protocol/java/org/openyolo/protocol/PasswordSpecification.java
similarity index 95%
rename from api/java/org/openyolo/api/PasswordSpecification.java
rename to protocol/java/org/openyolo/protocol/PasswordSpecification.java
index 4bca5c3..4e56973 100644
--- a/api/java/org/openyolo/api/PasswordSpecification.java
+++ b/protocol/java/org/openyolo/protocol/PasswordSpecification.java
@@ -14,6 +14,6 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.api.internal.Constants.HASH_PRIME;
+import static org.openyolo.protocol.internal.InternalConstants.HASH_PRIME;
 import static org.valid4j.Assertive.require;
@@ -40,791 +40,791 @@ import java.util.TreeSet;
 /**
  * Specification of an acceptable set of passwords, expressed in terms of allowed and required
  * sets of characters and a size range. Only ASCII printable characters are supported.
  *
  * <p>
  * Example Specifications:
  *
  * <ul>
  *     <li>
  *     A 12-16 character password that must contain at least one digit and one upper-case letter:
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .ofLength(12, 16)
  *             .allow(ALL_PRINTABLE)
  *             .require(NUMERALS, 1)
  *             .require(UPPER_ALPHA, 1)
  *             .build();
  *     }
  *     </li>
  *     <li>
  *     A 6-digit pin number:
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .allow(NUMERALS)
  *             .ofLength(6,6)
  *             .build();
  *     }
  *     </li>
  *     <li>
  *     An 8-12 character password permitting only alphanumeric characters
  *     {@code
  *     new PasswordSpecification.Builder()
  *             .ofLength(8,12)
  *             .allow(LOWER_ALPHA)
  *             .allow(UPPER_ALPHA)
  *             .allow(NUMERALS)
  *             .build();
  *     }
  *     </li>
  * </ul>
  * </p>
  */
 public final class PasswordSpecification implements Parcelable {
 
     /**
      * Parcelable {@link android.os.Parcelable.Creator Creator} for PasswordSpecification instances.
      */
     public static final Creator<PasswordSpecification> CREATOR = new PasswordSpecificationCreator();
 
     /**
      * The set of lower case ASCII characters (a-z).
      */
     public static final String LOWER_ALPHA = "abcdefghijklmnopqrstuvwxyz";
 
     /**
      * The set of lower case ASCII characters, omitting those which are difficult to distinguish
      * from other alphanumeric characters. The omitted characters are:
      * <ul>
      * <li>l (lima), often confused with 1 (one) and I (india, upper case)</li>
      * <li>u (uniform), often confused with v (victor)</li>
      * <li>v (victor), often confused with u (uniform)</li>
      * <li>w (whiskey), often confused with vv (victor victor)</li>
      * </ul>
      */
     public static final String LOWER_ALPHA_DISTINGUISHABLE = "abcdefghijkmnopqrstxyz";
 
     /**
      * The set of upper case ASCII characters (A-Z).
      */
     public static final String UPPER_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
     /**
      * The set of upper case ASCII characters, omitting those which can be difficult to distinguish
      * from other alphanumeric characters. The omitted characters are:
      * <ul>
      * <li>I (india), often confused with 1 (one) and l (lima, lower case)</li>
      * <li>O (oscar), often confused with 0 (zero)</li>
      * <li>U (uniform), often confused with v (victor)</li>
      * <li>V (victor), often confused with u (uniform)</li>
      * <li>W (whiskey), often confused with vv (victor victor)</li>
      * <li>Z (zulu), often confused with 2 (two)</li>
      * </ul>
      */
     public static final String UPPER_ALPHA_DISTINGUISHABLE = "ABCDEFGHJKLMNPQRSTXY";
 
     /**
      * The set of ASCII numerals (0-9).
      */
     public static final String NUMERALS = "1234567890";
 
     /**
      * The set of ASCII numerals, omitting those which can be difficult to distinguish from other
      * alphanumeric characters. The omitted characters are:
      * <ul>
      * <li>0 (zero), often confused with O (oscar, upper case)</li>
      * <li>1 (one), often confused with I (india, upper case) and l (lima, lower case)</li>
      * <li>2 (two), often confused with Z (zulu, upper case)</li>
      * </ul>
      */
     public static final String NUMERALS_DISTINGUISHABLE = "3456789";
 
     /**
      * The set of all alpha-numeric ASCII characters (a-z, A-Z, 0-9).
      */
     public static final String ALPHANUMERIC = LOWER_ALPHA + UPPER_ALPHA + NUMERALS;
 
     /**
      * The set of all printable ASCII symbols.
      */
     public static final String SYMBOLS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
 
     /**
      * The set of all printable ASCII characters.
      */
     public static final String ALL_PRINTABLE =
             LOWER_ALPHA + UPPER_ALPHA + NUMERALS + SYMBOLS;
 
     /**
      * The set of all alphanumeric characters (and space) which are easily
      * distinguished. Specifically, this excludes:
      * <ul>
      * <li>I (india, upper case), often confused with 1 (one) and l (lima, lower case)</li>
      * <li>l (lima, lower case), often confused with 1 (one) and I (india, upper case)</li>
      * <li>O (oscar, upper case), often confused with 0 (zero)</li>
      * <li>U (uniform, lower and upper case), often confused with v (victor)</li>
      * <li>V (victor, lower and upper case), often confused with u (uniform)</li>
      * <li>W (whiskey, lower and upper case), often confused with vv (victor victor)</li>
      * <li>Z (zulu), often confused with 2 (two)</li>
      * <li>0 (zero), often confused with O (oscar, upper case)</li>
      * <li>1 (one), often confused with I (india, upper case) and l (lima, lower case)</li>
      * <li>2 (two), often confused with Z (zulu, upper case)</li>
      * </ul>
      */
     public static final String ALPHANUMERIC_DISTINGUISHABLE =
             LOWER_ALPHA_DISTINGUISHABLE + UPPER_ALPHA_DISTINGUISHABLE + NUMERALS_DISTINGUISHABLE;
 
     /**
      * The minimum password length used by {@link #DEFAULT PasswordSpecification.DEFAULT}.
      */
     public static final int DEFAULT_MIN_PASSWORD_LENGTH = 12;
 
     /**
      * The maximum password length used by {@link #DEFAULT PasswordSpecification.DEFAULT}.
      */
     public static final int DEFAULT_MAX_PASSWORD_LENGTH = 16;
 
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({PASSWORD_CONFORMS,
             PASSWORD_LENGTH_MISMATCH,
             PASSWORD_REQUIRED_CHARACTER_MISSING,
             PASSWORD_DISALLOWED_CHARACTER})
     public @interface ConformanceMask {}
 
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({PASSWORD_LENGTH_MISMATCH,
             PASSWORD_REQUIRED_CHARACTER_MISSING,
             PASSWORD_DISALLOWED_CHARACTER})
     public @interface ConformanceError {}
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password conforms to the specification.
      */
     public static final int PASSWORD_CONFORMS = 0B0000;
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password is not within the required size bounds.
      */
     public static final int PASSWORD_LENGTH_MISMATCH = 0B0001;
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password is missing one or more required characters.
      */
     public static final int PASSWORD_REQUIRED_CHARACTER_MISSING = 0B0010;
 
     /**
      * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
      * that indicates that the supplied password contains a disallowed character.
      */
     public static final int PASSWORD_DISALLOWED_CHARACTER = 0B0100;
 
     /**
      * The default password specification used by the credentials API when no alternative is
      * provided. This specification should be compatible with the majority of password based
      * authentication systems and has sufficient entropy to be secure against offline attacks.
      * The specification permits passwords between 12 and 16 characters in length, composed of at
      * least one lower case letter, one upper case letter, and one numeral. All other characters
      * must be alphanumeric.
      *
      * <p>Characters which are difficult to distinguish are disallowed in this specification,
      * as it is tailored towards password generation rather than validation - see
      * {@link #DEFAULT_FOR_VALIDATION} for a password specification suited to validating user
      * entered passwords.
      */
     public static final PasswordSpecification DEFAULT = new PasswordSpecification.Builder()
             .ofLength(DEFAULT_MIN_PASSWORD_LENGTH, DEFAULT_MAX_PASSWORD_LENGTH)
             .allow(ALPHANUMERIC_DISTINGUISHABLE)
             .require(LOWER_ALPHA_DISTINGUISHABLE, 1)
             .require(UPPER_ALPHA_DISTINGUISHABLE, 1)
             .require(NUMERALS_DISTINGUISHABLE, 1)
             .build();
 
     /**
      * A default password specification, intended for use in validating user entered passwords.
      * This differs from {@link #DEFAULT} in that characters which are difficult to distinguish
      * are permitted.
      */
     public static final PasswordSpecification DEFAULT_FOR_VALIDATION =
             new PasswordSpecification.Builder()
                     .ofLength(DEFAULT_MIN_PASSWORD_LENGTH, DEFAULT_MAX_PASSWORD_LENGTH)
                     .allow(ALPHANUMERIC)
                     .require(LOWER_ALPHA, 1)
                     .require(UPPER_ALPHA, 1)
                     .require(NUMERALS, 1)
                     .build();
 
     private static final int ASCII_PRINTABLE_RANGE_LOWER = 32;
     private static final int ASCII_PRINTABLE_RANGE_UPPER = 126;
 
     /**
      * Utility method to check if the password is conformant to the specification defined.
      * @param result the result of the @link #checkConformance(String) checkConformance} method.
      * @return true if password is conforming to specs.
      */
     public static boolean checkResultForError(final int result, @ConformanceError final int mask) {
         return (result & mask) != 0;
     }
 
     /**
      * The set of allowed characters, represented as a string.
      */
     public final String allowedChars;
 
     /**
      * The required character sets for this specification.
      */
     public final SortedSet<RequiredCharSet> requiredCharSets;
 
     /**
      * The maximum acceptable size of a password.
      */
     public final int minimumSize;
 
     /**
      * The minimum acceptable size of a password.
      */
     public final int maximumSize;
 
     // the below fields are created on-demand, and are not serialized. They should not be
     // directly referenced, instead, use the associated getters to ensure they are correctly
     // instantiated.
     private Integer mHash;
     private Random mRandom;
     private int[] mRequiredSpecMapping;
     private int[] mRequiredCharCounts;
 
     private PasswordSpecification(
             String allowedChars,
             SortedSet<RequiredCharSet> requiredCharSets,
             int minimumSize,
             int maximumSize) {
         this.allowedChars = allowedChars;
         this.requiredCharSets = Collections.unmodifiableSortedSet(requiredCharSets);
         this.minimumSize = minimumSize;
         this.maximumSize = maximumSize;
     }
 
     /**
      * Determines whether the provided password conforms to the specification.
      *
      * @return a bit field which represents the status of the checks on this password.
      *     values are {@link #PASSWORD_CONFORMS} - 0 if the password conforms to the specification.
      *     Otherwise, an error code will be returned in the form of a bit field.
      *     (one comprised of the of the bits representing issues with this password
      *     {@link #PASSWORD_LENGTH_MISMATCH},
      *     {@link #PASSWORD_DISALLOWED_CHARACTER} or
      *     {@link #PASSWORD_REQUIRED_CHARACTER_MISSING}).
      *
      *     @see <a href="https://en.wikipedia.org/wiki/Bit_field">Bit Field</a> -
      *     A bit field is a data structure used in computer programming, to store information in
      *     the bits of a byte.
      */
     @ConformanceMask
     public int checkConformance(String password) {
         int result = PASSWORD_CONFORMS;
         if (TextUtils.isEmpty(password)) {
             result |= PASSWORD_LENGTH_MISMATCH;
         }
 
         if (isOutsideRange(password.length(), minimumSize, maximumSize)) {
             result |= PASSWORD_LENGTH_MISMATCH;
         }
 
         // in order to check the required and allowed characters, we attempt to match
         // each character against a required character set. If the requisite number of
         // characters have been matched against that required set, then they are checked
         // to see if they are allowed beyond this count (which allows for password
         // specifications with exact required counts, by having a disjoint set of
         // required characters from allowed characters).
         int[] requiredSpecMapping = getRequiredSpecMapping();
         int[] requiredSpecRemainingCounts = extractRequiredCharCounts();
 
         for (char c : password.toCharArray()) {
             if (!containsCharacter(allowedChars, c)) {
                 result |= PASSWORD_DISALLOWED_CHARACTER;
             }
 
             int requiredSpecIndex = requiredSpecMapping[getCharMappingIndex(c)];
             if (requiredSpecIndex >= 0) {
                 requiredSpecRemainingCounts[requiredSpecIndex]--;
             }
         }
 
         for (int remaining : requiredSpecRemainingCounts) {
             if (remaining > 0) {
                 result |= PASSWORD_REQUIRED_CHARACTER_MISSING;
                 break;
             }
         }
 
         return result;
     }
 
     /**
      * Generates a random password in conformance with the specification.
      */
     @NonNull
     public String generate() {
         int size = minimumSize + getRandom().nextInt(maximumSize - minimumSize + 1);
         ArrayList<Character> chars = new ArrayList<>(size);
 
         // select all the required characters
         for (RequiredCharSet set : requiredCharSets) {
             selectCharacters(set.chars, set.count, chars);
         }
 
         // select all remaining characters from the allowed characters set
         int remaining = size - chars.size();
         selectCharacters(allowedChars, remaining, chars);
 
         // randomly shuffle the characters, so the required characters do not occur in a
         // predictable position
         Collections.shuffle(chars);
         return charCollectionToString(chars);
     }
 
     /**
      * Translates the specification into a protocol buffer, for transmission or storage.
      */
     @NonNull
-    public org.openyolo.proto.PasswordSpecification toProtocolBuffer() {
-        return new org.openyolo.proto.PasswordSpecification.Builder()
-                .minSize(minimumSize)
-                .maxSize(maximumSize)
-                .allowed(allowedChars)
-                .requiredSets(convertRequiredCharSetsToProto())
+    public Protobufs.PasswordSpecification toProtocolBuffer() {
+        return Protobufs.PasswordSpecification.newBuilder()
+                .setMinSize(minimumSize)
+                .setMaxSize(maximumSize)
+                .setAllowed(allowedChars)
+                .addAllRequiredSets(convertRequiredCharSetsToProto())
                 .build();
     }
 
     @Override
     public void writeToParcel(Parcel out, int flags) {
-        byte[] encoded = toProtocolBuffer().encode();
+        byte[] encoded = toProtocolBuffer().toByteArray();
         out.writeInt(encoded.length);
         out.writeByteArray(encoded);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (obj == null || !(obj instanceof PasswordSpecification)) {
             return false;
         }
 
         PasswordSpecification other = (PasswordSpecification)obj;
 
         if (this.minimumSize != other.minimumSize
                 || this.maximumSize != other.maximumSize
                 || !this.allowedChars.equals(other.allowedChars)) {
             return false;
         }
 
         if (this.requiredCharSets.size() != other.requiredCharSets.size()) {
             return false;
         }
 
         Iterator<RequiredCharSet> thisRequiredSetIter = this.requiredCharSets.iterator();
         Iterator<RequiredCharSet> otherRequiredSetIter = other.requiredCharSets.iterator();
 
         while (thisRequiredSetIter.hasNext()) {
             if (!thisRequiredSetIter.next().equals(otherRequiredSetIter.next())) {
                 return false;
             }
         }
 
         return true;
     }
 
     @Override
     public int hashCode() {
         if (mHash != null) {
             return mHash;
         }
 
         int hash = minimumSize;
         hash = hash * HASH_PRIME + maximumSize;
         hash = hash * HASH_PRIME + allowedChars.hashCode();
 
         for (RequiredCharSet set : requiredCharSets) {
             hash = hash * HASH_PRIME + set.chars.hashCode();
             hash = hash * HASH_PRIME + set.count;
         }
 
         mHash = hash;
         return mHash;
     }
 
-    private List<org.openyolo.proto.RequiredCharSet> convertRequiredCharSetsToProto() {
-        List<org.openyolo.proto.RequiredCharSet> convertedRequiredCharSets = new ArrayList<>();
+    private List<Protobufs.RequiredCharSet> convertRequiredCharSetsToProto() {
+        List<Protobufs.RequiredCharSet> convertedRequiredCharSets = new ArrayList<>();
 
         for (RequiredCharSet set : requiredCharSets) {
             convertedRequiredCharSets.add(
-                    new org.openyolo.proto.RequiredCharSet.Builder()
-                            .chars(set.chars)
-                            .count(set.count)
+                    Protobufs.RequiredCharSet.newBuilder()
+                            .setChars(set.chars)
+                            .setCount(set.count)
                             .build());
         }
 
         return convertedRequiredCharSets;
     }
 
     /**
      * Extracts a mapping from an adjusted character index (where the lowest printable ascii
      * character is given index 0) to the required character spec that it corresponds to,
      * or -1 if the character is not part of any required set.
      */
     private int[] getRequiredSpecMapping() {
         if (mRequiredSpecMapping != null) {
             return mRequiredSpecMapping;
         }
 
         int[] requiredSpecMapping =
                 new int[ASCII_PRINTABLE_RANGE_UPPER - ASCII_PRINTABLE_RANGE_LOWER + 1];
         Arrays.fill(requiredSpecMapping, -1);
 
         int specIndex = 0;
         for (RequiredCharSet set : requiredCharSets) {
             for (char c : set.chars.toCharArray()) {
                 requiredSpecMapping[getCharMappingIndex(c)] = specIndex;
             }
             specIndex++;
         }
 
         mRequiredSpecMapping = requiredSpecMapping;
         return mRequiredSpecMapping;
     }
 
     /**
      * Determines the provided character's adjusted index in the required character spec mapping,
      * where the lowest printable ascii character is given index 0.
      */
     private static int getCharMappingIndex(char ch) {
         return ch - ASCII_PRINTABLE_RANGE_LOWER;
     }
 
     private void selectCharacters(String chars, int count, ArrayList<Character> result) {
         Random random = getRandom();
         for (int i = 0; i < count; i++) {
             result.add(chars.charAt(random.nextInt(chars.length())));
         }
     }
 
     private boolean containsCharacter(String chars, char ch) {
         int pos = Arrays.binarySearch(chars.toCharArray(), ch);
         return (pos >= 0 && pos < chars.length() && chars.charAt(pos) == ch);
     }
 
     private int[] extractRequiredCharCounts() {
         if (mRequiredCharCounts == null) {
             mRequiredCharCounts = new int[requiredCharSets.size()];
             int index = 0;
             for (RequiredCharSet set : requiredCharSets) {
                 mRequiredCharCounts[index] = set.count;
                 index++;
             }
         }
 
         int[] requiredCharCounts = new int[mRequiredCharCounts.length];
         System.arraycopy(
                 mRequiredCharCounts,
                 0, // source index
                 requiredCharCounts,
                 0, // destination index
                 mRequiredCharCounts.length);
         return requiredCharCounts;
     }
 
     private Random getRandom() {
         if (mRandom != null) {
             return mRandom;
         }
 
         mRandom = new SecureRandom();
         return mRandom;
     }
 
     private static String charCollectionToString(Collection<Character> chars) {
         char[] charArray = new char[chars.size()];
         int pos = 0;
         for (char c : chars) {
             charArray[pos++] = c;
         }
 
         return new String(charArray);
     }
 
     private static boolean isOutsideRange(int val, int lowerBound, int upperBound) {
         return val < lowerBound || val > upperBound;
     }
 
     /**
      * Produces {@link PasswordSpecification} instances. At least one call to
      * {@link #allow(String)} or {@link #require(String,int)} must be made to specify the set of
      * characters that the password can contain. The password size range will default to
      * {@link #DEFAULT_MIN_PASSWORD_LENGTH} to {@link #DEFAULT_MAX_PASSWORD_LENGTH},
      * which may be overridden.
      */
     public static class Builder {
 
         private final TreeSet<Character> mAllowedCharSet = new TreeSet<>();
         private final TreeSet<RequiredCharSet> mRequiredCharSets = new TreeSet<>();
         private int mMinimumSize = -1;
         private int mMaximumSize = -1;
 
         /**
          * Recreates a password specification from its protocol buffer form.
          */
-        public Builder(org.openyolo.proto.PasswordSpecification proto) {
-            this.ofLength(proto.minSize, proto.maxSize);
-            this.allow(proto.allowed);
-            for (org.openyolo.proto.RequiredCharSet set : proto.requiredSets) {
-                this.require(set.chars, set.count);
+        public Builder(Protobufs.PasswordSpecification proto) {
+            this.ofLength(proto.getMinSize(), proto.getMaxSize());
+            this.allow(proto.getAllowed());
+            for (Protobufs.RequiredCharSet set : proto.getRequiredSetsList()) {
+                this.require(set.getChars(), set.getCount());
             }
         }
 
         /**
          * Starts the process of defining a password specification.
          */
         public Builder() {}
 
         /**
          * Declares that the provided set of characters may occur in a password,
          * zero or more times.
          * @param allowedChars A set of characters which may occur in a password. Duplicate
          *     characters in the string, or provided over multiple calls to allow,
          *     will be ignored.
          * @throws InvalidSpecificationError if the string is null or empty, or contains
          *     characters which are not in the ascii printable range.
          */
         public Builder allow(@NonNull String allowedChars) {
             mAllowedCharSet.addAll(checkAndSortChars(allowedChars, "allowedChars"));
             return this;
         }
 
         /**
          * Declares that at least as many characters as specified must exist in the password,
          * drawn from the provided set. The character set must not overlap with any
          * other required character set, and must be a subset of the allowed character set.
          *
          * @param requiredChars A set of characters from which the required count will be selected.
          *     Duplicate characters will be ignored.
          * @param count The number of characters which will be selected from the required character
          *     set. Must be at least 1.
          * @throws InvalidSpecificationError if the string is null or empty, contains
          *     characters which are not in the ascii printable range, or exist within another
          *     required set of characters.
          */
         public Builder require(@NonNull String requiredChars, int count) {
             if (count < 1) {
                 throw new InvalidSpecificationError("count must be at least 1");
             }
 
             TreeSet<Character> requiredCharSet = checkAndSortChars(requiredChars, "requiredChars");
             mAllowedCharSet.addAll(requiredCharSet);
             mRequiredCharSets.add(
                     new RequiredCharSet(
                             charCollectionToString(requiredCharSet),
                             count));
             return this;
         }
 
         /**
          * Declares that the password must be within a certain size range.
          * @param minimumSize
          *     The minimum size of the password. Must be at least 1.
          * @param  maximumSize
          *     The maximum size of the password. Must be at least as large as {@code minimumSize}.
          */
         public Builder ofLength(int minimumSize, int maximumSize) {
             if (minimumSize < 1) {
                 throw new InvalidSpecificationError("minimumSize must be at least 1");
             }
 
             if (minimumSize > maximumSize) {
                 throw new InvalidSpecificationError(
                         "maximumSize must be greater than or equal to minimumSize");
             }
 
             mMinimumSize = minimumSize;
             mMaximumSize = maximumSize;
 
             return this;
         }
 
         /**
          * Produces a {@link PasswordSpecification} instance, if the configuration specified on the
          * builder is valid.
          *
          * @throws InvalidSpecificationError if the specification is invalid.
          */
         public PasswordSpecification build() {
             if (mAllowedCharSet.isEmpty()) {
                 throw new InvalidSpecificationError("no allowed characters specified");
             }
 
             if (mMinimumSize < 0) {
                 // the length of the password was never set
                 throw new InvalidSpecificationError(
                         "minimum and maximum size of password not specified");
             }
 
             checkRequiredCharsTotalCount();
             checkRequiredCharsDisjoint();
 
             return new PasswordSpecification(
                     charCollectionToString(mAllowedCharSet),
                     mRequiredCharSets,
                     mMinimumSize,
                     mMaximumSize);
         }
 
         private TreeSet<Character> checkAndSortChars(String chars, String paramName) {
             if (TextUtils.isEmpty(chars)) {
                 throw new InvalidSpecificationError(paramName + " cannot be null or empty");
             }
 
             TreeSet<Character> filteredChars = new TreeSet<>();
 
             for (char c : chars.toCharArray()) {
                 if (isOutsideRange(c, ASCII_PRINTABLE_RANGE_LOWER, ASCII_PRINTABLE_RANGE_UPPER)) {
                     throw new InvalidSpecificationError(
                             paramName + " must only contain ASCII printable characters");
                 }
                 filteredChars.add(c);
             }
 
             return filteredChars;
         }
 
         private void checkRequiredCharsTotalCount() {
             int count = 0;
             for (RequiredCharSet set : mRequiredCharSets) {
                 count += set.count;
             }
 
             if (count > mMaximumSize) {
                 throw new InvalidSpecificationError(
                         "required character count cannot be greater than the max password size");
             }
         }
 
         private void checkRequiredCharsDisjoint() {
             boolean[] charsUsed =
                     new boolean[ASCII_PRINTABLE_RANGE_UPPER - ASCII_PRINTABLE_RANGE_LOWER + 1];
 
             for (RequiredCharSet set : mRequiredCharSets) {
                 for (char c : set.chars.toCharArray()) {
                     if (charsUsed[c - ASCII_PRINTABLE_RANGE_LOWER]) {
                         throw new InvalidSpecificationError("character " + c
                                 + " occurs in more than one required character set");
                     }
                     charsUsed[c - ASCII_PRINTABLE_RANGE_LOWER] = true;
                 }
             }
         }
     }
 
     /**
      * The error type that is thrown in an attempt is made to construct an invalid specification.
      */
     public static class InvalidSpecificationError extends Error {
         /**
          * Creates an InvalidSpecificationError with the provided reason.
          */
         public InvalidSpecificationError(String reason) {
             super(reason);
         }
     }
 
     /**
      * Represents a required character set, where a password must contain at least as many
      * characters as specified, drawn from the specified set.
      */
     private static final class RequiredCharSet implements Comparable<RequiredCharSet> {
 
         /**
          * The set of characters from which the required characters must be drawn.
          */
         public final String chars;
 
         /**
          * The minimum number of characters that must occur in the password, drawn from
          * {@link #chars}.
          */
         public final int count;
 
         private RequiredCharSet(String chars, int count) {
             this.chars = chars;
             this.count = count;
         }
 
         @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
             }
 
             if (obj == null || !(obj instanceof RequiredCharSet)) {
                 return false;
             }
 
             RequiredCharSet other = (RequiredCharSet) obj;
             return this.chars.equals(other.chars) && this.count == other.count;
         }
 
         @Override
         public int hashCode() {
             return count * HASH_PRIME + chars.hashCode();
         }
 
         @Override
         public int compareTo(@NonNull RequiredCharSet other) {
             require(other, notNullValue());
 
             // sort by count then chars
             if (this.count < other.count) {
                 return -1;
             }
 
             if (this.count > other.count) {
                 return 1;
             }
 
             return chars.compareTo(other.chars);
         }
     }
 
     private static final class PasswordSpecificationCreator
             implements Creator<PasswordSpecification> {
 
         @Override
         public PasswordSpecification createFromParcel(Parcel parcel) {
             int encodedSize = parcel.readInt();
             byte[] encoded = new byte[encodedSize];
             parcel.readByteArray(encoded);
 
-            org.openyolo.proto.PasswordSpecification proto;
+            Protobufs.PasswordSpecification proto;
             try {
-                proto = org.openyolo.proto.PasswordSpecification.ADAPTER.decode(encoded);
+                proto = Protobufs.PasswordSpecification.parseFrom(encoded);
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
 
             return new PasswordSpecification.Builder(proto).build();
         }
 
         @Override
         public PasswordSpecification[] newArray(int size) {
             return new PasswordSpecification[size];
         }
     }
 }
diff --git a/protocol/java/org/openyolo/protocol/ProtocolConstants.java b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
new file mode 100644
index 0000000..8273eb9
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/ProtocolConstants.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol;
+
+/**
+ * Defines key constants that are used to identify data carried in intents.
+ */
+public final class ProtocolConstants {
+
+    /**
+     * The data type used for credential queries using the BBQ protocol.
+     */
+    public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
+
+    /**
+     * The extra value key used to store the credential in a retrieve intent response.
+     */
+    public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
+
+    /**
+     * The extra key value used to carry a hint request to a credential provider.
+     */
+    public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
+
+    /**
+     * The category used for all OpenYOLO-related intents.
+     */
+    public static final String OPENYOLO_CATEGORY = "org.openyolo";
+
+    /**
+     * The action used for hint intents.
+     */
+    public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
+
+    /**
+     * The action used for save intents.
+     */
+    public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
+
+    private ProtocolConstants() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+}
diff --git a/api/java/org/openyolo/api/RetrieveRequest.java b/protocol/java/org/openyolo/protocol/RetrieveRequest.java
similarity index 74%
rename from api/java/org/openyolo/api/RetrieveRequest.java
rename to protocol/java/org/openyolo/protocol/RetrieveRequest.java
index 9588046..e6cab86 100644
--- a/api/java/org/openyolo/api/RetrieveRequest.java
+++ b/protocol/java/org/openyolo/protocol/RetrieveRequest.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -23,11 +23,6 @@ import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.api.internal.CollectionConverter.toList;
-import static org.openyolo.api.internal.CollectionConverter.toMap;
-import static org.openyolo.api.internal.CollectionConverter.toSet;
-import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationMethod;
-import static org.openyolo.api.internal.CustomMatchers.notNullOrEmptyString;
-import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP;
-import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_KVP_TO_PAIR;
-import static org.openyolo.api.internal.UriConverters.CONVERTER_STRING_TO_URI;
-import static org.openyolo.api.internal.UriConverters.CONVERTER_URI_TO_STRING;
+import static org.openyolo.protocol.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.protocol.internal.CustomMatchers.notNullOrEmptyString;
+import static org.openyolo.protocol.internal.UriConverters.CONVERTER_STRING_TO_URI;
+import static org.openyolo.protocol.internal.UriConverters.CONVERTER_URI_TO_STRING;
 import static org.valid4j.Validation.validate;
@@ -45,240 +40,254 @@ import java.util.Map;
 import java.util.Set;
-import org.openyolo.api.internal.NoopValueConverter;
-import org.openyolo.proto.CredentialRetrieveRequest;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.NoopValueConverter;
 
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class RetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     @NonNull
     private final Set<Uri> mAuthMethods;
 
     @NonNull
-    private final Map<String, byte[]> mAdditionalParams;
+    private final Map<String, byte[]> mAdditionalProps;
 
     private RetrieveRequest(
             @NonNull Set<Uri> authMethods,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
-        mAdditionalParams = additionalParams;
+        mAdditionalProps = additionalParams;
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(
             @NonNull Set<Uri> authenticationMethods) {
         return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(@NonNull Uri... authenticationMethods) {
         return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * The set of authentication methods that the requestor supports. This is used to filter the set
      * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<Uri> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
-    public Map<String, byte[]> getAdditionalParameters() {
-        return mAdditionalParams;
+    public Map<String, byte[]> getAdditionalProperties() {
+        return mAdditionalProps;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
-    public String getAdditionalParameterAsString(@NonNull String key) {
+    public String getAdditionalPropertyAsString(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
-        if (mAdditionalParams.containsKey(key)) {
-            return new String(mAdditionalParams.get(key), Charset.forName("UTF-8"));
+        if (mAdditionalProps.containsKey(key)) {
+            return new String(mAdditionalProps.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
-    public byte[] getAdditionalParameter(@NonNull String key) {
+    public byte[] getAdditionalProperty(@NonNull String key) {
         validate(key, notNullValue(), IllegalArgumentException.class);
 
-        return mAdditionalParams.get(key);
+        return mAdditionalProps.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
-        byte[] protoBytes = toProtocolBuffer().encode();
+        byte[] protoBytes = toProtocolBuffer().toByteArray();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
-    public CredentialRetrieveRequest toProtocolBuffer() {
-        return new CredentialRetrieveRequest.Builder()
-                .authMethods(toList(mAuthMethods, CONVERTER_URI_TO_STRING))
-                .additionalParams(toList(mAdditionalParams.entrySet(), CONVERTER_ENTRY_TO_KVP))
+    public Protobufs.CredentialRetrieveRequest toProtocolBuffer() {
+        return Protobufs.CredentialRetrieveRequest.newBuilder()
+                .addAllAuthMethods(
+                        CollectionConverter.toList(
+                                mAuthMethods,
+                                CONVERTER_URI_TO_STRING))
+                .putAllAdditionalProps(
+                        CollectionConverter.convertMapValues(
+                                mAdditionalProps,
+                                ByteStringConverters.BYTE_ARRAY_TO_BYTE_STRING))
                 .build();
     }
 
     /**
      * Creates {@link RetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<Uri> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
-        public Builder(@NonNull CredentialRetrieveRequest requestProto) {
+        public Builder(@NonNull Protobufs.CredentialRetrieveRequest requestProto) {
             validate(requestProto, notNullValue(), IllegalArgumentException.class);
 
-            setAuthenticationMethods(toSet(requestProto.authMethods, CONVERTER_STRING_TO_URI));
-            setAdditionalParameters(toMap(requestProto.additionalParams, CONVERTER_KVP_TO_PAIR));
+            setAuthenticationMethods(CollectionConverter.toSet(
+                    requestProto.getAuthMethodsList(),
+                    CONVERTER_STRING_TO_URI));
+            setAdditionalProperties(
+                    CollectionConverter.convertMapValues(
+                            requestProto.getAdditionalPropsMap(),
+                            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Uri... authMethods) {
             setAuthenticationMethods(
-                    toSet(null, authMethods, NoopValueConverter.<Uri>getInstance()));
+                    CollectionConverter.toSet(
+                            authMethods,
+                            NoopValueConverter.<Uri>getInstance()));
         }
 
         /**
          * Starts the process of describing a retrieve request. At least one authentication method
          * must be provided.
          */
         public Builder(@NonNull Set<Uri> authMethods) {
             setAuthenticationMethods(authMethods);
         }
 
         /**
          * Specifies the authentication methods supported by the requester. At least one
          * authentication method must be provided.
          */
         private Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
             validate(authMethods, notNullValue(), IllegalArgumentException.class);
             validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
             validate(
                     authMethods,
                     everyItem(isValidAuthenticationMethod()),
                     IllegalArgumentException.class);
 
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
-        public Builder setAdditionalParameters(
+        public Builder setAdditionalProperties(
                 @NonNull Map<String, byte[]> additionalParams) {
             validate(additionalParams, notNullValue(), IllegalArgumentException.class);
             validate(
                     additionalParams.keySet(),
                     everyItem(notNullOrEmptyString()),
                     IllegalArgumentException.class);
             validate(
                     additionalParams.values(),
                     everyItem(notNullValue()),
                     IllegalArgumentException.class);
 
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
-         * @see {@link RetrieveRequest#getAdditionalParameterAsString(String)}
+         * @see RetrieveRequest#getAdditionalPropertyAsString(String)
          */
-        public Builder addAdditionalParameter(
+        public Builder addAdditionalProperty(
                 @NonNull String name,
                 @NonNull String value) {
             validate(value, notNullValue(), IllegalArgumentException.class);
 
-            addAdditionalParameter(name, value.getBytes(Charset.forName("UTF-8")));
+            addAdditionalProperty(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
-        public Builder addAdditionalParameter(String name, byte[] value) {
+        public Builder addAdditionalProperty(String name, byte[] value) {
             validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
             validate(value, notNullValue(), IllegalArgumentException.class);
 
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link RetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public RetrieveRequest build() {
             return new RetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
     private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
 
         @Override
         public RetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new RetrieveRequest.Builder(
-                        CredentialRetrieveRequest.ADAPTER.decode(protoBytes))
+                        Protobufs.CredentialRetrieveRequest.parseFrom(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public RetrieveRequest[] newArray(int size) {
             return new RetrieveRequest[size];
         }
     }
 }
diff --git a/api/java/org/openyolo/api/RetrieveResult.java b/protocol/java/org/openyolo/protocol/RetrieveResult.java
similarity index 71%
rename from api/java/org/openyolo/api/RetrieveResult.java
rename to protocol/java/org/openyolo/protocol/RetrieveResult.java
index 6894108..4953845 100644
--- a/api/java/org/openyolo/api/RetrieveResult.java
+++ b/protocol/java/org/openyolo/protocol/RetrieveResult.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -24,160 +24,193 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import com.google.protobuf.InvalidProtocolBufferException;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-import org.openyolo.api.internal.CollectionConverter;
-import org.openyolo.api.internal.IntentUtil;
-import org.openyolo.api.internal.KeyValuePairConverters;
-import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveResponse;
+import org.openyolo.protocol.internal.ByteStringConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
+import org.openyolo.protocol.internal.IntentUtil;
 
 /**
  * A response to a {@link RetrieveRequest credential retrieve request}.
  */
 public class RetrieveResult implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveResult} instances.
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveResult> CREATOR = new RetrieveResultCreator();
 
     @Nullable
     private final Intent mRetrieveIntent;
 
     @NonNull
     private final Map<String, CredentialRetrieveResponse> mResponses;
 
     private RetrieveResult(
             @Nullable Intent retrieveIntent,
             @NonNull Map<String, CredentialRetrieveResponse> responses) {
         mRetrieveIntent = retrieveIntent;
         mResponses = responses;
     }
 
     /**
      * An intent that can be used to retrieve a credential for the calling app. If no credentials
      * are available, this will be {@code null}. User input may or may not be required to retrieve
      * the credential, at the discretion of the credential provider. The retrieve intent
      * should be fired when the app is ready to retrieve the credential - typically immediately
      * after the retrieve result is received.
      */
     @Nullable
     public Intent getRetrieveIntent() {
         return mRetrieveIntent;
     }
 
     /**
      * The package names of responding credential providers that indicated they may have a usable
      * credential.
      */
     @NonNull
     public Set<String> getResponderPackageNames() {
         return mResponses.keySet();
     }
 
     /**
      * Retrieves the intent for the specified responder package name, if available.
      */
     @NonNull
     public Intent getRetrieveIntentForResponder(@NonNull String responderPackageName) {
         require(responderPackageName, notNullValue());
         CredentialRetrieveResponse response = mResponses.get(responderPackageName);
         if (response == null) {
             throw new IllegalArgumentException(responderPackageName + " is not a responder");
         }
 
-        return IntentUtil.fromBytes(response.retrieveIntent.toByteArray());
+        return IntentUtil.fromBytes(response.getRetrieveIntent().toByteArray());
     }
 
     /**
      * Retrieves the additional, non-standard response parameters for the specified responder
      * package name, if available.
      */
     @NonNull
-    public Map<String, byte[]> getAdditionalParamsForResponder(String responderPackageName) {
+    public Map<String, byte[]> getAdditionalPropsForResponder(String responderPackageName) {
         CredentialRetrieveResponse response = mResponses.get(responderPackageName);
         if (response == null) {
             throw new IllegalArgumentException(responderPackageName + " is not a responder");
         }
 
-        return CollectionConverter.toMap(
-                response.additionalParams,
-                KeyValuePairConverters.CONVERTER_KVP_TO_PAIR);
+        return CollectionConverter.convertMapValues(
+                response.getAdditionalPropsMap(),
+            ByteStringConverters.BYTE_STRING_TO_BYTE_ARRAY);
     }
 
     /**
      * Creates {@link RetrieveResult} instances.
      */
     public static final class Builder {
 
         @Nullable
         private Intent mIntent;
 
         @NonNull
         private Map<String, CredentialRetrieveResponse> mProtoResponses;
 
         /**
          * Starts the process of describing a credential retrieve result.
          */
         public Builder() {
             mIntent = null;
             mProtoResponses = Collections.emptyMap();
         }
 
         /**
          * Specifies the map of protocol buffer responses received for the credential request,
          * keyed by the package name of the responder.
          */
         @NonNull
         public Builder setProtoResponses(
                 @NonNull Map<String, CredentialRetrieveResponse> protoResponses) {
             require(protoResponses, notNullValue());
             for (CredentialRetrieveResponse value : protoResponses.values()) {
                 require(value, notNullValue());
             }
             mProtoResponses = protoResponses;
             return this;
         }
 
         /**
          * Specifies the retrieve intent, that can be used to retrieve existing credentials from
          * the provider, if available.
          */
         @NonNull
         public Builder setRetrieveIntent(@Nullable Intent intent) {
             mIntent = intent;
             return this;
         }
 
         /**
          * Creates a {@link RetrieveResult} with the properties described to the builder.
          */
         @NonNull
         public RetrieveResult build() {
             return new RetrieveResult(mIntent, mProtoResponses);
         }
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
-
+        dest.writeParcelable(mRetrieveIntent, 0);
+        dest.writeInt(mResponses.size());
+
+        for (String key : mResponses.keySet()) {
+            byte[] responseBytes = mResponses.get(key).toByteArray();
+            dest.writeString(key);
+            dest.writeInt(responseBytes.length);
+            dest.writeByteArray(responseBytes);
+        }
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     static final class RetrieveResultCreator implements Creator<RetrieveResult> {
         @Override
         public RetrieveResult createFromParcel(Parcel in) {
-            return null;
+            Intent retrieveIntent = in.readParcelable(Intent.class.getClassLoader());
+            int numResponses = in.readInt();
+
+            Map<String, CredentialRetrieveResponse> responses = new HashMap<>(numResponses);
+            for (int i = 0; i < numResponses; i++) {
+                String key = in.readString();
+                int responseSize = in.readInt();
+                byte[] responseBytes = new byte[responseSize];
+                in.readByteArray(responseBytes);
+
+                CredentialRetrieveResponse response;
+                try {
+                    response = CredentialRetrieveResponse.parseFrom(responseBytes);
+                } catch (InvalidProtocolBufferException ex) {
+                    throw new IllegalArgumentException("Unable to parse response proto");
+                }
+
+                responses.put(key, response);
+            }
+
+            return new RetrieveResult.Builder()
+                    .setRetrieveIntent(retrieveIntent)
+                    .setProtoResponses(responses)
+                    .build();
         }
 
         @Override
         public RetrieveResult[] newArray(int size) {
             return new RetrieveResult[size];
         }
     }
 
 }
diff --git a/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java b/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
new file mode 100644
index 0000000..1392a81
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/AuthenticationDomainConverters.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import org.openyolo.protocol.AuthenticationDomain;
+
+/**
+ * Implementations of {@link ValueConverter} related to {@link AuthenticationDomain}.
+ */
+public final class AuthenticationDomainConverters {
+
+    /**
+     * Creates {@link AuthenticationDomain} instances from strings.
+     */
+    public static final ValueConverter<String, AuthenticationDomain> STRING_TO_DOMAIN =
+            new StringToAuthenticationDomainConverter();
+
+    /**
+     * Extracts the string representation from {@link AuthenticationDomain} instances.
+     */
+    public static final ValueConverter<AuthenticationDomain, String> DOMAIN_TO_STRING =
+            new AuthenticationDomainToStringConverter();
+
+    private AuthenticationDomainConverters() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+
+    private static final class StringToAuthenticationDomainConverter
+            implements ValueConverter<String, AuthenticationDomain> {
+        @Override
+        public AuthenticationDomain convert(String value) {
+            return new AuthenticationDomain(value);
+        }
+    }
+
+    private static final class AuthenticationDomainToStringConverter
+            implements ValueConverter<AuthenticationDomain, String> {
+
+        @Override
+        public String convert(AuthenticationDomain value) {
+            return value.toString();
+        }
+    }
+}
diff --git a/protocol/java/org/openyolo/protocol/internal/ByteStringConverters.java b/protocol/java/org/openyolo/protocol/internal/ByteStringConverters.java
new file mode 100644
index 0000000..868b4a9
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/ByteStringConverters.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import com.google.protobuf.ByteString;
+
+/**
+ * Instances of {@link ValueConverter} related to {@link com.google.protobuf.ByteString}
+ * instances.
+ */
+public final class ByteStringConverters {
+
+    /**
+     * Extracts byte arrays from {@link ByteString} instances.
+     */
+    public static final ValueConverter<ByteString, byte[]> BYTE_STRING_TO_BYTE_ARRAY
+            = new ByteStringToByteArrayConverter();
+
+    /**
+     * Copies byte arrays into {@link ByteString} instances.
+     */
+    public static final ValueConverter<byte[], ByteString> BYTE_ARRAY_TO_BYTE_STRING
+            = new ByteArrayToByteStringConverter();
+
+    private static final class ByteStringToByteArrayConverter
+            implements ValueConverter<ByteString, byte[]> {
+        @Override
+        public byte[] convert(ByteString value) {
+            return value.toByteArray();
+        }
+    }
+
+    private static final class ByteArrayToByteStringConverter
+            implements ValueConverter<byte[], ByteString> {
+        @Override
+        public ByteString convert(byte[] value) {
+            return ByteString.copyFrom(value);
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/CollectionConverter.java b/protocol/java/org/openyolo/protocol/internal/CollectionConverter.java
similarity index 86%
rename from api/java/org/openyolo/api/internal/CollectionConverter.java
rename to protocol/java/org/openyolo/protocol/internal/CollectionConverter.java
index e90411d..2755232 100644
--- a/api/java/org/openyolo/api/internal/CollectionConverter.java
+++ b/protocol/java/org/openyolo/protocol/internal/CollectionConverter.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
@@ -22,3 +22,2 @@ import android.util.ArraySet;
 import android.util.Pair;
-
 import java.util.ArrayList;
@@ -33,161 +32,192 @@ import java.util.Set;
 /**
  * Utility methods to convert collections to different types, while also potentially changing
  * the types of the values themselves.
  */
 public final class CollectionConverter {
 
     /**
      * Converts all the values in the provided collection, and adds them to a new set.
      */
     @NonNull
     public static <T, U> Set<U> toSet(
             @Nullable Collection<T> values,
             @NonNull ValueConverter<T, U> valueConverter) {
         Set<U> result = createSet(values);
         convert(values, result, valueConverter);
         return result;
     }
 
+    /**
+     * Converts all the provided values, and adds them to a new set.
+     */
+    public static <T, U> Set<U> toSet(
+            @Nullable T[] values,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        return toSet(null, values, valueConverter);
+    }
+
     /**
      * Converts all the provided values, and adds them to a new set.
      */
     @NonNull
     public static <T, U> Set<U> toSet(
             @Nullable T firstValue,
             @Nullable T[] additionalValues,
             @NonNull ValueConverter<T, U> valueConverter) {
         Set<U> result = createSet(firstValue, additionalValues);
         convert(firstValue, additionalValues, result, valueConverter);
         return result;
     }
 
     /**
      * Converts all the values in the provided collection, and adds them to a new list.
      */
     @NonNull
     public static <T, U> List<U> toList(
             @Nullable Collection<T> values,
             @NonNull ValueConverter<T, U> valueConverter) {
         List<U> result = createList(values);
         convert(values, result, valueConverter);
         return result;
     }
 
     /**
      * Converts all the provided values, and adds them to a new set.
      */
     @NonNull
     public static <T, U> List<U> toList(
             @Nullable T firstValue,
             @Nullable T[] values,
             @NonNull ValueConverter<T, U> valueConverter) {
         List<U> result = createList(firstValue, values);
         convert(firstValue, values, result, valueConverter);
         return result;
     }
 
     /**
      * Converts all the values in the provided collection, and adds them to a new map.
      */
     @NonNull
     public static <T, U, V> Map<U, V> toMap(
             @Nullable Collection<T> values,
             @NonNull ValueConverter<T, Pair<U, V>> valueConverter) {
         if (values == null) {
             return Collections.emptyMap();
         }
 
         Map<U, V> result = createMap(values.size());
         for (T value : values) {
             Pair<U, V> converted = valueConverter.convert(value);
             result.put(converted.first, converted.second);
         }
 
         return result;
     }
 
+    /**
+     * Converts the values stored against keys in the provided map, using the provided
+     * value converter.
+     */
+    @NonNull
+    public static <K, V, U> Map<K, U> convertMapValues(
+            @Nullable Map<K, V> map,
+            @NonNull ValueConverter<V, U> valueConverter) {
+        if (map == null) {
+            return Collections.emptyMap();
+        }
+
+        Map<K, U> result = createMap(map.size());
+        for (K key : map.keySet()) {
+            V value = map.get(key);
+            U convertedValue = valueConverter.convert(value);
+            result.put(key, convertedValue);
+        }
+
+        return result;
+    }
+
     private static <T, U> void convert(
             @Nullable Collection<T> source,
             @NonNull Collection<U> target,
             @NonNull ValueConverter<T, U> valueConverter) {
         if (source == null) {
             return;
         }
 
         for (T value : source) {
             target.add(valueConverter.convert(value));
         }
     }
 
     private static <T, U> void convert(
             @Nullable T firstValue,
             @Nullable T[] additionalValues,
             @NonNull Collection<U> target,
             @NonNull ValueConverter<T, U> valueConverter) {
         if (firstValue == null && additionalValues == null) {
             return;
         }
 
         if (firstValue != null) {
             target.add(valueConverter.convert(firstValue));
         }
 
         if (additionalValues != null) {
             for (T value : additionalValues) {
                 target.add(valueConverter.convert(value));
             }
         }
     }
 
     @NonNull
     private static <T> Set<T> createSet(Collection collection) {
         return createSet(collection != null ? collection.size() : 0);
     }
 
     @NonNull
     private static <T, U> Set<T> createSet(U firstValue, U[] values) {
         return createSet((firstValue != null ? 1 : 0)
                 + (values != null ? values.length : 0));
     }
 
     @NonNull
     private static <T> Set<T> createSet(int size) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             return new ArraySet<>(size);
         } else {
             return new HashSet<>();
         }
     }
 
     @NonNull
     private static <T, U> List<T> createList(
             @Nullable Collection<U> values) {
         return createList(values != null ? values.size() : 0);
     }
 
     @NonNull
     private static <T, U> List<T> createList(
             @Nullable U firstValue,
             @Nullable U[] additionalValues) {
         return createList((firstValue != null ? 1 : 0)
                 + (additionalValues != null ? additionalValues.length : 0));
     }
 
     @NonNull
     private static <T> List<T> createList(int size) {
         return new ArrayList<>(size);
     }
 
     @NonNull
     private static <T, U> Map<T, U> createMap(int size) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             return new ArrayMap<>(size);
         } else {
             return new HashMap<>();
         }
     }
 
     private CollectionConverter() {
         throw new IllegalStateException("not intended to be constructed");
     }
 }
diff --git a/api/java/org/openyolo/api/internal/CustomMatchers.java b/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
similarity index 99%
rename from api/java/org/openyolo/api/internal/CustomMatchers.java
rename to protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
index 717476c..c10fa77 100644
--- a/api/java/org/openyolo/api/internal/CustomMatchers.java
+++ b/protocol/java/org/openyolo/protocol/internal/CustomMatchers.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
diff --git a/api/java/org/openyolo/api/internal/IntentUtil.java b/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
similarity index 98%
rename from api/java/org/openyolo/api/internal/IntentUtil.java
rename to protocol/java/org/openyolo/protocol/internal/IntentUtil.java
index d7a92ff..f61b51f 100644
--- a/api/java/org/openyolo/api/internal/IntentUtil.java
+++ b/protocol/java/org/openyolo/protocol/internal/IntentUtil.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
diff --git a/api/java/org/openyolo/api/internal/Constants.java b/protocol/java/org/openyolo/protocol/internal/InternalConstants.java
similarity index 91%
rename from api/java/org/openyolo/api/internal/Constants.java
rename to protocol/java/org/openyolo/protocol/internal/InternalConstants.java
index 22a8597..828de77 100644
--- a/api/java/org/openyolo/api/internal/Constants.java
+++ b/protocol/java/org/openyolo/protocol/internal/InternalConstants.java
@@ -14,13 +14,13 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
 /**
  * Internal constants used throughout the library.
  */
-public class Constants {
+public class InternalConstants {
 
     /**
      * A prime number for use in deriving hash codes.
      */
     public static final int HASH_PRIME = 92821;
 }
diff --git a/api/java/org/openyolo/api/internal/NoopValueConverter.java b/protocol/java/org/openyolo/protocol/internal/NoopValueConverter.java
similarity index 96%
rename from api/java/org/openyolo/api/internal/NoopValueConverter.java
rename to protocol/java/org/openyolo/protocol/internal/NoopValueConverter.java
index 7c56d34..51ce052 100644
--- a/api/java/org/openyolo/api/internal/NoopValueConverter.java
+++ b/protocol/java/org/openyolo/protocol/internal/NoopValueConverter.java
@@ -14,7 +14,7 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
 /**
  * Returns the provided value as-is. Useful for performing collection type conversion where
  * the values do not change.
  */
diff --git a/protocol/java/org/openyolo/protocol/internal/StringUtil.java b/protocol/java/org/openyolo/protocol/internal/StringUtil.java
new file mode 100644
index 0000000..d0907a2
--- /dev/null
+++ b/protocol/java/org/openyolo/protocol/internal/StringUtil.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.protocol.internal;
+
+import android.support.annotation.Nullable;
+
+/**
+ * String manipulation utilities.
+ */
+public final class StringUtil {
+
+    /**
+     * Returns the provided string value if it is non-null and non-empty, otherwise returns null.
+     */
+    @Nullable
+    public static String nullifyEmptyString(@Nullable String str) {
+        if (str == null || str.isEmpty()) {
+            return null;
+        }
+
+        return str;
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/UriConverters.java b/protocol/java/org/openyolo/protocol/internal/UriConverters.java
similarity index 97%
rename from api/java/org/openyolo/api/internal/UriConverters.java
rename to protocol/java/org/openyolo/protocol/internal/UriConverters.java
index 00ae829..54453da 100644
--- a/api/java/org/openyolo/api/internal/UriConverters.java
+++ b/protocol/java/org/openyolo/protocol/internal/UriConverters.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
diff --git a/api/java/org/openyolo/api/internal/ValueConverter.java b/protocol/java/org/openyolo/protocol/internal/ValueConverter.java
similarity index 95%
rename from api/java/org/openyolo/api/internal/ValueConverter.java
rename to protocol/java/org/openyolo/protocol/internal/ValueConverter.java
index 0579f9c..e323a34 100644
--- a/api/java/org/openyolo/api/internal/ValueConverter.java
+++ b/protocol/java/org/openyolo/protocol/internal/ValueConverter.java
@@ -14,6 +14,6 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
 /**
  * Simple abstraction that converts values of type T into values of type U.
  */
diff --git a/api/java/org/openyolo/api/internal/package-info.java b/protocol/java/org/openyolo/protocol/internal/package-info.java
similarity index 74%
rename from api/java/org/openyolo/api/internal/package-info.java
rename to protocol/java/org/openyolo/protocol/internal/package-info.java
index 064ceef..6b92df8 100644
--- a/api/java/org/openyolo/api/internal/package-info.java
+++ b/protocol/java/org/openyolo/protocol/internal/package-info.java
@@ -1,18 +1,19 @@
 /*
  * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the
  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 /**
- * The contents of this package are not part of the official API; use at your own risk.
+ * Data types and utility classes that are used by the OpenYOLO libraries. _NOTE_: The contents of
+ * this package are _not_ part of the public API, and may change at any time.
  */
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
diff --git a/demoproviders/barbican/java/okio/package-info.java b/protocol/java/org/openyolo/protocol/package-info.java
similarity index 81%
rename from demoproviders/barbican/java/okio/package-info.java
rename to protocol/java/org/openyolo/protocol/package-info.java
index 531e681..bd108aa 100644
--- a/demoproviders/barbican/java/okio/package-info.java
+++ b/protocol/java/org/openyolo/protocol/package-info.java
@@ -1,18 +1,19 @@
 /*
  * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the
  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 /**
- * OKIO extensions for cryptographic streams.
+ * Data types and messages which are sent between the client and credential provider in the
+ * OpenYOLO protocol.
  */
-package okio;
+package org.openyolo.protocol;
diff --git a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
similarity index 96%
rename from api/javatests/org/openyolo/api/AuthenticationDomainTest.java
rename to protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
index 969f5eb..dfa7f67 100644
--- a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
+++ b/protocol/javatests/org/openyolo/protocol/AuthenticationDomainTest.java
@@ -16,3 +16,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -38,3 +38,5 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
-import org.openyolo.api.internal.CollectionConverter;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.internal.AuthenticationDomainConverters;
+import org.openyolo.protocol.internal.CollectionConverter;
 import org.robolectric.RobolectricTestRunner;
@@ -44,188 +46,188 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Unit tests for {@link AuthenticationDomain}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AuthenticationDomainTest {
 
     private static final String VALID_PACKAGE_NAME = "com.example.app";
 
     private static byte[] VALID_SIGNATURE_BYTES = new byte[]
             { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
     private static final String VALID_FINGERPRINT =
             "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                     + "7V4Lo8BdCxaA307H0HYkAw==";
 
     private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
             "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
 
     private static final PackageInfo VALID_PACKAGE_INFO = makeValidPackageInfo();
 
     private static PackageInfo makeValidPackageInfo() {
         PackageInfo packageInfo = new PackageInfo();
         packageInfo.signatures = new Signature[2];
         packageInfo.signatures[0] = new Signature(VALID_SIGNATURE_BYTES);
         packageInfo.signatures[1] = new Signature(new byte[16]);
 
         return packageInfo;
     }
 
     @Mock
     PackageManager mockPackageManager;
     @Mock
     Context mockContext;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenReturn(VALID_PACKAGE_INFO);
         when(mockContext.getPackageName()).thenReturn(VALID_PACKAGE_NAME);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
     }
 
     @Test
     public void getSelfAuthDomain_withValidInput_returnsValidDomain() throws Exception {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain).isNotNull();
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.toString())
                 .isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test
     public void listForPackage_forValidPackage_containsValidAuthenticationDomain() {
         assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME))
                 .contains(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
     }
 
     @Test
     public void listForPackage_forNullPackageName_returnsEmpty() throws Exception {
         assertThat(AuthenticationDomain.listForPackage(mockContext, null /* package */)).isEmpty();
     }
 
     @Test
     public void listForPackage_packageDoesNotExist_returnsEmpty() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
                 .thenAnswer(new Answer<PackageInfo>() {
                     @Override
                     public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                         throw new NameNotFoundException();
                     }
                 });
 
         assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME)).isEmpty();
     }
 
     @Test
     public void getUri_returnsExpectedValue() throws Exception{
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain.getUri().toString()).isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test(expected = RequireViolation.class)
     public void CreateAndroidAuthDomain_withNullDomain_throwsRequireViolation() throws Exception{
         AuthenticationDomain.createAndroidAuthDomain(null /* authDomain */, mock(Signature.class));
     }
 
     @Test
     public void validWebAuthDomain_hasExpectedBehaviour() {
         AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
 
         assertThat(authDomain.isAndroidAuthDomain()).isFalse();
         assertThat(authDomain.isWebAuthDomain()).isTrue();
 
         try {
             authDomain.getAndroidPackageName();
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void validAndroidAuthDomain_hasExpectedBehaviour(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.isWebAuthDomain()).isFalse();
 
         assertThat(authDomain.getAndroidPackageName()).isEqualTo(VALID_PACKAGE_NAME);
     }
 
     @Test
     public void getSelfAuthDomain_packageNotFoundException_throwsException() throws Exception {
         when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
             .thenAnswer(new Answer<PackageInfo>() {
                 @Override
                 public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
                     throw new NameNotFoundException();
                 }
             });
 
         try {
             AuthenticationDomain.getSelfAuthDomain(mockContext);
 
             failBecauseExceptionWasNotThrown(IllegalStateException.class);
         } catch (IllegalStateException ex) {}
     }
 
     @Test
     public void stringsToAuthDomainsConverter_withValidInput_returnsExpectValues()
             throws Exception {
         List<String> domains = new ArrayList<>();
         domains.add("https://www.google.com");
         domains.add("https://www.yahoo.com");
         domains.add("https://www.facebook.com");
 
         List<AuthenticationDomain> result =
                 CollectionConverter.toList(
                         domains,
-                        AuthenticationDomain.CONVERTER_STRING_TO_DOMAIN);
+                        AuthenticationDomainConverters.STRING_TO_DOMAIN);
 
         assertThat(result.size()).isEqualTo(3);
 
         assertThat(result.get(0).getUri().toString()).isEqualTo(domains.get(0));
         assertThat(result.get(1).getUri().toString()).isEqualTo(domains.get(1));
         assertThat(result.get(2).getUri().toString()).isEqualTo(domains.get(2));
     }
 
     @Test
     public void hashCode_ofAuthDomainAndEquivalentUri_areEqual(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
         Uri authDomainUri = authDomain.getUri();
 
         assertThat(authDomain.hashCode()).isEqualTo(authDomainUri.hashCode());
     }
 
     @Test
     public void hashCode_ofAuthDomainAndUnequalUri_areNotEqual(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
         Uri authDomainUri = authDomain.getUri();
 
         assertThat(authDomain.hashCode()).isEqualTo(authDomainUri.hashCode());
     }
 
     @Test
     public void equals_withEquivalent_returnsTrue() throws Exception {
         AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mockContext);
         AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
         assertThat(authDomainA).isEqualTo(authDomainA);
         assertThat(authDomainA).isEqualTo(authDomainB);
 
         assertThat(authDomainA.compareTo(authDomainB)).isEqualTo(0);
     }
 
     @Test
     public void equals_withDifferentType_returnsFalse() throws Exception {
         final String authenticationDomainString = "https://www.example.com";
         AuthenticationDomain domain = new AuthenticationDomain(authenticationDomainString);
 
         assertThat(domain).isNotEqualTo(authenticationDomainString);
     }
 
 }
diff --git a/api/javatests/org/openyolo/api/CredentialTest.java b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
similarity index 80%
rename from api/javatests/org/openyolo/api/CredentialTest.java
rename to protocol/javatests/org/openyolo/protocol/CredentialTest.java
index 7fa203f..a66facf 100644
--- a/api/javatests/org/openyolo/api/CredentialTest.java
+++ b/protocol/javatests/org/openyolo/protocol/CredentialTest.java
@@ -16,10 +16,6 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
 import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.openyolo.api.AuthenticationMethods.ID_AND_PASSWORD;
+import static org.openyolo.protocol.AuthenticationMethods.ID_AND_PASSWORD;
 
@@ -27,5 +23,2 @@ import android.net.Uri;
 import android.os.Parcel;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
 import org.junit.Test;
@@ -37,221 +30,248 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link Credential}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class CredentialTest {
 
     public static final String EMAIL_ID = "alice@example.com";
+    public static final String AUTH_DOMAIN_STR = "https://www.example.com";
     public static final AuthenticationDomain AUTH_DOMAIN =
-            new AuthenticationDomain("https://www.example.com");
+            new AuthenticationDomain(AUTH_DOMAIN_STR);
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullIdentifier() {
         new Credential.Builder(null, ID_AND_PASSWORD, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthMethod() {
         new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     @SuppressWarnings("ConstantConditions")
     public void testBuilder_nullAuthDomain() {
         new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, null);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_emptyIdentifier() {
         new Credential.Builder("", ID_AND_PASSWORD, AUTH_DOMAIN);
     }
 
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_emptyAuthMethod() {
+        new Credential.Builder(EMAIL_ID, "", AUTH_DOMAIN_STR);
+    }
+
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithoutScheme() {
         new Credential.Builder(EMAIL_ID, Uri.parse("www.example.com"), AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithPath() {
         new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com/path"), AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithQuery() {
         new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com?a=b"), AUTH_DOMAIN);
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_authMethodWithFragment() {
         new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com#a"), AUTH_DOMAIN);
     }
 
     @Test
     public void testBuilder_mandatoryPropsOnly() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 ID_AND_PASSWORD,
-                new AuthenticationDomain("https://www.example.com")).build();
+                AUTH_DOMAIN).build();
         assertThat(cr).isNotNull();
         assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
         assertThat(cr.getAuthenticationMethod()).isEqualTo(ID_AND_PASSWORD);
-        assertThat(cr.getAuthenticationDomain()).isNotNull();
+        assertThat(cr.getAuthenticationDomain()).isEqualTo(AUTH_DOMAIN);
         assertThat(cr.getDisplayName()).isNull();
         assertThat(cr.getDisplayPicture()).isNull();
         assertThat(cr.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testBuilder_setIdentifier() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setIdentifier("bob@example.com")
                 .build();
         assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
     }
 
     @Test(expected = RequireViolation.class)
-    @SuppressWarnings("all")
+    @SuppressWarnings("ConstantConditions")
     public void testBuilder_setIdentifier_toNull() {
         new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
             .setIdentifier(null)
             .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuilder_setIdentifier_toEmpty() {
         new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setIdentifier("")
                 .build();
     }
 
     @Test
     public void testBuilder_setPassword() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
     }
 
     @Test
     public void testBuilder_setPassword_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword("password1")
                 .build();
         assertThat(cr.getPassword()).isEqualTo("password1");
     }
 
     @Test
     public void testBuilder_setPassword_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setPassword("CorrectHorseBatteryStaple")
                 .setPassword(null)
                 .build();
         assertThat(cr.getPassword()).isNull();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test
     public void testBuilder_setPassword_toEmpty() {
-        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setPassword("")
                 .build();
+
+        assertThat(cr.getDisplayName()).isNull();
     }
 
     @Test
     public void testBuilder_setDisplayName() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alice");
     }
 
     @Test
     public void testBuilder_setDisplayName_twice() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName("Alicia")
                 .build();
         assertThat(cr.getDisplayName()).isEqualTo("Alicia");
     }
 
     @Test
     public void testBuilder_setDisplayName_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayName("Alice")
                 .setDisplayName(null)
                 .build();
         assertThat(cr.getDisplayName()).isNull();
     }
 
-    @Test(expected = RequireViolation.class)
+    @Test
     public void testBuilder_setDisplayName_toEmpty() {
-        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayName("")
                 .build();
+
+        assertThat(cr.getDisplayName()).isNull();
     }
 
     public void testBuilder_setDisplayPicture() {
         Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayPicture(pictureUri)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
     }
 
     public void testBuilder_setDisplayPicture_twice() {
         Uri first = Uri.parse("https://robohash.org/alice@example.com");
         Uri second = Uri.parse("https://robohash.org/bob@example.com");
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayPicture(first)
                 .setDisplayPicture(second)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isSameAs(second);
     }
 
     public void testBuilder_setDisplayPicture_toNull() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
                 .setDisplayPicture((Uri)null)
                 .build();
 
         assertThat(cr.getDisplayPicture()).isNull();
     }
 
     @Test
     public void testBuilder_setAuthenticationMethod() {
         Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
                 .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
                 .build();
 
         assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
     }
 
     @Test
     public void testGetProto() {
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 ID_AND_PASSWORD,
                 new AuthenticationDomain("https://www.example.com")).build();
-        org.openyolo.proto.Credential proto = cr.getProto();
+        Protobufs.Credential proto = cr.getProto();
         assertThat(proto).isNotNull();
     }
 
     @Test
-    public void testWriteToParcel(){
+    public void testWriteAndRead(){
         Credential cr = new Credential.Builder(
                 EMAIL_ID,
                 ID_AND_PASSWORD,
-                new AuthenticationDomain("https://www.example.com")).build();
-        Parcel parcel = mock(Parcel.class);
-        cr.writeToParcel(parcel, 0);
-        verify(parcel).writeInt(anyInt());
-        verify(parcel).writeByteArray(any(byte[].class));
-    }
-    private Set<String> keys(String... keys) {
-        return new HashSet<>(Arrays.asList(keys));
+                new AuthenticationDomain("https://www.example.com"))
+                .setDisplayName("Alice")
+                .setPassword("h4ckm3")
+                .setDisplayPicture("https://www.robohash.org/alice")
+                .build();
+
+        // TODO: add some additional props and ensure these are preserved
+
+        Parcel p = Parcel.obtain();
+        cr.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        Credential readCredential = Credential.CREATOR.createFromParcel(p);
+
+        assertThat(readCredential.getIdentifier())
+                .isEqualTo(cr.getIdentifier());
+        assertThat(readCredential.getAuthenticationMethod())
+                .isEqualTo(cr.getAuthenticationMethod());
+        assertThat(readCredential.getAuthenticationDomain())
+                .isEqualTo(cr.getAuthenticationDomain());
+        assertThat(readCredential.getDisplayName())
+                .isEqualTo(cr.getDisplayName());
+        assertThat(readCredential.getDisplayPicture())
+                .isEqualTo(cr.getDisplayPicture());
+        assertThat(readCredential.getPassword())
+                .isEqualTo(cr.getPassword());
     }
 }
diff --git a/api/javatests/org/openyolo/api/HintRequestTest.java b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
similarity index 89%
rename from api/javatests/org/openyolo/api/HintRequestTest.java
rename to protocol/javatests/org/openyolo/protocol/HintRequestTest.java
index d1b75b8..35a2bb9 100644
--- a/api/javatests/org/openyolo/api/HintRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/HintRequestTest.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -22,3 +22,2 @@ import android.os.Parcel;
 import java.nio.charset.Charset;
-import java.util.Arrays;
 import java.util.HashMap;
@@ -26,7 +25,9 @@ import java.util.HashSet;
 import java.util.Set;
-import java.util.TreeMap;
-import org.assertj.core.data.MapEntry;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.proto.HintRetrieveRequest;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.HintRequest;
+import org.openyolo.protocol.IdentifierTypes;
+import org.openyolo.protocol.PasswordSpecification;
+import org.openyolo.protocol.Protobufs;
 import org.robolectric.RobolectricTestRunner;
@@ -36,434 +37,434 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Tests for {@link HintRequest}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class HintRequestTest {
 
     @Test
     public void testBuild() {
         PasswordSpecification originalSpec = new PasswordSpecification.Builder()
                 .ofLength(8, 10)
                 .allow(PasswordSpecification.ALPHANUMERIC)
                 .require(PasswordSpecification.NUMERALS, 1)
                 .build();
 
         HintRequest request = new HintRequest.Builder(
                 AuthenticationMethods.ID_AND_PASSWORD,
                 AuthenticationMethods.GOOGLE)
                 .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
                 .setIdentifierTypes(IdentifierTypes.EMAIL)
                 .addIdentifierType(IdentifierTypes.PHONE)
-                .addAdditionalParameter("a", new byte[] { 1, 2, 3})
-                .addAdditionalParameter("b", "hello")
+                .addAdditionalProperty("a", new byte[] { 1, 2, 3})
+                .addAdditionalProperty("b", "hello")
                 .setPasswordSpecification(originalSpec)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(
                         AuthenticationMethods.ID_AND_PASSWORD,
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getIdentifierTypes())
                 .containsOnly(
                         IdentifierTypes.EMAIL,
                         IdentifierTypes.PHONE);
 
-        assertThat(request.getAdditionalParameters())
+        assertThat(request.getAdditionalProperties())
                 .containsOnly(
                         entry("a", new byte[] {1, 2, 3}),
                         entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
 
         assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
 
-        assertThat(request.getAdditionalParameter("a")).isEqualTo(new byte[] {1, 2, 3});
-        assertThat(request.getAdditionalParameterAsString("b")).isEqualTo("hello");
+        assertThat(request.getAdditionalProperty("a")).isEqualTo(new byte[] {1, 2, 3});
+        assertThat(request.getAdditionalPropertyAsString("b")).isEqualTo("hello");
 
-        assertThat(request.getAdditionalParameter("c")).isNull();
-        assertThat(request.getAdditionalParameterAsString("d")).isNull();
+        assertThat(request.getAdditionalProperty("c")).isNull();
+        assertThat(request.getAdditionalPropertyAsString("d")).isNull();
     }
 
     @Test
     public void testBuild_overwriteAuthenticationMethods() {
         HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods(
                         AuthenticationMethods.GOOGLE,
                         AuthenticationMethods.FACEBOOK)
                 .build();
 
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testBuild_overwriteIdentityTypes() {
         HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes(IdentifierTypes.PHONE)
                 .setIdentifierTypes(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC)
                 .build();
 
         assertThat(request.getIdentifierTypes())
                 .containsOnly(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC);
     }
 
     @Test
     public void testForEmailAndPasswordAccount() {
         HintRequest request = HintRequest.forEmailAndPasswordAccount();
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
         assertThat(request.getIdentifierTypes())
                 .containsOnly(IdentifierTypes.EMAIL);
         assertThat(request.getPasswordSpecification())
                 .isEqualTo(PasswordSpecification.DEFAULT);
-        assertThat(request.getAdditionalParameters()).isEmpty();
+        assertThat(request.getAdditionalProperties()).isEmpty();
     }
 
     @Test
     public void testSerialize() {
         HintRequest request = new HintRequest.Builder(
                 AuthenticationMethods.ID_AND_PASSWORD,
                 AuthenticationMethods.FACEBOOK)
                 .setIdentifierTypes(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC)
                 .setPasswordSpecification(
                         new PasswordSpecification.Builder()
                                 .ofLength(10, 100)
                                 .allow(PasswordSpecification.ALPHANUMERIC)
                                 .require(PasswordSpecification.NUMERALS, 1)
                                 .build())
                 .build();
 
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             HintRequest read = HintRequest.CREATOR.createFromParcel(p);
 
             assertThat(read.getAuthenticationMethods())
                     .containsOnlyElementsOf(request.getAuthenticationMethods());
             assertThat(read.getIdentifierTypes())
                     .containsOnlyElementsOf(request.getIdentifierTypes());
             assertThat(read.getPasswordSpecification())
                     .isEqualTo(request.getPasswordSpecification());
         } finally {
             p.recycle();
         }
     }
 
     /* **************************** constraint violation test cases *******************************/
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullRequestProto() {
-        new HintRequest.Builder((HintRetrieveRequest) null).build();
+        new HintRequest.Builder((Protobufs.HintRetrieveRequest) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullAuthenticationMethod() {
         new HintRequest.Builder((Uri) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullString() {
         new HintRequest.Builder((String) null).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriSet() {
         new HintRequest.Builder((Set<Uri>) null).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullUriInVarargs() {
         new HintRequest.Builder(
                 AuthenticationMethods.ID_AND_PASSWORD,
                 null,
                 AuthenticationMethods.GOOGLE).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_nullStringInVarargs() {
         new HintRequest.Builder(
                 "custom://auth-method",
                 null,
                 "custom://another-auth-method")
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_invalidAuthMethodString() {
         new HintRequest.Builder("notAnAuthMethod").build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_emptySet() {
         new HintRequest.Builder(new HashSet<Uri>()).build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_constructor_setContainingNull() {
         HashSet<Uri> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(new HashSet<>(authMethods)).build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods((Uri) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods(
                         AuthenticationMethods.ID_AND_PASSWORD,
                         null,
                         AuthenticationMethods.GOOGLE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods((String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullStringInVarargs() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods(
                         "custom://auth-method",
                         null,
                         "custom://another-auth-method")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_nullSet() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods((Set<Uri>) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_emptySet() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods(new HashSet<Uri>())
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setAuthenticationMethods_setContainingNull() {
         HashSet<Uri> authMethods = new HashSet<>();
         authMethods.add(null);
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setAuthenticationMethods(authMethods)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addAuthenticationMethod((Uri) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_nullString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addAuthenticationMethod((String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_emptyString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addAuthenticationMethod("")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addAuthenticationMethod_invalidString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addAuthenticationMethod("notAnAuthMethod")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setIdentifierTypes_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes((Uri) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setIdentifierTypes_nullUriInVarargs() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes(
                         IdentifierTypes.EMAIL,
                         null,
                         IdentifierTypes.PHONE)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setIdentifierTypes_nullString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes((String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setIdentifierTypes_nullStringInVarargs() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes(
                         "custom://id-type",
                         null,
                         "custom://another-id-type")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setIdentifierTypes_nullSet() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes((Set<Uri>) null)
                 .build();
     }
 
     public void testBuild_setIdentifierTypes_emptySet() {
         HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes(new HashSet<Uri>())
                 .build();
 
         assertThat(request.getIdentifierTypes()).isEmpty();
     }
 
     @Test(expected = RequireViolation.class)
     public void testBuild_setIdentifierTypes_setContainingNull() {
         HashSet<Uri> idTypes = new HashSet<>();
         idTypes.add(null);
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setIdentifierTypes(idTypes)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addIdentifierType_nullUri() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addIdentifierType((Uri) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addIdentifierType_nullString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addIdentifierType((String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addIdentifierType_emptyString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addIdentifierType("")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_addIdentifierType_invalidString() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addIdentifierType("notAnIdTpye")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
-    public void testBuild_setAdditionalParameters_nullMap() {
+    public void testBuild_setAdditionalProperties_nullMap() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setAdditionalParameters(null)
+                .setAdditionalProperties(null)
                 .build();
     }
 
     @Test(expected = RequireViolation.class)
-    public void testBuild_setAdditionalParameters_nullKey() {
-        HashMap<String, byte[]> additionalParams = new HashMap<>();
-        additionalParams.put(null, new byte[0]);
+    public void testBuild_setAdditionalProperties_nullKey() {
+        HashMap<String, byte[]> additionalProps = new HashMap<>();
+        additionalProps.put(null, new byte[0]);
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setAdditionalParameters(additionalParams)
+                .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
-    public void testBuild_setAdditionalParameters_nullValue() {
-        HashMap<String, byte[]> additionalParams = new HashMap<>();
-        additionalParams.put("a", null);
+    public void testBuild_setAdditionalProperty_nullValue() {
+        HashMap<String, byte[]> additionalProps = new HashMap<>();
+        additionalProps.put("a", null);
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .setAdditionalParameters(additionalParams)
+                .setAdditionalProperties(additionalProps)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalParameter_nullKey() {
+    public void testBuild_addAdditionalProperty_nullKey() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addAdditionalParameter(null, "value")
+                .addAdditionalProperty(null, "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalParameter_emptyKey() {
+    public void testBuild_addAdditionalProperty_emptyKey() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addAdditionalParameter("", "value")
+                .addAdditionalProperty("", "value")
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalParameter_nullByteArrayValue() {
+    public void testBuild_addAdditionalProperty_nullByteArrayValue() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addAdditionalParameter("key", (byte[]) null)
+                .addAdditionalProperty("key", (byte[]) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
-    public void testBuild_addAdditionalParameter_nullStringValue() {
+    public void testBuild_addAdditionalProperty_nullStringValue() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addAdditionalParameter("key", (String) null)
+                .addAdditionalProperty("key", (String) null)
                 .build();
     }
 
     @SuppressWarnings("ConstantConditions")
     @Test(expected = RequireViolation.class)
     public void testBuild_setPasswordSpecification_null() {
         new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .setPasswordSpecification(null)
                 .build();
     }
 }
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/PasswordSpecificationTest.java b/protocol/javatests/org/openyolo/protocol/PasswordSpecificationTest.java
similarity index 91%
rename from api/javatests/org/openyolo/api/PasswordSpecificationTest.java
rename to protocol/javatests/org/openyolo/protocol/PasswordSpecificationTest.java
index f9181ed..c745ec1 100644
--- a/api/javatests/org/openyolo/api/PasswordSpecificationTest.java
+++ b/protocol/javatests/org/openyolo/protocol/PasswordSpecificationTest.java
@@ -17,3 +17,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -23,25 +23,15 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyListOf;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.openyolo.api.PasswordSpecification.ALPHANUMERIC;
-import static org.openyolo.api.PasswordSpecification.ALPHANUMERIC_DISTINGUISHABLE;
-import static org.openyolo.api.PasswordSpecification.LOWER_ALPHA;
-import static org.openyolo.api.PasswordSpecification.LOWER_ALPHA_DISTINGUISHABLE;
-import static org.openyolo.api.PasswordSpecification.NUMERALS;
-import static org.openyolo.api.PasswordSpecification.PASSWORD_CONFORMS;
-import static org.openyolo.api.PasswordSpecification.PASSWORD_DISALLOWED_CHARACTER;
-import static org.openyolo.api.PasswordSpecification.PASSWORD_LENGTH_MISMATCH;
-import static org.openyolo.api.PasswordSpecification.PASSWORD_REQUIRED_CHARACTER_MISSING;
-import static org.openyolo.api.PasswordSpecification.UPPER_ALPHA;
-import static org.openyolo.api.PasswordSpecification.UPPER_ALPHA_DISTINGUISHABLE;
+import static org.openyolo.protocol.PasswordSpecification.ALPHANUMERIC;
+import static org.openyolo.protocol.PasswordSpecification.LOWER_ALPHA;
+import static org.openyolo.protocol.PasswordSpecification.NUMERALS;
+import static org.openyolo.protocol.PasswordSpecification.PASSWORD_CONFORMS;
+import static org.openyolo.protocol.PasswordSpecification.PASSWORD_DISALLOWED_CHARACTER;
+import static org.openyolo.protocol.PasswordSpecification.PASSWORD_LENGTH_MISMATCH;
+import static org.openyolo.protocol.PasswordSpecification.PASSWORD_REQUIRED_CHARACTER_MISSING;
+import static org.openyolo.protocol.PasswordSpecification.UPPER_ALPHA;
 
 import android.os.Parcel;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openyolo.protocol.PasswordSpecification;
 import org.robolectric.RobolectricTestRunner;
diff --git a/api/javatests/org/openyolo/api/RetrieveRequestTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
similarity index 82%
rename from api/javatests/org/openyolo/api/RetrieveRequestTest.java
rename to protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
index e84a18d..e70cef4 100644
--- a/api/javatests/org/openyolo/api/RetrieveRequestTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveRequestTest.java
@@ -17,3 +17,3 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
@@ -31,3 +31,5 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.proto.CredentialRetrieveRequest;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.RetrieveRequest;
 import org.robolectric.RobolectricTestRunner;
@@ -36,98 +38,98 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveRequestTest {
 
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
     private RetrieveRequest request;
 
     @Before
     public void setUp() {
         request = new RetrieveRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
-                .addAdditionalParameter("a", "b")
-                .addAdditionalParameter("c", testBytes)
+                .addAdditionalProperty("a", "b")
+                .addAdditionalProperty("c", testBytes)
                 .build();
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
-                    deserialized.getAdditionalParameters(),
-                    request.getAdditionalParameters());
+                    deserialized.getAdditionalProperties(),
+                    request.getAdditionalProperties());
         } finally {
             p.recycle();
         }
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
         new RetrieveRequest.Builder(new HashSet<Uri>()  /* authenticationMethods */);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
-        new RetrieveRequest.Builder((CredentialRetrieveRequest) null);
+        new RetrieveRequest.Builder((Protobufs.CredentialRetrieveRequest) null);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         RetrieveRequest request = RetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<Uri> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
-    public void testGetAdditionalParameters() {
-        assertThat(request.getAdditionalParameters()).isNotNull();
-        assertThat(request.getAdditionalParameters()).hasSize(2);
-        assertThat(request.getAdditionalParameterAsString("a")).isEqualTo("b");
-        assertThat(request.getAdditionalParameter("c")).isEqualTo(testBytes);
+    public void testGetAdditionalProperties() {
+        assertThat(request.getAdditionalProperties()).isNotNull();
+        assertThat(request.getAdditionalProperties()).hasSize(2);
+        assertThat(request.getAdditionalPropertyAsString("a")).isEqualTo("b");
+        assertThat(request.getAdditionalProperty("c")).isEqualTo(testBytes);
     }
 
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
-        CredentialRetrieveRequest.ADAPTER.decode((byte[]) null);
+        Protobufs.CredentialRetrieveRequest.parseFrom((byte[]) null);
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/RetrieveResultTest.java b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
similarity index 60%
rename from api/javatests/org/openyolo/api/RetrieveResultTest.java
rename to protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
index c0ec19d..0816f67 100644
--- a/api/javatests/org/openyolo/api/RetrieveResultTest.java
+++ b/protocol/javatests/org/openyolo/protocol/RetrieveResultTest.java
@@ -17,8 +17,9 @@
 
-package org.openyolo.api;
+package org.openyolo.protocol;
 
 import static junit.framework.TestCase.assertNotNull;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
 import android.content.Intent;
-import android.os.Parcelable;
+import android.os.Parcel;
 import java.util.HashMap;
@@ -29,4 +30,5 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.api.internal.IntentUtil;
-import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.protocol.Protobufs;
+import org.openyolo.protocol.RetrieveResult;
+import org.openyolo.protocol.internal.IntentUtil;
 import org.robolectric.RobolectricTestRunner;
@@ -36,56 +38,75 @@ import org.valid4j.errors.RequireViolation;
 /**
  * Battery of tests for the RetrieveIntent class
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveResultTest {
 
     private RetrieveResult underTest;
 
     @Before
     public void setUp() throws Exception {
         Intent fromIntent = new Intent("com.openyolo.ACTION");
         fromIntent.setPackage("com.openyolo");
         byte[] fromBytes = IntentUtil.toBytes(fromIntent);
         Intent retrieveIntent= IntentUtil.fromBytes(fromBytes);
 
-        Map<String, CredentialRetrieveResponse> protoResponses = new HashMap<>();
+        Map<String, Protobufs.CredentialRetrieveResponse> protoResponses = new HashMap<>();
 
         underTest = new RetrieveResult.Builder()
                 .setProtoResponses(protoResponses)
                 .setRetrieveIntent(retrieveIntent)
                 .build();
     }
 
-    @Test
-    public void testInnerClassNewArray(){
-        int size = 10;
-        Parcelable.Creator<RetrieveResult> creator = new RetrieveResult.RetrieveResultCreator();
-        RetrieveResult[] result = creator.newArray(size);
-        assertEquals(size, result.length);
-
-    }
-
     @Test
     public void testGetRetrieveIntent(){
         Intent intent = underTest.getRetrieveIntent();
         assertNotNull(intent);
     }
 
     @Test
     public void testGetResponderPackageNames(){
         Set<String> responders = underTest.getResponderPackageNames();
         assertNotNull(responders);
     }
 
     @Test(expected = RequireViolation.class)
     public void testGetRetrieveIntentForResponder_null(){
         underTest.getRetrieveIntentForResponder(null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testGetRetrieveIntentForResponder_illegal(){
         underTest.getRetrieveIntentForResponder("BLahblah");
     }
 
-}
\ No newline at end of file
+    @Test
+    public void testWriteAndRead() {
+        Parcel p = Parcel.obtain();
+        underTest.writeToParcel(p, 0);
+        p.setDataPosition(0);
+
+        RetrieveResult result = RetrieveResult.CREATOR.createFromParcel(p);
+        checkIntentsEquivalent(underTest.getRetrieveIntent(), result.getRetrieveIntent());
+        assertThat(result.getResponderPackageNames())
+                .isEqualTo(underTest.getResponderPackageNames());
+
+        for (String responder : result.getResponderPackageNames()) {
+            checkIntentsEquivalent(
+                    underTest.getRetrieveIntentForResponder(responder),
+                    result.getRetrieveIntentForResponder(responder));
+
+            assertThat(result.getAdditionalPropsForResponder(responder))
+                    .isEqualTo(underTest.getAdditionalPropsForResponder(responder));
+        }
+    }
+
+    private void checkIntentsEquivalent(Intent expected, Intent actual) {
+        // NOTE: we don't check the full intent, just the basic properties
+        assertThat(actual.getPackage())
+                .isEqualTo(expected.getPackage());
+        assertThat(actual.getAction())
+                .isEqualTo(expected.getAction());
+    }
+}
diff --git a/api/javatests/org/openyolo/api/internal/CustomMatchersTest.java b/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
similarity index 97%
rename from api/javatests/org/openyolo/api/internal/CustomMatchersTest.java
rename to protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
index a497e23..bfc6f84 100644
--- a/api/javatests/org/openyolo/api/internal/CustomMatchersTest.java
+++ b/protocol/javatests/org/openyolo/protocol/internal/CustomMatchersTest.java
@@ -17,3 +17,3 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
@@ -26,3 +26,3 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.protocol.AuthenticationMethods;
 import org.robolectric.RobolectricTestRunner;
diff --git a/api/javatests/org/openyolo/api/internal/IntentUtilTest.java b/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
similarity index 96%
rename from api/javatests/org/openyolo/api/internal/IntentUtilTest.java
rename to protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
index 3bcf812..87462d3 100644
--- a/api/javatests/org/openyolo/api/internal/IntentUtilTest.java
+++ b/protocol/javatests/org/openyolo/protocol/internal/IntentUtilTest.java
@@ -17,3 +17,3 @@
 
-package org.openyolo.api.internal;
+package org.openyolo.protocol.internal;
 
@@ -21,2 +21,3 @@ import static junit.framework.TestCase.assertTrue;
 import static org.junit.Assert.assertEquals;
+
 import android.content.Intent;
@@ -24,3 +25,2 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.api.internal.IntentUtil;
 import org.robolectric.RobolectricTestRunner;
diff --git a/protocol/javatests/org/openyolo/protocol/internal/package-info.java b/protocol/javatests/org/openyolo/protocol/internal/package-info.java
new file mode 100644
index 0000000..61be35b
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/internal/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tests for internal utilities and types.
+ */
+package org.openyolo.protocol.internal;
diff --git a/protocol/javatests/org/openyolo/protocol/package-info.java b/protocol/javatests/org/openyolo/protocol/package-info.java
new file mode 100644
index 0000000..18e3d3c
--- /dev/null
+++ b/protocol/javatests/org/openyolo/protocol/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tests for OpenYOLO Protocol core types.
+ */
+package org.openyolo.protocol;
diff --git a/protocol/proto/openyolo.proto b/protocol/proto/openyolo.proto
new file mode 100644
index 0000000..a5388f7
--- /dev/null
+++ b/protocol/proto/openyolo.proto
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto3";
+
+package org.openyolo;
+
+option java_package = "org.openyolo.protocol";
+option java_outer_classname = "Protobufs";
+
+message CredentialRetrieveRequest {
+    // at least one authMethod required
+    repeated string authMethods = 1;
+    map<string, TokenRequestInfo> supportedTokenProviders = 2;
+    map<string, bytes> additionalProps = 3;
+}
+
+message CredentialRetrieveResponse {
+    bytes retrieveIntent = 1;
+    map<string, bytes> additionalProps = 2;
+}
+
+message CredentialRetrieveResponseList {
+    repeated CredentialRetrieveResponse responses = 1;
+}
+
+message HintRetrieveRequest {
+    // at least one authMethod required
+    repeated string authMethods = 1;
+
+    // at least one idType required
+    repeated string idTypes = 2;
+
+    PasswordSpecification passwordSpec = 3;
+    map<string, TokenRequestInfo> supportedTokenProviders = 4;
+    map<string, bytes> additionalProps = 5;
+}
+
+message HintRetrieveResponse {
+    bytes retrieveIntent = 1; // required
+    map<string, bytes> additionalProps = 2;
+}
+
+message HintRetrieveResponseList {
+    repeated HintRetrieveResponse responses = 1;
+}
+
+message TokenRequestInfo {
+    string clientId = 1;
+    string nonce = 2;
+    map<string, bytes> additionalProps = 3;
+}
+
+message Credential {
+    // required fields:
+    string id = 1;
+    string authDomain = 2;
+    string authMethod = 3;
+
+    // optional fields:
+    string displayName = 4;
+    string displayPictureUri = 5;
+    string password = 6;
+    string idToken = 7;
+    map<string, bytes> additionalProps = 8;
+}
+
+message CredentialList {
+    repeated Credential credentials = 1;
+}
+
+message PasswordSpecification {
+    // required fields:
+    string allowed = 1;
+    uint32 minSize = 2;
+    uint32 maxSize = 3;
+
+    // optional:
+    repeated RequiredCharSet requiredSets = 4;
+}
+
+message RequiredCharSet {
+    // all fields required
+    string chars = 1;
+    uint32 count = 2;
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index bf89c77..bd31ac3 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':bbq', ':api', ':spi', ':testapp', ':demoproviders:barbican', ':demoproviders:trapdoor'
+include ':bbq', ':protocol', ':api', ':spi', ':testapp', ':demoproviders:barbican', ':demoproviders:trapdoor'
diff --git a/spi/AndroidManifest.xml b/spi/AndroidManifest.xml
index 67d2d97..c4c09eb 100644
--- a/spi/AndroidManifest.xml
+++ b/spi/AndroidManifest.xml
@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.openyolo.spi">
+<manifest package="org.openyolo.spi">
 
 </manifest>
diff --git a/spi/build.gradle b/spi/build.gradle
index 8e33c9f..192fa00 100644
--- a/spi/build.gradle
+++ b/spi/build.gradle
@@ -11,6 +11,8 @@ android {
 dependencies {
-    compile project(':api')
+    compile project(':bbq')
+    compile project(':protocol')
+
     compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
     compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     apply from:'../config/testdeps.gradle', to:it
 }
diff --git a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
index 7d16e8d..430f116 100644
--- a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
+++ b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
@@ -20,4 +20,4 @@ import android.util.Log;
 import com.google.bbq.BaseBroadcastQueryReceiver;
+import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import com.google.bbq.proto.BroadcastQuery;
 import java.io.IOException;
@@ -25,60 +25,63 @@ import java.util.HashSet;
 import java.util.Set;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.RetrieveRequest;
-import org.openyolo.proto.CredentialRetrieveRequest;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveRequest;
+import org.openyolo.protocol.RetrieveRequest;
 
 /**
  * Partial implementation of an OpenYOLO request receiver, that should be extended by providers.
  * This implementation handles some basic validation and decoding of the request before
  * handing the request to
  * {@link #processCredentialRequest(Context, BroadcastQuery, RetrieveRequest, Set)}.
  */
 public abstract class BaseCredentialQueryReceiver extends BaseBroadcastQueryReceiver {
 
     /**
      * Creates a receiver that will log errors to the specified log tag.
      */
     public BaseCredentialQueryReceiver(String logTag) {
         super(logTag);
     }
 
     @Override
     protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
         CredentialRetrieveRequest requestProto;
+
         try {
-            requestProto = CredentialRetrieveRequest.ADAPTER.decode(query.queryMessage);
+            requestProto = CredentialRetrieveRequest.parseFrom(query.getQueryMessage());
         } catch (NullPointerException | IOException ex) {
             Log.w(mLogTag, "Failed to parse credential request message", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         RetrieveRequest request;
         try {
             request = new RetrieveRequest.Builder(requestProto).build();
         } catch (NullPointerException | IllegalArgumentException ex) {
             Log.w(mLogTag, "Credential request message failed field validation", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         // TODO: validate claimed authentication domains
         Set<AuthenticationDomain> requestorDomains =
-                new HashSet<>(AuthenticationDomain.listForPackage(context, query.requestingApp));
+                new HashSet<>(AuthenticationDomain.listForPackage(
+                    context,
+                    query.getRequestingApp()));
 
         // Ensure the authentication domain of the requesting app can be determined
         if (requestorDomains.isEmpty()) {
             Log.w(mLogTag, "Unable to determine the authentication domain of the requesting app");
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         processCredentialRequest(context, query, request, requestorDomains);
     }
 
     protected abstract void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains);
 }
diff --git a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
index 6ad612b..41ab721 100644
--- a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
+++ b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
@@ -18,21 +18,21 @@ import android.content.Intent;
 import android.support.annotation.Nullable;
-import org.openyolo.api.CredentialClient;
-import org.openyolo.proto.Credential;
+import org.openyolo.protocol.Protobufs.Credential;
+import org.openyolo.protocol.ProtocolConstants;
 
 /**
  * Utility methods for expressing and manipulating the result of a credential retrieve intent.
  */
 public final class RetrieveIntentResultUtil {
 
     /**
      * Creates an {@link android.content.Intent} wrapper for the result of a credential retrieve
      * intent.
      */
     public static Intent createResponseData(@Nullable Credential credential) {
         Intent responseData = new Intent();
         if (credential != null) {
-            responseData.putExtra(CredentialClient.EXTRA_CREDENTIAL, credential.encode());
+            responseData.putExtra(ProtocolConstants.EXTRA_CREDENTIAL, credential.toByteArray());
         }
         return responseData;
     }
 }
diff --git a/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java b/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
index e61c54c..b0414f1 100644
--- a/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
+++ b/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
@@ -23,3 +23,2 @@ import android.text.TextUtils;
 import android.util.Log;
-
 import java.util.ArrayList;
@@ -27,51 +26,50 @@ import java.util.Collections;
 import java.util.List;
-
-import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationDomain;
 import org.openyolo.spi.assetlinks.data.AndroidAssetStatement;
 import org.openyolo.spi.assetlinks.data.AssetStatement;
 
 /**
  * <p>
- * This class loads the {@link org.openyolo.api.AuthenticationDomain}s for the 'source'
+ * This class loads the {@link AuthenticationDomain}s for the 'source'
  * (client) and 'target' asset statements and finds the ones that are bidirectional.  That is,
  * where the source and target apps grant the same relations to each other.
  * </p>
  *
  * <p>Example for looking-up bidirectional relationships:</p>
  *
  * <pre>
  * {@code
  *
  * private void loadRelatedAuthDomains(Context context, String requestedAppPackage) {
  *      // get the asset statements for the requesting/client app
  *      List<AssetStatement> sourceAssetStatements = getSourceAssetStatements
  *               (context, requestedAppPackage);
  *
  *      TargetAssetStatementLoader assetStatementLoader = new
  *               TargetAssetStatementLoader(context, sourceAssetStatements);
  *
  *      // get all 'related' target asset statements - those referenced in the client app's
  *      // asset statements
  *      List<AssetStatement> targetAssetStatements = assetStatementLoader
  *               .getRelatedAssetStatements();
  *
  *      AssetRelationshipHelper assetRelationshipHelper = new
  *               AssetRelationshipHelper(context, requestedAppPackage, sourceAssetStatements,
  *                targetAssetStatements);
  *
  *      List<AuthenticationDomain> bidirectionalAuthDomains =
  *               assetRelationshipHelper.getBidirectionalAuthDomains();
  * }
  *
  * private List<AssetStatement> getSourceAssetStatements(Context context, String packageName) {
  *      String clientAssetStatements = AssetStatementsUtil.getAssetStatements(context,
  *               packageName);
  *      return parseAssetStatementsJson(clientAssetStatements);
  * }
  *
  * private List<AssetStatement> parseAssetStatementsJson(String json) {
  *      return AssetStatementsFactory.INSTANCE.createAssetStatements(json);
  * }
  *}
  * </pre>
  */
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java
index 90e2a32..aea0697 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java
@@ -20,3 +20,2 @@ import static org.valid4j.Assertive.require;
 import android.support.annotation.NonNull;
-
 import java.util.List;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java
index 14d20ae..16c127f 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java
@@ -23,3 +23,2 @@ import android.text.TextUtils;
 import android.util.Log;
-
 import java.util.ArrayList;
@@ -27,3 +26,2 @@ import java.util.Collections;
 import java.util.List;
-
 import org.json.JSONArray;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java b/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java
index 507bdee..51fa169 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java
@@ -20,3 +20,2 @@ import android.text.TextUtils;
 import android.util.Log;
-
 import java.util.ArrayList;
@@ -25,3 +24,2 @@ import java.util.Collections;
 import java.util.List;
-
 import org.json.JSONArray;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java b/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java
index 20b36dc..d968dba 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java
@@ -17,3 +17,2 @@ package org.openyolo.spi.assetlinks.data;
 import android.util.Patterns;
-
 import java.util.ArrayList;
@@ -21,3 +20,2 @@ import java.util.Collections;
 import java.util.List;
-
 import org.json.JSONArray;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java
index f6cddc0..4754a25 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java
@@ -22,6 +22,4 @@ import android.support.annotation.NonNull;
 import android.util.Log;
-
 import java.util.Collections;
 import java.util.List;
-
 import org.json.JSONObject;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java
index 0c60ffd..382d5f0 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java
@@ -20,3 +20,2 @@ import static org.valid4j.Assertive.require;
 import android.support.annotation.NonNull;
-
 import java.util.Collections;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java
index 2b432ea..9761ee6 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java
@@ -22,3 +22,2 @@ import android.support.annotation.NonNull;
 import android.util.Log;
-
 import java.util.ArrayList;
@@ -26,3 +25,2 @@ import java.util.Collections;
 import java.util.List;
-
 import org.json.JSONArray;
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java
index 32b8639..33469f0 100644
--- a/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java
+++ b/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java
@@ -20,3 +20,2 @@ import static org.valid4j.Assertive.require;
 import android.support.annotation.NonNull;
-
 import java.util.List;
diff --git a/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java
index d3e8a4a..f48c06f 100644
--- a/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java
+++ b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java
@@ -28,3 +28,2 @@ import android.text.TextUtils;
 import android.util.Log;
-
 import java.security.MessageDigest;
@@ -34,3 +33,2 @@ import java.util.Collections;
 import java.util.List;
-
 import org.openyolo.spi.AssetStatementsUtil;
diff --git a/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java
index d3daeca..6a81be5 100644
--- a/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java
+++ b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java
@@ -21,6 +21,4 @@ import android.content.Context;
 import android.support.annotation.NonNull;
-
 import java.util.ArrayList;
 import java.util.List;
-
 import org.openyolo.spi.assetlinks.data.AndroidAssetStatement;
diff --git a/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java b/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java
index 8b7f12d..7921966 100644
--- a/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java
+++ b/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java
@@ -19,3 +19,2 @@ package org.openyolo.spi;
 
-import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -26,2 +25,3 @@ import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.when;
+
 import android.content.Context;
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
index 780016c..404eb13 100644
--- a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -30,3 +30,4 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import com.google.bbq.proto.BroadcastQuery;
+import com.google.bbq.Protobufs.BroadcastQuery;
+import com.google.protobuf.ByteString;
 import java.util.ArrayList;
@@ -35,3 +36,2 @@ import java.util.List;
 import java.util.Set;
-import okio.ByteString;
 import org.junit.Before;
@@ -41,6 +41,5 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.RetrieveRequest;
-import org.openyolo.proto.CredentialRetrieveRequest;
-import org.openyolo.proto.KeyValuePair;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Protobufs.CredentialRetrieveRequest;
+import org.openyolo.protocol.RetrieveRequest;
 import org.robolectric.RobolectricTestRunner;
@@ -49,169 +48,153 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link BaseCredentialQueryReceiver}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE,
         shadows = {
                 ShadowQueryResponseSender.class,
                 ShadowAuthenticationDomain.class
         })
 public class BaseCredentialQueryReceiverTest {
 
     private BaseCredentialQueryReceiver credentialQueryReceiver;
 
     @Mock
     Context mockContext;
 
     private static final String CALLING_PACKAGE_NAME = "org.openyolo.supercoolapp";
 
     private static final BroadcastQuery QUERY_WITH_NULL_MESSAGE =
             makeQueryFromRequest(null /* request */);
 
     private static final BroadcastQuery QUERY_WITH_INVALID_REQUEST =
             makeQueryFromRequest(makeInvalidCredentialRetrieveRequest());
 
     private static final BroadcastQuery QUERY_WITH_VALID_REQUEST =
             makeQueryFromRequest(makeValidCredentialRetrieveRequest());
 
     private static final List<AuthenticationDomain> VALID_AUTHENTICATION_DOMAINS =
             makeValidAuthenticationDomains();
 
 
-    private static final BroadcastQuery makeQueryFromRequest(
+    private static BroadcastQuery makeQueryFromRequest(
             @Nullable CredentialRetrieveRequest request) {
-        ByteString queryMessage = null;
-        if (null != request) {
-            queryMessage = ByteString.of(CredentialRetrieveRequest.ADAPTER.encode(request));
+        BroadcastQuery.Builder builder = BroadcastQuery.newBuilder()
+                .setRequestingApp(CALLING_PACKAGE_NAME)
+                .setDataType("blah")
+                .setRequestId(101L)
+                .setResponseId(102L);
+
+        if (request != null) {
+            builder.setQueryMessage(ByteString.copyFrom(request.toByteArray()));
         }
 
-        return new BroadcastQuery.Builder()
-                .requestingApp(CALLING_PACKAGE_NAME)
-                .dataType("blah")
-                .requestId(101L)
-                .responseId(102L)
-                .queryMessage(queryMessage)
-                .build();
+        return builder.build();
     }
 
     private static List<AuthenticationDomain> makeValidAuthenticationDomains() {
         List<AuthenticationDomain> authenticationDomains = new ArrayList<>();
         authenticationDomains.add(mock(AuthenticationDomain.class));
 
         return authenticationDomains;
     }
 
     private static CredentialRetrieveRequest makeInvalidCredentialRetrieveRequest() {
-        List<String> authDomains = new ArrayList<>();
-        List<String> authMethods = new ArrayList<>();
-        List<KeyValuePair> additionalParams = new ArrayList<>();
-
         // Invalid because it does not specify a non-empty set of authentication method
-        return new CredentialRetrieveRequest(
-                authDomains,
-                authMethods,
-                additionalParams,
-                ByteString.EMPTY);
+        return CredentialRetrieveRequest.newBuilder().build();
     }
 
     private static CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
-        List<String> authDomains = new ArrayList<>();
-        List<String> authMethods = new ArrayList<>();
-        authMethods.add("custom://one");
-        authMethods.add("custom://two");
-        List<KeyValuePair> additionalParams = new ArrayList<>();
-
-        return new CredentialRetrieveRequest(
-                authDomains,
-                authMethods,
-                additionalParams,
-                ByteString.EMPTY);
+        return CredentialRetrieveRequest.newBuilder()
+            .addAuthMethods("custom://one")
+            .addAuthMethods("custom://two")
+            .build();
     }
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         ShadowQueryResponseSender.intializeForTest();
 
         credentialQueryReceiver = spy(
                 new BaseCredentialQueryReceiver("TestCredentialQueryReceiver") {
                     @Override
                     protected void processCredentialRequest(
                             @NonNull Context context,
                             @NonNull BroadcastQuery query,
                             @NonNull RetrieveRequest request,
                             @NonNull Set<AuthenticationDomain> requestorDomains) {
                         // Do nothing
                     }
                 });
 
         ShadowAuthenticationDomain.setListForPackageResponse(VALID_AUTHENTICATION_DOMAINS);
     }
 
     @Test
     public void processQuery_withNullQuery_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_NULL_MESSAGE);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withInvalidRequest_sendsNullResponse() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_INVALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
     public void processQuery_withValidRequest_processesRequest() throws Exception {
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasCalled();
         verifyQueryResponseIsNotSent();
     }
 
     @Test
     public void processQuery_withValidRequestAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
             throws Exception {
         ShadowAuthenticationDomain.setListForPackageResponse(Collections.EMPTY_LIST);
         credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     private void verifyQueryResponseIsNotSent() {
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(0))
                 .sendResponse((BroadcastQuery) any(), (byte[]) any());
     }
 
     private void verifyQueryResponseIsSentWith(@Nullable byte[] response) {
         if (null == response) {
             verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                     .sendResponse((BroadcastQuery) any(), (byte[]) isNull());
             return;
         }
 
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                 .sendResponse((BroadcastQuery) any(), eq(response));
     }
 
     private void verifyProcessCredentialRequestWasCalled() {
         verify(credentialQueryReceiver, times(1))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (RetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 
     private void verifyProcessCredentialRequestWasNotCalled() {
         verify(credentialQueryReceiver, times(0))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (RetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
index 28627f7..2057405 100644
--- a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
+++ b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
@@ -21,3 +21,4 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.openyolo.api.AuthenticationMethods.ID_AND_PASSWORD;
+import static org.openyolo.protocol.AuthenticationMethods.ID_AND_PASSWORD;
+
 import android.content.Intent;
@@ -26,5 +27,5 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.Credential;
-import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.ProtocolConstants;
 import org.robolectric.RobolectricTestRunner;
@@ -33,27 +34,27 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveIntentResultUtil
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveIntentResultUtilTest {
     public static final String EMAIL_ID = "alice@example.com";
     private String base64string = "ChFhbGljZUBleGFtcGxlLmNvbRIXaHR0cHM6Ly93d3cuZXhhbXBsZS5jb20aGm9wZW55b2xvOi8v\naWQtYW5kLXBhc3N3b3Jk\n";
 
     @Test
     public void testCreateResponseData() throws Exception {
         Credential cr = new Credential.Builder( EMAIL_ID, ID_AND_PASSWORD,
         new AuthenticationDomain("https://www.example.com")).build();
         Intent reposnse = RetrieveIntentResultUtil.createResponseData(cr.getProto());
-        byte[] bytes = reposnse.getExtras().getByteArray(CredentialClient.EXTRA_CREDENTIAL);
+        byte[] bytes = reposnse.getExtras().getByteArray(ProtocolConstants.EXTRA_CREDENTIAL);
         assertEquals(bytes.length, 72);
         String data = Base64.encodeToString(bytes, Base64.DEFAULT);
         assertEquals(base64string, data);
     }
 
     @Test
     public void testCreateResponseData_withNull() throws Exception {
         Intent reposnse = RetrieveIntentResultUtil.createResponseData(null);
         assertNull(reposnse.getExtras());
     }
 
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java b/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
index eae5017..4136fdf 100644
--- a/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
+++ b/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
@@ -7,3 +7,3 @@ import java.util.Collections;
 import java.util.List;
-import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationDomain;
 import org.robolectric.annotation.Implementation;
diff --git a/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java b/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java
index a3c4953..9cbfb60 100644
--- a/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java
+++ b/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java
@@ -6,4 +6,4 @@ import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import com.google.bbq.Protobufs.BroadcastQuery;
 import com.google.bbq.QueryResponseSender;
-import com.google.bbq.proto.BroadcastQuery;
 import org.robolectric.annotation.Implementation;
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java
index 1cee929..b79b635 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java
@@ -19,3 +19,4 @@ package org.openyolo.spi.assetlinks;
 import android.content.Context;
-
+import java.util.Collections;
+import java.util.List;
 import org.junit.Test;
@@ -28,9 +29,6 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.Collections;
-import java.util.List;
-
 /**
  * Tests for {@link AssetRelationshipHelper}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java
index 17b394e..dbb43cb 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java
@@ -21,2 +21,3 @@ import static junit.framework.Assert.assertTrue;
 
+import java.util.List;
 import org.json.JSONObject;
@@ -28,8 +29,6 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.List;
-
 /**
  * Tests for {@link AndroidAssetStatementDeserializer}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java
index c2be457..ab2d116 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java
@@ -18,2 +18,3 @@ package org.openyolo.spi.assetlinks.data;
 
+import java.util.Arrays;
 import org.junit.Test;
@@ -21,6 +22,4 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.Arrays;
-
 /**
  * Tests for {@link AndroidAssetStatement).
  */
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java
index 3450804..f42fed4 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java
@@ -21,6 +21,2 @@ import static org.openyolo.spi.assetlinks.data.RelationType.GetLoginCreds;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
 import java.util.Arrays;
@@ -28,6 +24,9 @@ import java.util.Collection;
 import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
 /**
  * Tests for {@link AssetStatement}
  */
 @RunWith(Parameterized.class)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java
index b0de0b0..e098984 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java
@@ -19,2 +19,7 @@ package org.openyolo.spi.assetlinks.data;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.List;
 import org.junit.Test;
@@ -24,12 +29,6 @@ import org.robolectric.annotation.Config;
 
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-
 /**
  * Tests for {@link AssetStatementsFactory}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java
index aa55f5d..30de1ce 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java
@@ -18,2 +18,6 @@ package org.openyolo.spi.assetlinks.data;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
 import org.json.JSONArray;
@@ -26,10 +30,6 @@ import org.robolectric.annotation.Config;
 
-import java.util.List;
-
-import static org.junit.Assert.*;
-
 /**
  * Tests for {@link DeserializerUtil}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java
index 65e6b7d..88f83dc 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java
@@ -21,2 +21,3 @@ import static junit.framework.Assert.assertTrue;
 
+import java.util.List;
 import org.json.JSONObject;
@@ -28,8 +29,6 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.List;
-
 /**
  * Tests for {@link IncludeAssetStatementDeserializer}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java
index ef4123b..9a28d8f 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java
@@ -18,5 +18,2 @@ package org.openyolo.spi.assetlinks.data;
 
-import org.junit.Test;
-import org.valid4j.errors.RequireViolation;
-
 import static junit.framework.Assert.assertEquals;
@@ -24,5 +21,8 @@ import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertTrue;
 
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
 /**
  * Tests for {@link IncludeStatement}
  */
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java
index 847eb8f..6725d23 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java
@@ -19,4 +19,2 @@ package org.openyolo.spi.assetlinks.data;
 
-import org.junit.Test;
-
 import static junit.framework.Assert.assertNotNull;
@@ -24,5 +22,7 @@ import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.assertTrue;
 
+import org.junit.Test;
+
 /**
  * Tests for {@link NamespaceType}.
  */
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java
index 624fa0a..d81e200 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java
@@ -19,4 +19,2 @@ package org.openyolo.spi.assetlinks.data;
 
-import org.junit.Test;
-
 import static junit.framework.Assert.assertNotNull;
@@ -25,2 +23,4 @@ import static junit.framework.Assert.assertTrue;
 
+import org.junit.Test;
+
 public class RelationTypeTest {
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java
index 40bba93..c095ee7 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java
@@ -21,2 +21,3 @@ import static junit.framework.Assert.assertTrue;
 
+import java.util.List;
 import org.json.JSONObject;
@@ -28,8 +29,6 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.List;
-
 /**
  * Tests for {@link WebAssetStatementDeserializer}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java
index 9bec98e..2a76a90 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java
@@ -18,2 +18,3 @@ package org.openyolo.spi.assetlinks.data;
 
+import java.util.Arrays;
 import org.junit.Test;
@@ -21,6 +22,4 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.Arrays;
-
 /**
  * Test for {@link WebSiteAssetStatement}
  */
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java
index 726c0ca..1e2bd46 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java
@@ -19,2 +19,9 @@ package org.openyolo.spi.assetlinks.loader;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.openyolo.spi.assetlinks.data.RelationType.GetLoginCreds;
+import static org.openyolo.spi.assetlinks.data.RelationType.HandleAllUrls;
+
+import java.util.Arrays;
+import java.util.List;
 import org.junit.Test;
@@ -27,12 +34,4 @@ import org.openyolo.spi.assetlinks.data.WebTarget;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.*;
-import static org.openyolo.spi.assetlinks.data.RelationType.GetLoginCreds;
-import static org.openyolo.spi.assetlinks.data.RelationType.HandleAllUrls;
-
 /**
  * Tests for {@link TargetAndroidAssetStatementLoader}.
  */
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java
index 4ae3b93..8f95c2a 100644
--- a/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java
@@ -21,3 +21,4 @@ package org.openyolo.spi.assetlinks.loader;
 import android.content.Context;
-
+import java.util.Collections;
+import java.util.List;
 import org.junit.Test;
@@ -30,9 +31,6 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.Collections;
-import java.util.List;
-
 /**
  * Tests for {@link TargetAssetStatementLoader}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
diff --git a/spi/javatests/java/org/openyolo/spi/package-info.java b/spi/javatests/java/org/openyolo/spi/package-info.java
new file mode 100644
index 0000000..6c5618d
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tests for OpenYOLO SPI.
+ */
+package org.openyolo.spi;
diff --git a/testapp/build.gradle b/testapp/build.gradle
index 3409028..d7a6bf1 100644
--- a/testapp/build.gradle
+++ b/testapp/build.gradle
@@ -7,13 +7,13 @@ apply from:'../config/android-common.gradle'
 android {
     defaultConfig {
         applicationId "org.openyolo.testapp"
         project.archivesBaseName = "openyolo-testapp"
         vectorDrawables.useSupportLibrary = true
     }
     buildTypes {
         release {
             minifyEnabled true
-            proguardFiles getDefaultProguardFile('proguard-android.txt')
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
         }
     }
 }
@@ -21,11 +21,12 @@ android {
 dependencies {
     compile project(':api')
     compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
     compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
     compile "com.android.support:design:${rootProject.supportLibVersion}"
     compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    compile 'com.google.guava:guava:20.0'
 
     compile 'com.jakewharton:butterknife:8.5.1'
     compile 'com.github.bumptech.glide:glide:3.7.0'
     apt 'com.jakewharton:butterknife-compiler:8.5.1'
 }
diff --git a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
index 47e38a8..09e650d 100644
--- a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
+++ b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
@@ -23,10 +23,7 @@ import android.widget.EditText;
 import android.widget.LinearLayout;
-
 import butterknife.BindView;
 import butterknife.ButterKnife;
-
 import java.util.HashSet;
 import java.util.Set;
-
-import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.protocol.AuthenticationMethods;
 
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 27b3f93..8a788f8 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -26,3 +26,2 @@ import android.widget.ImageView;
 import android.widget.LinearLayout;
-
 import butterknife.BindView;
@@ -31,9 +30,7 @@ import butterknife.OnClick;
 import butterknife.OnTextChanged;
-
 import com.bumptech.glide.Glide;
-
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.api.Credential;
-import org.openyolo.api.PasswordSpecification;
+import org.openyolo.protocol.AuthenticationDomain;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.PasswordSpecification;
 
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 76aa059..2ee72c6 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -28,3 +28,2 @@ import android.view.ViewGroup;
 import android.widget.EditText;
-
 import butterknife.BindView;
@@ -32,10 +31,9 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
-
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.api.Credential;
 import org.openyolo.api.CredentialClient;
-import org.openyolo.api.HintRequest;
+import org.openyolo.protocol.AuthenticationMethods;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.HintRequest;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
diff --git a/testapp/java/org/openyolo/testapp/RandomData.java b/testapp/java/org/openyolo/testapp/RandomData.java
index 0cf09c4..928e93f 100644
--- a/testapp/java/org/openyolo/testapp/RandomData.java
+++ b/testapp/java/org/openyolo/testapp/RandomData.java
@@ -17,295 +17,292 @@ package org.openyolo.testapp;
 import android.support.annotation.NonNull;
+import com.google.common.io.BaseEncoding;
 import java.util.Locale;
 import java.util.Random;
-import okio.ByteString;
 
 /**
  * Generates random data useful for populating credentials.
  */
 public class RandomData {
 
     /**
      * The top-100 given (aka "first") names, from US Census Bureau data.
      */
     public static final String[] GIVEN_NAMES = {
             "Amanda",
             "Amy",
             "Andrew",
             "Angela",
             "Ann",
             "Anna",
             "Anthony",
             "Arthur",
             "Barbara",
             "Betty",
             "Brenda",
             "Brian",
             "Carl",
             "Carol",
             "Carolyn",
             "Catherine",
             "Charles",
             "Christine",
             "Christopher",
             "Cynthia",
             "Daniel",
             "David",
             "Deborah",
             "Debra",
             "Dennis",
             "Diane",
             "Donald",
             "Donna",
             "Dorothy",
             "Douglas",
             "Edward",
             "Elizabeth",
             "Eric",
             "Frances",
             "Frank",
             "Gary",
             "George",
             "Gregory",
             "Harold",
             "Helen",
             "Henry",
             "James",
             "Janet",
             "Jason",
             "Jeffrey",
             "Jennifer",
             "Jerry",
             "Jessica",
             "John",
             "Jose",
             "Joseph",
             "Joshua",
             "Joyce",
             "Karen",
             "Kathleen",
             "Kenneth",
             "Kevin",
             "Kimberly",
             "Larry",
             "Laura",
             "Linda",
             "Lisa",
             "Margaret",
             "Maria",
             "Marie",
             "Mark",
             "Martha",
             "Mary",
             "Matthew",
             "Melissa",
             "Michael",
             "Michelle",
             "Nancy",
             "Pamela",
             "Patricia",
             "Patrick",
             "Paul",
             "Peter",
             "Raymond",
             "Rebecca",
             "Richard",
             "Robert",
             "Roger",
             "Ronald",
             "Ruth",
             "Ryan",
             "Sandra",
             "Sarah",
             "Scott",
             "Sharon",
             "Shirley",
             "Stephanie",
             "Stephen",
             "Steven",
             "Susan",
             "Thomas",
             "Timothy",
             "Virginia",
             "Walter",
             "William",
     };
 
     /**
      * The top-100 family names, from US Census Bureau data.
      */
     public static final String[] FAMILY_NAMES = {
             "Adams",
             "Alexander",
             "Allen",
             "Anderson",
             "Bailey",
             "Baker",
             "Barnes",
             "Bell",
             "Bennett",
             "Brooks",
             "Brown",
             "Bryant",
             "Butler",
             "Campbell",
             "Carter",
             "Clark",
             "Coleman",
             "Collins",
             "Cook",
             "Cooper",
             "Cox",
             "Davis",
             "Diaz",
             "Edwards",
             "Evans",
             "Flores",
             "Foster",
             "Garcia",
             "Gonzales",
             "Gonzalez",
             "Gray",
             "Green",
             "Griffin",
             "Hall",
             "Harris",
             "Hayes",
             "Henderson",
             "Hernandez",
             "Hill",
             "Howard",
             "Hughes",
             "Jackson",
             "James",
             "Jenkins",
             "Johnson",
             "Jones",
             "Kelly",
             "King",
             "Lee",
             "Lewis",
             "Long",
             "Lopez",
             "Martin",
             "Martinez",
             "Miller",
             "Mitchell",
             "Moore",
             "Morgan",
             "Morris",
             "Murphy",
             "Nelson",
             "Parker",
             "Patterson",
             "Perez",
             "Perry",
             "Peterson",
             "Phillips",
             "Powell",
             "Price",
             "Ramirez",
             "Reed",
             "Richardson",
             "Rivera",
             "Roberts",
             "Robinson",
             "Rodriguez",
             "Rogers",
             "Ross",
             "Russell",
             "Sanchez",
             "Sanders",
             "Scott",
             "Simmons",
             "Smith",
             "Stewart",
             "Taylor",
             "Thomas",
             "Thompson",
             "Torres",
             "Turner",
             "Walker",
             "Ward",
             "Washington",
             "Watson",
             "White",
             "Williams",
             "Wilson",
             "Wood",
             "Wright",
             "Young"
     };
 
     private static final int ROBOHASH_LENGTH = 32;
 
     private final Random mRandom;
 
     /**
      * Instantiates a random user data source.
      */
     public RandomData() {
         mRandom = new Random();
     }
 
     /**
      * Generates a given (aka "first") name.
      */
     @NonNull
     public String generateGivenName() {
         return GIVEN_NAMES[mRandom.nextInt(GIVEN_NAMES.length)];
     }
 
     /**
      * Generates a family name.
      */
     @NonNull
     public String generateFamilyName() {
         return FAMILY_NAMES[mRandom.nextInt(FAMILY_NAMES.length)];
     }
 
     /**
      * Generates a full display name composed of a given name and family name.
      */
     public String generateDisplayName() {
         return getDisplayName(generateGivenName(), generateFamilyName());
     }
 
     /**
      * Generates a display name from the provided given and family names.
      */
     public String getDisplayName(String givenName, String familyName) {
         return givenName + " " + familyName;
     }
 
     /**
      * Generates an email address.
      */
     public String generateEmailAddress() {
         return getEmailAddress(generateGivenName(), generateFamilyName());
     }
 
     /**
      * Generates an email address using the provided given and family names for the user.
      */
     public String getEmailAddress(String givenName, String surname) {
         return givenName.toLowerCase(Locale.US).trim()
                 + "." + surname.toLowerCase(Locale.US).trim()
                 + "@openyolo.org";
     }
 
-    /**
-     * Generates a hexadecimal string from a random byte array of the provided length.
-     */
-    public String generateHexString(int numBytes) {
-        byte[] bytes = new byte[numBytes];
-        mRandom.nextBytes(bytes);
-        return ByteString.of(bytes).hex();
-    }
-
     /**
      * Generates a profile picture URI.
      */
     public String generateProfilePictureUri() {
-        return "https://robohash.org/" + generateHexString(ROBOHASH_LENGTH) + "?set=set3";
+        return "https://robohash.org/" + generateRandomHexString(ROBOHASH_LENGTH) + "?set=set3";
+    }
+
+    private String generateRandomHexString(int length) {
+        byte[] randomBytes = new byte[length / 2];
+        mRandom.nextBytes(randomBytes);
+        return BaseEncoding.base16().encode(randomBytes);
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index b3b50f3..5d7891e 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -28,3 +28,2 @@ import android.view.View;
 import android.view.ViewGroup;
-
 import butterknife.BindView;
@@ -32,14 +31,12 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
-
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
-
-import org.openyolo.api.Credential;
 import org.openyolo.api.CredentialClient;
 import org.openyolo.api.RetrieveCallback;
-import org.openyolo.api.RetrieveRequest;
-import org.openyolo.api.RetrieveResult;
+import org.openyolo.protocol.Credential;
+import org.openyolo.protocol.RetrieveRequest;
+import org.openyolo.protocol.RetrieveResult;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index 07f709c..a7e4833 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -29,7 +29,7 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
-import org.openyolo.api.Credential;
 import org.openyolo.api.CredentialClient;
+import org.openyolo.protocol.Credential;
 
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
diff --git a/testapp/proguard-rules.txt b/testapp/proguard-rules.txt
new file mode 100644
index 0000000..096696c
--- /dev/null
+++ b/testapp/proguard-rules.txt
@@ -0,0 +1,16 @@
+-dontwarn sun.misc.Unsafe
+-dontwarn javax.annotation.**
+-dontwarn java.lang.ClassValue
+-dontwarn com.google.j2objc.annotations.**
+-dontwarn com.google.errorprone.annotations.**
+-dontwarn com.google.appengine.**
+-dontwarn com.google.apphosting.**
+-dontwarn com.google.protobuf.Extension
+-dontwarn com.google.protobuf.ExtensionRegistry
+-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
+
+# ignore dynamic accesses in guava code
+-dontnote com.google.common.**
+
+# ignore dynamic accesses in javalite proto
+-dontnote com.google.protobuf.GeneratedMessageLite
\ No newline at end of file

commit 300a45754e50501bf611658c1a2e965f1d62bfe5
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Tue Apr 11 15:42:47 2017 -0700

    Dependency upgrades
    
    - Upgrading robolectric surfaced issues with assert4j; changed to Java6Assertions.
    - New lint check in build tools complains about layouts with the same name,
      even across projects. Renamed the demo picker_layout to compensate.
    - Icons for the test app were the wrong size (also picked up by new lint check).
      Fixed this, and also change color to match the actual color scheme used by
      the demo app.

diff --git a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java b/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
index 5351a54..969f5eb 100644
--- a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
+++ b/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
@@ -18,4 +18,4 @@ package org.openyolo.api;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.failBecauseExceptionWasNotThrown;
 import static org.mockito.Mockito.mock;
diff --git a/api/javatests/org/openyolo/api/CredentialTest.java b/api/javatests/org/openyolo/api/CredentialTest.java
index ff99883..7fa203f 100644
--- a/api/javatests/org/openyolo/api/CredentialTest.java
+++ b/api/javatests/org/openyolo/api/CredentialTest.java
@@ -18,3 +18,3 @@ package org.openyolo.api;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 import static org.mockito.Matchers.any;
diff --git a/api/javatests/org/openyolo/api/HintRequestTest.java b/api/javatests/org/openyolo/api/HintRequestTest.java
index 2bf7c39..d1b75b8 100644
--- a/api/javatests/org/openyolo/api/HintRequestTest.java
+++ b/api/javatests/org/openyolo/api/HintRequestTest.java
@@ -16,3 +16,3 @@ package org.openyolo.api;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 import static org.assertj.core.data.MapEntry.entry;
diff --git a/api/javatests/org/openyolo/api/PasswordSpecificationTest.java b/api/javatests/org/openyolo/api/PasswordSpecificationTest.java
index 7a59532..f9181ed 100644
--- a/api/javatests/org/openyolo/api/PasswordSpecificationTest.java
+++ b/api/javatests/org/openyolo/api/PasswordSpecificationTest.java
@@ -21,3 +21,3 @@ import static junit.framework.TestCase.assertFalse;
 import static junit.framework.TestCase.assertTrue;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
diff --git a/api/javatests/org/openyolo/api/RetrieveRequestTest.java b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
index 4fc97fb..e84a18d 100644
--- a/api/javatests/org/openyolo/api/RetrieveRequestTest.java
+++ b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
@@ -19,3 +19,3 @@ package org.openyolo.api;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 
diff --git a/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java b/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
index 6460254..f664711 100644
--- a/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
+++ b/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
@@ -20,3 +20,4 @@ package org.openyolo.api.internal;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 import java.util.ArrayList;
diff --git a/build.gradle b/build.gradle
index fb0cdbe..c692498 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,13 +4,13 @@ apply from: 'config/keystore.gradle'
 buildscript {
     repositories {
         jcenter()
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:2.3.1'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
-        classpath 'org.ajoberstar:gradle-git:1.6.0'
+        classpath 'org.ajoberstar:gradle-git:1.7.1'
         classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
     }
 }
@@ -44,3 +44,3 @@ project.ext.compileSdkVersion = 25
 project.ext.buildToolsVersion = '25.0.2'
-project.ext.supportLibVersion = '25.1.1'
+project.ext.supportLibVersion = '25.3.1'
 
@@ -60,3 +60,3 @@ subprojects {
 task wrapper(type: Wrapper) {
-    gradleVersion = '3.3'
+    gradleVersion = '3.5'
 }
diff --git a/config/testdeps.gradle b/config/testdeps.gradle
index ec6a194..3bf17f0 100644
--- a/config/testdeps.gradle
+++ b/config/testdeps.gradle
@@ -2,3 +2,3 @@ testCompile 'junit:junit:4.12'
 testCompile 'org.mockito:mockito-core:2.7.0'
-testCompile 'org.robolectric:robolectric:3.2.2'
+testCompile 'org.robolectric:robolectric:3.3.2'
 testCompile 'com.squareup.assertj:assertj-android:1.1.1'
\ No newline at end of file
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
index 3f46233..ed4b522 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -46,134 +46,134 @@ import org.openyolo.spi.RetrieveIntentResultUtil;
 /**
  * Displays a dialog to pick a credential from a list.
  */
 public class CredentialPickerActivity extends AppCompatActivity {
 
     private static final String LOG_TAG = "CredentialPicker";
 
     private static final String EXTRA_CREDENTIALS = "credentials";
 
     @BindView(R.id.available_credentials)
     RecyclerView mCredentialView;
 
     /**
      * Creates an intent to display the credential picker with the provided set of credentials.
      */
     public static Intent createIntent(Context context, List<Credential> credentials) {
         Intent intent = new Intent(context, CredentialPickerActivity.class);
         intent.putExtra(EXTRA_CREDENTIALS, new CredentialList(credentials).encode());
         return intent;
     }
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
 
-        setContentView(R.layout.picker_layout);
+        setContentView(R.layout.credential_picker_layout);
         ButterKnife.bind(this);
 
         mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
         mCredentialView.setLayoutManager(new LinearLayoutManager(this));
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
             setResult(RESULT_CANCELED);
             finish();
             return true;
         }
 
         return super.onTouchEvent(event);
     }
 
     private List<Credential> getCredentials() {
         byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
         try {
             List<Credential> credentials =
                     new ArrayList<>(CredentialList.ADAPTER.decode(credentialBytes).credentials);
             Collections.sort(credentials, CredentialQualityScore.QUALITY_SORT);
             return credentials;
         } catch (IOException ex) {
             throw new IllegalStateException("Failed to decode credentials from intent", ex);
         }
     }
 
     private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
 
         List<Credential> mCredentials;
 
         CredentialPickerAdapter(List<Credential> credentials) {
             mCredentials = credentials;
         }
 
         @Override
         public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
             View credentialView = LayoutInflater.from(parent.getContext())
                     .inflate(R.layout.credential_picker_item_view, parent, false);
 
             return new CredentialViewHolder(credentialView);
         }
 
         @Override
         public void onBindViewHolder(CredentialViewHolder holder, int position) {
             holder.bind(mCredentials.get(position));
         }
 
         @Override
         public int getItemCount() {
             return mCredentials.size();
         }
     }
 
     private final class CredentialViewHolder extends RecyclerView.ViewHolder {
 
         private ImageView mProfileIcon;
         private TextView mPrimaryLabel;
         private TextView mSecondaryLabel;
 
         CredentialViewHolder(View itemView) {
             super(itemView);
 
             mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
             mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
             mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
         }
 
         void bind(final Credential credential) {
 
             int iconId = CredentialClassifier.getDefaultIconForCredential(credential);
 
             if (credential.displayPictureUri != null) {
                 Uri displayPictureUri = Uri.parse(credential.displayPictureUri);
                 Glide.with(CredentialPickerActivity.this)
                         .load(displayPictureUri)
                         .fitCenter()
                         .fallback(iconId)
                         .into(mProfileIcon);
             } else {
                 mProfileIcon.setImageResource(iconId);
             }
 
             if (credential.displayName != null) {
                 mPrimaryLabel.setText(credential.displayName);
                 mSecondaryLabel.setText(credential.id);
                 mSecondaryLabel.setVisibility(View.VISIBLE);
             } else {
                 mPrimaryLabel.setText(credential.id);
                 mSecondaryLabel.setVisibility(View.GONE);
             }
 
             itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     Intent responseData =
                             RetrieveIntentResultUtil.createResponseData(credential);
                     setResult(RESULT_OK, responseData);
                     finish();
                 }
             });
         }
     }
 }
diff --git a/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java b/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
index 97dae1a..94b1bb4 100644
--- a/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
+++ b/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
@@ -18,3 +18,3 @@ package org.openyolo.demoprovider.barbican.storage;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Java6Assertions.assertThat;
 
diff --git a/demoproviders/barbican/res/layout/picker_layout.xml b/demoproviders/barbican/res/layout/credential_picker_layout.xml
similarity index 100%
rename from demoproviders/barbican/res/layout/picker_layout.xml
rename to demoproviders/barbican/res/layout/credential_picker_layout.xml
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index deedc7f..58549d5 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 678a46a..4161a3e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,2 +1,2 @@
-#Wed Feb 01 19:21:11 PST 2017
+#Tue Apr 11 14:41:57 PDT 2017
 distributionBase=GRADLE_USER_HOME
@@ -5,2 +5,2 @@ zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
diff --git a/gradlew b/gradlew
index 9aa616c..4453cce 100755
--- a/gradlew
+++ b/gradlew
@@ -1,10 +1,10 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
 
 ##############################################################################
 ##
 ##  Gradle start up script for UN*X
 ##
 ##############################################################################
 
 # Attempt to set APP_HOME
 # Resolve links: $0 may be a link
@@ -136,31 +136,34 @@ if $cygwin ; then
         if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
             eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
         else
             eval `echo args$i`="\"$arg\""
         fi
         i=$((i+1))
     done
     case $i in
         (0) set -- ;;
         (1) set -- "$args0" ;;
         (2) set -- "$args0" "$args1" ;;
         (3) set -- "$args0" "$args1" "$args2" ;;
         (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
         (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
         (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
         (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
         (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
         (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
     esac
 fi
 
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
-    JVM_OPTS=("$@")
+# Escape application args
+save ( ) {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
 }
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
 
 # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
   cd "$(dirname "$0")"
@@ -168,2 +171,2 @@ fi
 
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/spi/build.gradle b/spi/build.gradle
index 980a22b..8e33c9f 100644
--- a/spi/build.gradle
+++ b/spi/build.gradle
@@ -4,9 +4,8 @@ apply from:'../config/android-common.gradle'
 android {
     defaultConfig {
         project.archivesBaseName = 'openyolo-spi'
         consumerProguardFiles 'proguard-rules.txt'
     }
 }
 
-
 dependencies {
diff --git a/testapp/res/mipmap-hdpi/ic_launcher.png b/testapp/res/mipmap-hdpi/ic_launcher.png
index 1a7b7d0..f7c013b 100644
Binary files a/testapp/res/mipmap-hdpi/ic_launcher.png and b/testapp/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/testapp/res/mipmap-mdpi/ic_launcher.png b/testapp/res/mipmap-mdpi/ic_launcher.png
index 33f6e12..56be171 100644
Binary files a/testapp/res/mipmap-mdpi/ic_launcher.png and b/testapp/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/testapp/res/mipmap-xhdpi/ic_launcher.png b/testapp/res/mipmap-xhdpi/ic_launcher.png
index d8e55a8..fabe542 100644
Binary files a/testapp/res/mipmap-xhdpi/ic_launcher.png and b/testapp/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/testapp/res/mipmap-xxhdpi/ic_launcher.png b/testapp/res/mipmap-xxhdpi/ic_launcher.png
index 9762cff..6b9942b 100644
Binary files a/testapp/res/mipmap-xxhdpi/ic_launcher.png and b/testapp/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/testapp/res/mipmap-xxxhdpi/ic_launcher.png b/testapp/res/mipmap-xxxhdpi/ic_launcher.png
index 18c4e87..37684a5 100644
Binary files a/testapp/res/mipmap-xxxhdpi/ic_launcher.png and b/testapp/res/mipmap-xxxhdpi/ic_launcher.png differ

commit 53486836b979bad6738ed908b72ce6c2719b7e46
Author: Michael Verde <mverde@agilebits.com>
Date:   Thu Mar 16 22:08:14 2017 -0700

    Added AgileBits to authors and Michael to contributors

diff --git a/AUTHORS b/AUTHORS
index 13565a3..df77d09 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,2 +9,3 @@
 
+AgileBits, Inc.
 Dashlane, Inc.
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index a9d1e05..5f70d1d 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -13,2 +13,3 @@ David Samuelson <samuelsond@google.com>
 Iain McGinniss <iainmcgin@google.com>
+Michael Verde <mverde@agilebits.com>
 Stan Kocken <stan.kocken@dashlane.com>

commit 4fc64c4e72e7d1ef13717c2eac4130f74202310e
Author: Michael Verde <mverde@agilebits.com>
Date:   Thu Mar 16 21:20:44 2017 -0700

    Fixed issue with snackbars overlapping navigation bar

diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 1039bd7..76aa059 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -39,103 +39,103 @@ import org.openyolo.api.HintRequest;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_method_text_input)
     EditText mAuthenticationMethodInput;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
         String uriString = mAuthenticationMethodInput.getText().toString();
         if (uriString.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         Uri authMethodUri = Uri.parse(uriString);
 
         HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethodUri);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.openyolo_id_and_password_provider_button)
     void onIdAndPasswordAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
-        Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
+        Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index fcf365f..b3b50f3 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -43,116 +43,116 @@ import org.openyolo.api.RetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<Uri> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         if (authenticationMethods.isEmpty()) {
             showSnackbar(R.string.authentication_field_required);
             return;
         }
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
-        Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
+        Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index 116b93c..07f709c 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -33,71 +33,71 @@ import org.openyolo.api.CredentialClient;
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
 public final class SaveTestPageFragment extends TestPageFragment {
 
     private static final int RC_SAVE = 0;
 
     @BindView(R.id.save_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Save";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.save_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
     @OnClick(R.id.save_button)
     void onSave() {
         Credential credential = mCredentialView.makeCredentialFromFields();
         Intent saveIntent = mApi.getSaveIntent(credential);
         if (saveIntent == null) {
             showSnackbar(R.string.no_available_save_providers);
             return;
         }
 
         startActivityForResult(saveIntent, RC_SAVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
-        Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
+        Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_SAVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             showSnackbar(R.string.credential_saved);
             return;
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.credential_save_canceled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 }

commit 8b9ba2470180a35946e49a1899b9feb28923b6fd
Author: S Gaw <sgaw@users.noreply.github.com>
Date:   Wed Mar 15 21:45:07 2017 +0100

    Custom views need public constructors (#15)

diff --git a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
index 1e2c26b..47e38a8 100644
--- a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
+++ b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
@@ -23,6 +23,9 @@ import android.widget.EditText;
 import android.widget.LinearLayout;
+
 import butterknife.BindView;
 import butterknife.ButterKnife;
+
 import java.util.HashSet;
 import java.util.Set;
+
 import org.openyolo.api.AuthenticationMethods;
@@ -30,64 +33,87 @@ import org.openyolo.api.AuthenticationMethods;
 public final class AuthenticationMethodsInputView extends LinearLayout {
 
     @BindView(R.id.facebook_authentication_method_checkbox)
     CheckBox mFaceBookCheckBox;
 
     @BindView(R.id.google_authentication_method_checkbox)
     CheckBox mGoogleCheckBox;
 
     @BindView(R.id.id_and_password_authentication_method_checkbox)
     CheckBox mIdAndPasswordCheckBox;
 
     @BindView(R.id.custom_authentication_method_checkbox)
     CheckBox mCustomAuthenticationMethodCheckBox;
 
     @BindView(R.id.custom_authentication_method)
     EditText mCustomAuthenticationMethod;
 
-    AuthenticationMethodsInputView(Context context) {
+    /**
+     * Simple constructor to use when creating an authentication method selection view from code.
+     *
+     * @param context The Context the view is running in, through which it can access the current
+     *                theme, resources, etc.
+     */
+    public AuthenticationMethodsInputView(Context context) {
         super(context);
         initialize(context);
     }
 
-    AuthenticationMethodsInputView(Context context, AttributeSet attrs) {
+    /**
+     * Constructor that is called when inflating a view from XML.
+     *
+     * @param context The Context the view is running in, through which it can access the current
+     *                theme, resources, etc.
+     * @param attrs   The attributes of the XML tag that is inflating the view.
+     */
+    public AuthenticationMethodsInputView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
-    AuthenticationMethodsInputView(Context context, AttributeSet attrs, int defStyle) {
+    /**
+     * Perform inflation from XML and apply a class-specific base style from a theme attribute.
+     *
+     * @param context  The Context the view is running in, through which it can access the current
+     *                 theme, resources, etc.
+     * @param attrs    The attributes of the XML tag that is inflating the view.
+     * @param defStyle An attribute in the current theme that contains a reference to a style
+     *                 resource that supplies default values for the view. Can be 0 to not look for
+     *                 defaults.
+     */
+    public AuthenticationMethodsInputView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.authentication_method_input_layout, this);
 
         ButterKnife.bind(view);
     }
 
     /**
      * @return A set of authentication domains that are marked as enabled.
      */
     public Set<Uri> getEnabledAuthenticationMethods() {
         Set<Uri> authenticationMethods = new HashSet<>();
 
         if (mFaceBookCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.FACEBOOK);
         }
 
         if (mGoogleCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.GOOGLE);
         }
 
         if (mIdAndPasswordCheckBox.isChecked()) {
             authenticationMethods.add(AuthenticationMethods.ID_AND_PASSWORD);
         }
 
         if (mCustomAuthenticationMethodCheckBox.isChecked()) {
             Uri authenticationMethod = Uri.parse(mCustomAuthenticationMethod.getText().toString());
             authenticationMethods.add(authenticationMethod);
         }
 
         return authenticationMethods;
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/CredentialView.java b/testapp/java/org/openyolo/testapp/CredentialView.java
index 6c769a9..27b3f93 100644
--- a/testapp/java/org/openyolo/testapp/CredentialView.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -26,2 +26,3 @@ import android.widget.ImageView;
 import android.widget.LinearLayout;
+
 import butterknife.BindView;
@@ -30,3 +31,5 @@ import butterknife.OnClick;
 import butterknife.OnTextChanged;
+
 import com.bumptech.glide.Glide;
+
 import org.openyolo.api.AuthenticationDomain;
@@ -37,190 +40,213 @@ import org.openyolo.api.PasswordSpecification;
 public final class CredentialView extends LinearLayout {
 
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_id_and_password_provider_button)
     ImageButton mIdAndPasswordProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
-    CredentialView(Context context) {
+    /**
+     * Simple constructor to use when creating a credential view from code.
+     *
+     * @param context The Context the view is running in, through which it can access the current
+     *                theme, resources, etc.
+     */
+    public CredentialView(Context context) {
         super(context);
         initialize(context);
     }
 
-    CredentialView(Context context, AttributeSet attrs) {
+    /**
+     * Constructor that is called when inflating a view from XML.
+     *
+     * @param context The Context the view is running in, through which it can access the current
+     *                theme, resources, etc.
+     * @param attrs   The attributes of the XML tag that is inflating the view.
+     */
+    public CredentialView(Context context, AttributeSet attrs) {
         super(context, attrs);
         initialize(context);
     }
 
-    CredentialView(Context context, AttributeSet attrs, int defStyle) {
+    /**
+     * Perform inflation from XML and apply a class-specific base style from a theme attribute.
+     *
+     * @param context  The Context the view is running in, through which it can access the current
+     *                 theme, resources, etc.
+     * @param attrs    The attributes of the XML tag that is inflating the view.
+     * @param defStyle An attribute in the current theme that contains a reference to a style
+     *                 resource that supplies default values for the view. Can be 0 to not look for
+     *                 defaults.
+     */
+    public CredentialView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         initialize(context);
     }
 
     private void initialize(Context context) {
         View view = View.inflate(context, R.layout.credential_layout, this);
 
         mRandomData = new RandomData();
         ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
     public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mIdAndPasswordProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_id_and_password_provider_button)
     void setIdAndPasswordAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
         Glide.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
      *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
      *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authenticationMethod = mAuthenticationMethodField.getText().toString();
         Uri authMethodUri = Uri.parse(authenticationMethod);
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethodUri,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
             credentialBuilder.setPassword(mPasswordField.getText().toString());
         }
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index ee0cf18..1039bd7 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -28,2 +28,3 @@ import android.view.ViewGroup;
 import android.widget.EditText;
+
 import butterknife.BindView;
@@ -31,2 +32,3 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
+
 import org.openyolo.api.AuthenticationMethods;
@@ -37,98 +39,103 @@ import org.openyolo.api.HintRequest;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
     @BindView(R.id.authentication_method_text_input)
     EditText mAuthenticationMethodInput;
 
     @BindView(R.id.hint_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         mCredentialView.clearFields();
 
-        Uri authMethodUri = Uri.parse(mAuthenticationMethodInput.getText().toString());
+        String uriString = mAuthenticationMethodInput.getText().toString();
+        if (uriString.isEmpty()) {
+            showSnackbar(R.string.authentication_field_required);
+            return;
+        }
+        Uri authMethodUri = Uri.parse(uriString);
 
         HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethodUri);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.openyolo_id_and_password_provider_button)
     void onIdAndPasswordAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
         mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index a1eaadf..fcf365f 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -28,2 +28,3 @@ import android.view.View;
 import android.view.ViewGroup;
+
 import butterknife.BindView;
@@ -31,4 +32,6 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
+
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
+
 import org.openyolo.api.Credential;
@@ -40,112 +43,116 @@ import org.openyolo.api.RetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<Uri> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
+        if (authenticationMethods.isEmpty()) {
+            showSnackbar(R.string.authentication_field_required);
+            return;
+        }
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index b549ac3..8c557e3 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,56 +1,57 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
 
     <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
     <string name="no_credentials">No credentials available</string>
     <string name="retrieve_cancelled">Credential retrieve cancelled</string>
     <string name="custom_authentication_method_hint">Custom</string>
     <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
     <string name="authentication_method_section_title">Authentication Methods:</string>
 
     <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
     <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
     <string name="id_and_password_authentication_method_checkbox_text">openyolo://id-and-password</string>
 
     <!-- Save Test -->
     <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
 
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
 
     <!-- Hint Test -->
     <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="hint_cancelled">Hint retrieve cancelled</string>
 
     <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
 
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
 
     <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
 
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
 
     <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="open_yolo_id_and_password_button_content_description">Set authentication method to Id and password</string>
 
     <!-- Misc -->
+    <string name="authentication_field_required">Must select authentication method</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
     <string name="no_credential_returned">No credential returned</string>
 </resources>

commit 35462c10f28a850b9a1c9eb3f17a6cfdd8195f0c
Author: David (@dxslly) <davidhlemon@gmail.com>
Date:   Fri Mar 10 14:54:42 2017 -0800

    Require CredentialRetrieveRequest to contain at least one auth method (#13)
    
    - Relaxed validation logic in RetrieveRequest instead to throw
    exceptions. As this request created by an external application the credential
    provider should be able to recover from malformated requests.
    
    - Fixed bug in BaseCredentialQueryReceiver that would cause malformed
    credential retrieve requests to crash the application.

diff --git a/api/java/org/openyolo/api/RetrieveRequest.java b/api/java/org/openyolo/api/RetrieveRequest.java
index f6af88b..9588046 100644
--- a/api/java/org/openyolo/api/RetrieveRequest.java
+++ b/api/java/org/openyolo/api/RetrieveRequest.java
@@ -16,5 +16,8 @@ package org.openyolo.api;
 
+import static java.util.Collections.EMPTY_SET;
 import static java.util.Collections.unmodifiableMap;
 import static java.util.Collections.unmodifiableSet;
+import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -29,3 +32,3 @@ import static org.openyolo.api.internal.UriConverters.CONVERTER_STRING_TO_URI;
 import static org.openyolo.api.internal.UriConverters.CONVERTER_URI_TO_STRING;
-import static org.valid4j.Assertive.require;
+import static org.valid4j.Validation.validate;
 
@@ -46,226 +49,236 @@ import org.openyolo.proto.CredentialRetrieveRequest;
 /**
  * A request for credentials, to be sent to credential providers on the device.
  */
 public class RetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveRequest} instances.
      *
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
     @NonNull
     private final Set<Uri> mAuthMethods;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalParams;
 
     private RetrieveRequest(
             @NonNull Set<Uri> authMethods,
             @NonNull Map<String, byte[]> additionalParams) {
         mAuthMethods = authMethods;
         mAdditionalParams = additionalParams;
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(
             @NonNull Set<Uri> authenticationMethods) {
-        return new RetrieveRequest.Builder()
-                .setAuthenticationMethods(authenticationMethods)
-                .build();
+        return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
     public static RetrieveRequest forAuthenticationMethods(@NonNull Uri... authenticationMethods) {
-        return new RetrieveRequest.Builder()
-                .setAuthenticationMethods(authenticationMethods)
-                .build();
+        return new RetrieveRequest.Builder(authenticationMethods).build();
     }
 
     /**
      * The set of authentication methods that the requestor supports. This is used to filter the set
-     * of credentials saved by the provider. If no authentication methods are specified, then no
-     * filtering of saved credentials will occur.
+     * of credentials saved by the provider. At least one authentication method must be specified.
      */
     @NonNull
     public Set<Uri> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalParameters() {
         return mAdditionalParams;
     }
 
     /**
      * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
      * string.
      */
     @Nullable
     public String getAdditionalParameterAsString(@NonNull String key) {
-        require(key, notNullValue());
+        validate(key, notNullValue(), IllegalArgumentException.class);
+
         if (mAdditionalParams.containsKey(key)) {
             return new String(mAdditionalParams.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalParameter(@NonNull String key) {
-        require(key, notNullValue());
+        validate(key, notNullValue(), IllegalArgumentException.class);
+
         return mAdditionalParams.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().encode();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public CredentialRetrieveRequest toProtocolBuffer() {
         return new CredentialRetrieveRequest.Builder()
                 .authMethods(toList(mAuthMethods, CONVERTER_URI_TO_STRING))
                 .additionalParams(toList(mAdditionalParams.entrySet(), CONVERTER_ENTRY_TO_KVP))
                 .build();
     }
 
     /**
      * Creates {@link RetrieveRequest} instances.
      */
     public static final class Builder {
 
         private Set<Uri> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
          * Starts the process of creating a retrieve request using the data contained in the
          * provided protocol buffer representation.
          */
         public Builder(@NonNull CredentialRetrieveRequest requestProto) {
-            require(requestProto, notNullValue());
+            validate(requestProto, notNullValue(), IllegalArgumentException.class);
+
             setAuthenticationMethods(toSet(requestProto.authMethods, CONVERTER_STRING_TO_URI));
             setAdditionalParameters(toMap(requestProto.additionalParams, CONVERTER_KVP_TO_PAIR));
         }
 
         /**
-         * Starts the process of describing a retrieve request.
+         * Starts the process of describing a retrieve request. At least one authentication method
+         * must be provided.
          */
-        public Builder() {}
+        public Builder(@NonNull Uri... authMethods) {
+            setAuthenticationMethods(
+                    toSet(null, authMethods, NoopValueConverter.<Uri>getInstance()));
+        }
 
         /**
-         * Specifies the authentication methods supported by the requester. If no values are
-         * specified, then any stored credential matching the set of specified authentication
-         * domains may be returned. All provided values must be non-null.
+         * Starts the process of describing a retrieve request. At least one authentication method
+         * must be provided.
          */
-        @NonNull
-        public Builder setAuthenticationMethods(@NonNull Uri... authMethods) {
-            setAuthenticationMethods(
-                    toSet(null, authMethods, NoopValueConverter.<Uri>getInstance()));
-            return this;
+        public Builder(@NonNull Set<Uri> authMethods) {
+            setAuthenticationMethods(authMethods);
         }
 
         /**
-         * Specifies the authentication methods supported by the requester. If no values are
-         * specified, then any stored credential matching the set of specified authentication
-         * domains may be returned. The provided set must be non-null, and contain only non-null
-         * values.
+         * Specifies the authentication methods supported by the requester. At least one
+         * authentication method must be provided.
          */
-        public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
-            require(authMethods, notNullValue());
-            require(authMethods, everyItem(isValidAuthenticationMethod()));
+        private Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
+            validate(authMethods, notNullValue(), IllegalArgumentException.class);
+            validate(authMethods, not(equalTo(EMPTY_SET)), IllegalArgumentException.class);
+            validate(
+                    authMethods,
+                    everyItem(isValidAuthenticationMethod()),
+                    IllegalArgumentException.class);
+
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
          * Specifies additional, non-standard retrieve request parameters. The provided map must be
          * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalParameters(
                 @NonNull Map<String, byte[]> additionalParams) {
-            require(additionalParams, notNullValue());
-            require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
-            require(additionalParams.values(), everyItem(notNullValue()));
+            validate(additionalParams, notNullValue(), IllegalArgumentException.class);
+            validate(
+                    additionalParams.keySet(),
+                    everyItem(notNullOrEmptyString()),
+                    IllegalArgumentException.class);
+            validate(
+                    additionalParams.values(),
+                    everyItem(notNullValue()),
+                    IllegalArgumentException.class);
+
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
          * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
          * parameter name and value must be non-null.
          *
          * @see {@link RetrieveRequest#getAdditionalParameterAsString(String)}
          */
         public Builder addAdditionalParameter(
                 @NonNull String name,
                 @NonNull String value) {
-            require(value, notNullValue());
+            validate(value, notNullValue(), IllegalArgumentException.class);
+
             addAdditionalParameter(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalParameter(String name, byte[] value) {
-            require(name, notNullOrEmptyString());
-            require(value, notNullValue());
+            validate(name, notNullOrEmptyString(), IllegalArgumentException.class);
+            validate(value, notNullValue(), IllegalArgumentException.class);
+
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link RetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public RetrieveRequest build() {
             return new RetrieveRequest(
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
     private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
 
         @Override
         public RetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new RetrieveRequest.Builder(
                         CredentialRetrieveRequest.ADAPTER.decode(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public RetrieveRequest[] newArray(int size) {
             return new RetrieveRequest[size];
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/RetrieveRequestTest.java b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
index 229738e..4fc97fb 100644
--- a/api/javatests/org/openyolo/api/RetrieveRequestTest.java
+++ b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
@@ -36,89 +36,98 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveRequestTest {
 
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
     private RetrieveRequest request;
 
     @Before
     public void setUp() {
-        request = new RetrieveRequest.Builder()
-                .setAuthenticationMethods(AuthenticationMethods.ID_AND_PASSWORD)
+        request = new RetrieveRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
                 .addAdditionalParameter("a", "b")
                 .addAdditionalParameter("c", testBytes)
                 .build();
     }
 
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
                     deserialized.getAdditionalParameters(),
                     request.getAdditionalParameters());
         } finally {
             p.recycle();
         }
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void builderUriSetConstructor_withEmptySet_throwsIllegalArgumentException() {
+        new RetrieveRequest.Builder(new HashSet<Uri>()  /* authenticationMethods */);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void builderProtoConstructor_withNull_throwsIllegalArgumentException() {
+        new RetrieveRequest.Builder((CredentialRetrieveRequest) null);
+    }
+
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
         RetrieveRequest request = RetrieveRequest
             .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
         Set<Uri> authenticationMethods = new HashSet<>();
         Collections.addAll(
             authenticationMethods,
             AuthenticationMethods.GOOGLE,
             AuthenticationMethods.FACEBOOK);
 
         RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         assertThat(request.getAuthenticationMethods())
             .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
     }
 
     @Test
     public void testGetAdditionalParameters() {
         assertThat(request.getAdditionalParameters()).isNotNull();
         assertThat(request.getAdditionalParameters()).hasSize(2);
         assertThat(request.getAdditionalParameterAsString("a")).isEqualTo("b");
         assertThat(request.getAdditionalParameter("c")).isEqualTo(testBytes);
     }
 
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
                 .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
         CredentialRetrieveRequest.ADAPTER.decode((byte[]) null);
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
index f066a07..780016c 100644
--- a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -49,147 +49,169 @@ import org.robolectric.annotation.Config;
 /**
  * Unit tests for {@link BaseCredentialQueryReceiver}.
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE,
         shadows = {
                 ShadowQueryResponseSender.class,
                 ShadowAuthenticationDomain.class
         })
 public class BaseCredentialQueryReceiverTest {
 
     private BaseCredentialQueryReceiver credentialQueryReceiver;
 
     @Mock
     Context mockContext;
 
     private static final String CALLING_PACKAGE_NAME = "org.openyolo.supercoolapp";
 
-    private static final BroadcastQuery BROADCAST_QUERY_WITH_NULL_MESSAGE =
-            new BroadcastQuery.Builder()
-                    .requestingApp(CALLING_PACKAGE_NAME)
-                    .dataType("blah")
-                    .requestId(101L)
-                    .responseId(102L)
-                    .queryMessage(null)
-                    .build();
-
-    private static final CredentialRetrieveRequest VALID_CREDENTIAL_RETRIEVE_REQUEST =
-            makeValidCredentialRetrieveRequest();
-
-    private static final ByteString VALID_CREDENTIAL_RETRIEVE_REQUEST_BYTE_STRING =
-            ByteString.of(
-                    CredentialRetrieveRequest.ADAPTER.encode(VALID_CREDENTIAL_RETRIEVE_REQUEST));
-
-    private static final BroadcastQuery BROADCAST_QUERY_WITH_VALID_MESSAGE =
-            new BroadcastQuery.Builder()
-                    .requestingApp(CALLING_PACKAGE_NAME)
-                    .dataType("blah")
-                    .requestId(101L)
-                    .responseId(102L)
-                    .queryMessage(VALID_CREDENTIAL_RETRIEVE_REQUEST_BYTE_STRING)
-                    .build();
+    private static final BroadcastQuery QUERY_WITH_NULL_MESSAGE =
+            makeQueryFromRequest(null /* request */);
+
+    private static final BroadcastQuery QUERY_WITH_INVALID_REQUEST =
+            makeQueryFromRequest(makeInvalidCredentialRetrieveRequest());
+
+    private static final BroadcastQuery QUERY_WITH_VALID_REQUEST =
+            makeQueryFromRequest(makeValidCredentialRetrieveRequest());
 
     private static final List<AuthenticationDomain> VALID_AUTHENTICATION_DOMAINS =
             makeValidAuthenticationDomains();
 
+
+    private static final BroadcastQuery makeQueryFromRequest(
+            @Nullable CredentialRetrieveRequest request) {
+        ByteString queryMessage = null;
+        if (null != request) {
+            queryMessage = ByteString.of(CredentialRetrieveRequest.ADAPTER.encode(request));
+        }
+
+        return new BroadcastQuery.Builder()
+                .requestingApp(CALLING_PACKAGE_NAME)
+                .dataType("blah")
+                .requestId(101L)
+                .responseId(102L)
+                .queryMessage(queryMessage)
+                .build();
+    }
+
     private static List<AuthenticationDomain> makeValidAuthenticationDomains() {
         List<AuthenticationDomain> authenticationDomains = new ArrayList<>();
         authenticationDomains.add(mock(AuthenticationDomain.class));
 
         return authenticationDomains;
     }
 
+    private static CredentialRetrieveRequest makeInvalidCredentialRetrieveRequest() {
+        List<String> authDomains = new ArrayList<>();
+        List<String> authMethods = new ArrayList<>();
+        List<KeyValuePair> additionalParams = new ArrayList<>();
+
+        // Invalid because it does not specify a non-empty set of authentication method
+        return new CredentialRetrieveRequest(
+                authDomains,
+                authMethods,
+                additionalParams,
+                ByteString.EMPTY);
+    }
+
     private static CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
         List<String> authDomains = new ArrayList<>();
         List<String> authMethods = new ArrayList<>();
         authMethods.add("custom://one");
         authMethods.add("custom://two");
         List<KeyValuePair> additionalParams = new ArrayList<>();
 
         return new CredentialRetrieveRequest(
                 authDomains,
                 authMethods,
                 additionalParams,
                 ByteString.EMPTY);
     }
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         ShadowQueryResponseSender.intializeForTest();
 
         credentialQueryReceiver = spy(
                 new BaseCredentialQueryReceiver("TestCredentialQueryReceiver") {
                     @Override
                     protected void processCredentialRequest(
                             @NonNull Context context,
                             @NonNull BroadcastQuery query,
                             @NonNull RetrieveRequest request,
                             @NonNull Set<AuthenticationDomain> requestorDomains) {
                         // Do nothing
                     }
                 });
 
         ShadowAuthenticationDomain.setListForPackageResponse(VALID_AUTHENTICATION_DOMAINS);
     }
 
     @Test
     public void processQuery_withNullQuery_sendsNullResponse() throws Exception {
-        credentialQueryReceiver.processQuery(mockContext, BROADCAST_QUERY_WITH_NULL_MESSAGE);
+        credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_NULL_MESSAGE);
+
+        verifyProcessCredentialRequestWasNotCalled();
+        verifyQueryResponseIsSentWith(null /* response */);
+    }
+
+    @Test
+    public void processQuery_withInvalidRequest_sendsNullResponse() throws Exception {
+        credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_INVALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     @Test
-    public void processQuery_withValidQuery_processesRequest() throws Exception {
-        credentialQueryReceiver.processQuery(mockContext, BROADCAST_QUERY_WITH_VALID_MESSAGE);
+    public void processQuery_withValidRequest_processesRequest() throws Exception {
+        credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasCalled();
         verifyQueryResponseIsNotSent();
     }
 
     @Test
-    public void processQuery_withValidQueryAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
+    public void processQuery_withValidRequestAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
             throws Exception {
         ShadowAuthenticationDomain.setListForPackageResponse(Collections.EMPTY_LIST);
-        credentialQueryReceiver.processQuery(mockContext, BROADCAST_QUERY_WITH_VALID_MESSAGE);
+        credentialQueryReceiver.processQuery(mockContext, QUERY_WITH_VALID_REQUEST);
 
         verifyProcessCredentialRequestWasNotCalled();
         verifyQueryResponseIsSentWith(null /* response */);
     }
 
     private void verifyQueryResponseIsNotSent() {
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(0))
                 .sendResponse((BroadcastQuery) any(), (byte[]) any());
     }
 
     private void verifyQueryResponseIsSentWith(@Nullable byte[] response) {
         if (null == response) {
             verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                     .sendResponse((BroadcastQuery) any(), (byte[]) isNull());
             return;
         }
 
         verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
                 .sendResponse((BroadcastQuery) any(), eq(response));
     }
 
     private void verifyProcessCredentialRequestWasCalled() {
         verify(credentialQueryReceiver, times(1))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (RetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 
     private void verifyProcessCredentialRequestWasNotCalled() {
         verify(credentialQueryReceiver, times(0))
                 .processCredentialRequest(
                         (Context) any(),
                         (BroadcastQuery) any(),
                         (RetrieveRequest) any(),
                         (Set<AuthenticationDomain>) any());
     }
 }
\ No newline at end of file
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index b5ff4aa..a1eaadf 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -40,114 +40,112 @@ import org.openyolo.api.RetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
         Set<Uri> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
-        RetrieveRequest request = new RetrieveRequest.Builder()
-                .setAuthenticationMethods(authenticationMethods)
-                .build();
+        RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 

commit 6352c10d6e30936bec0169b17656bf9298e50155
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Wed Mar 8 11:23:07 2017 -0800

    Removed authentication domains from CredentialRequest (#11)

diff --git a/api/java/org/openyolo/api/AuthenticationDomain.java b/api/java/org/openyolo/api/AuthenticationDomain.java
index 55ba5bb..fd58dd6 100644
--- a/api/java/org/openyolo/api/AuthenticationDomain.java
+++ b/api/java/org/openyolo/api/AuthenticationDomain.java
@@ -39,208 +39,197 @@ import org.openyolo.api.internal.ValueConverter;
 /**
  * A URI-based representation of an authentication domain, which determines the scope within which
  * a credential is valid. An authentication domain may have multiple equivalent representations,
  * such as when apps and sites share the same authentication system. The responsibility for
  * determining whether two given authentication domains are equivalent lies with the credential
  * provider.
  *
  * <p>Two broad classes of authentication domain are defined in the OpenYOLO
  * specification : Android authentication domains, of form
  * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
  * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
  * with no path, query or fragment. They must therefore always be of form
  * {@code scheme://authority}.
  */
 @SuppressLint("PackageManagerGetSignatures")
 public final class AuthenticationDomain implements Comparable<AuthenticationDomain> {
 
     static final ValueConverter<String, AuthenticationDomain> CONVERTER_STRING_TO_DOMAIN =
             new StringToAuthenticationDomainConverter();
 
-    static final ValueConverter<AuthenticationDomain, String> CONVERTER_DOMAIN_TO_STRING =
-            new AuthenticationDomainToStringConverter();
-
     private static final String DIGEST_SHA_512 = "SHA-512";
     private static final String SCHEME_ANDROID = "android";
     private static final String SCHEME_HTTP = "http";
     private static final String SCHEME_HTTPS = "https";
 
     private final Uri mUri;
 
     /**
      * Creates an authentication domain that represents the current package, as identified
      * by the provided context's {@link Context#getPackageName() getPackageName} method.
      */
     @NonNull
     public static AuthenticationDomain getSelfAuthDomain(@NonNull Context context) {
         require(context, notNullValue());
 
         PackageManager pm = context.getPackageManager();
         String packageName = context.getPackageName();
         PackageInfo packageInfo;
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             throw new IllegalStateException("Unable to find package info for " + packageName);
         }
 
         return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
     }
 
     /**
      * Creates the list of all authentication domains that represent the specified package.
      * The list will contain a distinct entry for every signature related to the application.
      */
     @NonNull
     public static List<AuthenticationDomain> listForPackage(
             @NonNull Context context,
             @Nullable String packageName) {
         require(context, notNullValue());
 
         PackageManager pm = context.getPackageManager();
         PackageInfo packageInfo;
         if (TextUtils.isEmpty(packageName)) {
             return Collections.emptyList();
         }
         try {
             packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
         } catch (PackageManager.NameNotFoundException e) {
             return Collections.emptyList();
         }
 
         ArrayList<AuthenticationDomain> authDomains =
                 new ArrayList<>(packageInfo.signatures.length);
         for (Signature signature : packageInfo.signatures) {
             authDomains.add(createAndroidAuthDomain(packageName, signature));
         }
 
         return authDomains;
     }
 
     /**
      * Creates an Android authentication domain (of form {@code android://SIGNATURE@PACKAGE}),
      * given the provided package name and signature.
      */
     @NonNull
     public static AuthenticationDomain createAndroidAuthDomain(
             @NonNull String packageName,
             @NonNull Signature signature) {
         require(!TextUtils.isEmpty(packageName), "packageName must not be null or empty");
         require(signature, notNullValue());
 
         return new AuthenticationDomain(
                 new Uri.Builder()
                         .scheme(SCHEME_ANDROID)
                         .encodedAuthority(generateSignatureHash(signature) + "@" + packageName)
                         .build());
     }
 
     @NonNull
     static String generateSignatureHash(@NonNull Signature signature) {
         try {
             MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_512);
             byte[] hashBytes = digest.digest(signature.toByteArray());
             return Base64.encodeToString(hashBytes, Base64.URL_SAFE).replace("\n", "");
         } catch (NoSuchAlgorithmException e) {
             throw new IllegalStateException(
                     "Platform does not support" + DIGEST_SHA_512 + " hashing");
         }
     }
 
     /**
      * Creates an authentication domain from the provided String representation. If the string
      * provided is not a valid authentication domain, an {@link IllegalArgumentException}
      * will be thrown.
      */
     public AuthenticationDomain(@NonNull String authDomainString) {
         mUri = require(Uri.parse(authDomainString), isValidAuthenticationDomain());
     }
 
     private AuthenticationDomain(@NonNull Uri authDomainUri) {
         mUri = authDomainUri;
     }
 
     /**
      * Determines whether the authentication domain refers to an Android application.
      */
     public boolean isAndroidAuthDomain() {
         return SCHEME_ANDROID.equals(mUri.getScheme());
     }
 
     /**
      * Determines whether the authentication domain refers to a Web domain.
      */
     public boolean isWebAuthDomain() {
         return SCHEME_HTTP.equals(mUri.getScheme())
                 || SCHEME_HTTPS.equals(mUri.getScheme());
     }
 
     /**
      * Retrieves the Android package name from the authentication domain. If the authentication
      * domain does not represent an Android application, an {@link IllegalStateException} will
      * be thrown.
      */
     @NonNull
     public String getAndroidPackageName() {
         if (!isAndroidAuthDomain()) {
             throw new IllegalStateException("Authentication domain is not an Android domain");
         }
         return mUri.getHost();
     }
 
     /**
      * Retrieves the URI form of the authentication domain.
      */
     @NonNull
     public Uri getUri() {
         return mUri;
     }
 
     /**
      * Retrieves the string form of the authentication domain.
      */
     @NonNull
     public String toString() {
         return mUri.toString();
     }
 
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
         }
 
         if (!(obj instanceof AuthenticationDomain)) {
             return false;
         }
 
         AuthenticationDomain other = (AuthenticationDomain) obj;
 
         return mUri.equals(other.getUri());
     }
 
     @Override
     public int hashCode() {
         return mUri.hashCode();
     }
 
     @Override
     public int compareTo(@NonNull AuthenticationDomain authenticationDomain) {
         return mUri.compareTo(authenticationDomain.getUri());
     }
 
-    static class AuthenticationDomainToStringConverter
-            implements ValueConverter<AuthenticationDomain, String> {
-        @Override
-        public String convert(AuthenticationDomain value) {
-            return value.toString();
-        }
-    }
-
     static class StringToAuthenticationDomainConverter
             implements ValueConverter<String, AuthenticationDomain> {
         @Override
         public AuthenticationDomain convert(String value) {
             return new AuthenticationDomain(value);
         }
     }
 }
diff --git a/api/java/org/openyolo/api/RetrieveRequest.java b/api/java/org/openyolo/api/RetrieveRequest.java
index c29618a..f6af88b 100644
--- a/api/java/org/openyolo/api/RetrieveRequest.java
+++ b/api/java/org/openyolo/api/RetrieveRequest.java
@@ -20,4 +20,2 @@ import static org.hamcrest.CoreMatchers.everyItem;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.openyolo.api.AuthenticationDomain.CONVERTER_DOMAIN_TO_STRING;
-import static org.openyolo.api.AuthenticationDomain.CONVERTER_STRING_TO_DOMAIN;
 import static org.openyolo.api.internal.CollectionConverter.toList;
@@ -33,3 +31,2 @@ import static org.valid4j.Assertive.require;
 
-import android.content.Context;
 import android.net.Uri;
@@ -47,305 +44,228 @@ import org.openyolo.api.internal.NoopValueConverter;
 import org.openyolo.proto.CredentialRetrieveRequest;
 
 /**
- * A request for credentials, to be sent to credential providers on the device. A request specifies
- * at least one {@link AuthenticationDomain authentication domain} for which a credential is
- * required.
+ * A request for credentials, to be sent to credential providers on the device.
  */
 public class RetrieveRequest implements Parcelable {
 
     /**
      * Parcelable reader for {@link RetrieveRequest} instances.
+     *
      * @see android.os.Parcelable
      */
     public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
 
-    /**
-     * Creates a basic retrieve request for the current application.
-     */
-    public static RetrieveRequest forSelf(Context context) {
-        return new RetrieveRequest.Builder(AuthenticationDomain.getSelfAuthDomain(context))
-                .build();
-    }
-
-    @NonNull
-    private final Set<AuthenticationDomain> mAuthDomains;
-
     @NonNull
     private final Set<Uri> mAuthMethods;
 
     @NonNull
     private final Map<String, byte[]> mAdditionalParams;
 
     private RetrieveRequest(
-            @NonNull Set<AuthenticationDomain> authDomains,
             @NonNull Set<Uri> authMethods,
             @NonNull Map<String, byte[]> additionalParams) {
-        mAuthDomains = authDomains;
         mAuthMethods = authMethods;
         mAdditionalParams = additionalParams;
     }
 
     /**
-     * The set of authentication domains for which a credential is desired. It is the
-     * responsibility of the credential provider to validate that the requester is permitted to
-     * retrieve credentials for this set of domains, and how to interpret requests for domains
-     * which are beyond the provably associated scope of the requester.
+     * Creates a {@link RetrieveRequest} from the given authentication methods.
      */
-    @NonNull
-    public Set<AuthenticationDomain> getAuthenticationDomains() {
-        return mAuthDomains;
+    public static RetrieveRequest forAuthenticationMethods(
+            @NonNull Set<Uri> authenticationMethods) {
+        return new RetrieveRequest.Builder()
+                .setAuthenticationMethods(authenticationMethods)
+                .build();
     }
 
     /**
-     * The set of authentication methods that the requestor supports. This is used to filter the
-     * set of credentials saved by the provider. If no authentication methods are specified, then
-     * no filtering of saved credentials will occur.
+     * Creates a {@link RetrieveRequest} from the given authentication methods.
+     */
+    public static RetrieveRequest forAuthenticationMethods(@NonNull Uri... authenticationMethods) {
+        return new RetrieveRequest.Builder()
+                .setAuthenticationMethods(authenticationMethods)
+                .build();
+    }
+
+    /**
+     * The set of authentication methods that the requestor supports. This is used to filter the set
+     * of credentials saved by the provider. If no authentication methods are specified, then no
+     * filtering of saved credentials will occur.
      */
     @NonNull
     public Set<Uri> getAuthenticationMethods() {
         return mAuthMethods;
     }
 
     /**
      * The map of additional, non-standard properties included with this request.
      */
     @NonNull
     public Map<String, byte[]> getAdditionalParameters() {
         return mAdditionalParams;
     }
 
     /**
-     * Retrieves the value of the named additional parameter, where the value is a UTF-8
-     * encoded string.
+     * Retrieves the value of the named additional parameter, where the value is a UTF-8 encoded
+     * string.
      */
     @Nullable
     public String getAdditionalParameterAsString(@NonNull String key) {
         require(key, notNullValue());
         if (mAdditionalParams.containsKey(key)) {
             return new String(mAdditionalParams.get(key), Charset.forName("UTF-8"));
         }
         return null;
     }
 
     /**
      * Retrieves the raw, byte-array value of the named additional parameter.
      */
     @Nullable
     public byte[] getAdditionalParameter(@NonNull String key) {
         require(key, notNullValue());
         return mAdditionalParams.get(key);
     }
 
     @Override
     public int describeContents() {
         return 0;
     }
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         byte[] protoBytes = toProtocolBuffer().encode();
         dest.writeInt(protoBytes.length);
         dest.writeByteArray(protoBytes);
     }
 
     /**
      * Converts the request into a protocol buffer, for storage or transmission.
      */
     public CredentialRetrieveRequest toProtocolBuffer() {
         return new CredentialRetrieveRequest.Builder()
-                .authDomains(toList(mAuthDomains, CONVERTER_DOMAIN_TO_STRING))
                 .authMethods(toList(mAuthMethods, CONVERTER_URI_TO_STRING))
                 .additionalParams(toList(mAdditionalParams.entrySet(), CONVERTER_ENTRY_TO_KVP))
                 .build();
     }
 
     /**
      * Creates {@link RetrieveRequest} instances.
      */
     public static final class Builder {
 
-        private Set<AuthenticationDomain> mAuthDomains = new HashSet<>();
         private Set<Uri> mAuthMethods = new HashSet<>();
         private Map<String, byte[]> mAdditionalParams = new HashMap<>();
 
         /**
-         * Starts the process of creating a retrieve request using the data contained in
-         * the provided protocol buffer representation.
+         * Starts the process of creating a retrieve request using the data contained in the
+         * provided protocol buffer representation.
          */
         public Builder(@NonNull CredentialRetrieveRequest requestProto) {
             require(requestProto, notNullValue());
-            setAuthenticationDomains(toSet(requestProto.authDomains, CONVERTER_STRING_TO_DOMAIN));
             setAuthenticationMethods(toSet(requestProto.authMethods, CONVERTER_STRING_TO_URI));
             setAdditionalParameters(toMap(requestProto.additionalParams, CONVERTER_KVP_TO_PAIR));
         }
 
         /**
-         * Starts the process of describing a retrieve request, providing the set of authentication
-         * domains for which a credential is desired. At least one authentication domain is
-         * required.
-         */
-        public Builder(
-                @NonNull AuthenticationDomain authDomain,
-                @NonNull AuthenticationDomain... additionalAuthDomains) {
-            setAuthenticationDomains(authDomain, additionalAuthDomains);
-        }
-
-        /**
-         * Starts the process of describing a retrieve request, providing the set of authentication
-         * domains (in the form of URI strings) for which a credential is desired. At least one
-         * authentication domain is required.
-         */
-        public Builder(
-                @NonNull String authDomain,
-                @NonNull String... additionalAuthDomains) {
-            setAuthenticationDomains(authDomain, additionalAuthDomains);
-        }
-
-        /**
-         * Starts the process of describing a retrieve request, with the mandatory list
-         * of authentication domains specified. The list must be non-null, with non-null entries.
+         * Starts the process of describing a retrieve request.
          */
-        public Builder(@NonNull Set<AuthenticationDomain> authDomains) {
-            setAuthenticationDomains(authDomains);
-        }
-
-        /**
-         * Specifies the authentication domain(s) for which a credential is desired.
-         * At least one must be specified. All values specified must be non-null.
-         */
-        @NonNull
-        public Builder setAuthenticationDomains(
-                @NonNull AuthenticationDomain authDomain,
-                @NonNull AuthenticationDomain... additionalAuthDomains) {
-            setAuthenticationDomains(toSet(
-                    authDomain,
-                    additionalAuthDomains,
-                    NoopValueConverter.<AuthenticationDomain>getInstance()));
-            return this;
-        }
-
-        /**
-         * Specifies the authentication domain(s) for which a credential is desired, in the
-         * form of URI strings. At least one value must be specified. All values specified must be
-         * non-null.
-         */
-        @NonNull
-        public Builder setAuthenticationDomains(
-                @NonNull String authDomain,
-                @NonNull String... authDomainStrs) {
-            setAuthenticationDomains(toSet(
-                    authDomain,
-                    authDomainStrs,
-                    CONVERTER_STRING_TO_DOMAIN));
-            return this;
-        }
-
-        /**
-         * Specifies the authentication domains from which a credential is desired.
-         * Must not be null. Must contain at least one value.
-         */
-        @NonNull
-        public Builder setAuthenticationDomains(@NonNull Set<AuthenticationDomain> authDomains) {
-            require(authDomains, notNullValue());
-            require(!authDomains.isEmpty(), "at least one authentication domain must be specified");
-            require(authDomains, everyItem(notNullValue()));
-            mAuthDomains = authDomains;
-            return this;
-        }
+        public Builder() {}
 
         /**
          * Specifies the authentication methods supported by the requester. If no values are
          * specified, then any stored credential matching the set of specified authentication
          * domains may be returned. All provided values must be non-null.
          */
         @NonNull
         public Builder setAuthenticationMethods(@NonNull Uri... authMethods) {
             setAuthenticationMethods(
                     toSet(null, authMethods, NoopValueConverter.<Uri>getInstance()));
             return this;
         }
 
         /**
          * Specifies the authentication methods supported by the requester. If no values are
          * specified, then any stored credential matching the set of specified authentication
-         * domains may be returned. The provided set must be non-null, and contain only
-         * non-null values.
+         * domains may be returned. The provided set must be non-null, and contain only non-null
+         * values.
          */
         public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
             require(authMethods, notNullValue());
             require(authMethods, everyItem(isValidAuthenticationMethod()));
             mAuthMethods = authMethods;
             return this;
         }
 
         /**
-         * Specifies additional, non-standard retrieve request parameters. The provided map
-         * must be non-null, and contain only non-null keys and values.
+         * Specifies additional, non-standard retrieve request parameters. The provided map must be
+         * non-null, and contain only non-null keys and values.
          */
         public Builder setAdditionalParameters(
                 @NonNull Map<String, byte[]> additionalParams) {
             require(additionalParams, notNullValue());
             require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
             require(additionalParams.values(), everyItem(notNullValue()));
             mAdditionalParams = additionalParams;
             return this;
         }
 
         /**
-         * Adds an additional parameter, where the value will be encoded as a UTF-8 string.
-         * Both the parameter name and value must be non-null.
+         * Adds an additional parameter, where the value will be encoded as a UTF-8 string. Both the
+         * parameter name and value must be non-null.
+         *
          * @see {@link RetrieveRequest#getAdditionalParameterAsString(String)}
          */
         public Builder addAdditionalParameter(
                 @NonNull String name,
                 @NonNull String value) {
             require(value, notNullValue());
             addAdditionalParameter(name, value.getBytes(Charset.forName("UTF-8")));
             return this;
         }
 
         /**
          * Adds an additional parameter. Both the parameter name and value must be non-null.
          */
         public Builder addAdditionalParameter(String name, byte[] value) {
             require(name, notNullOrEmptyString());
             require(value, notNullValue());
             mAdditionalParams.put(name, value);
             return this;
         }
 
         /**
          * Creates a {@link RetrieveRequest} using the properties set on the builder.
          */
         @NonNull
         public RetrieveRequest build() {
             return new RetrieveRequest(
-                    unmodifiableSet(mAuthDomains),
                     unmodifiableSet(mAuthMethods),
                     unmodifiableMap(mAdditionalParams));
         }
     }
 
     private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
+
         @Override
         public RetrieveRequest createFromParcel(Parcel in) {
 
             int protoLength = in.readInt();
             byte[] protoBytes = new byte[protoLength];
             in.readByteArray(protoBytes);
 
             try {
                 return new RetrieveRequest.Builder(
                         CredentialRetrieveRequest.ADAPTER.decode(protoBytes))
                         .build();
             } catch (IOException ex) {
                 throw new IllegalStateException("Unable to read proto from parcel", ex);
             }
         }
 
         @Override
         public RetrieveRequest[] newArray(int size) {
             return new RetrieveRequest[size];
         }
     }
 }
diff --git a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java b/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
index 6e8ca86..5351a54 100644
--- a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
+++ b/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
@@ -18,7 +18,7 @@ package org.openyolo.api;
 
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.TestCase.assertTrue;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import android.content.Context;
@@ -26,3 +26,7 @@ import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.Signature;
+import android.net.Uri;
+import java.util.ArrayList;
+import java.util.List;
 import org.junit.Before;
@@ -32,2 +36,4 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 import org.openyolo.api.internal.CollectionConverter;
@@ -37,134 +43,189 @@ import org.valid4j.errors.RequireViolation;
 
-import java.util.ArrayList;
-import java.util.List;
-
+/**
+ * Unit tests for {@link AuthenticationDomain}.
+ */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class AuthenticationDomainTest {
 
-    private static final String SELF_PACKAGE_NAME = "com.example.app";
+    private static final String VALID_PACKAGE_NAME = "com.example.app";
 
-    private byte[] sigBytes = new byte[]
+    private static byte[] VALID_SIGNATURE_BYTES = new byte[]
             { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
-    private String sigSha512HashBase64 =
+    private static final String VALID_FINGERPRINT =
             "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
                     + "7V4Lo8BdCxaA307H0HYkAw==";
-    private PackageInfo packageInfo;
+
+    private static final String VALID_AUTHENTICATION_DOMAIN_STRING =
+            "android://" + VALID_FINGERPRINT + "@" + VALID_PACKAGE_NAME;
+
+    private static final PackageInfo VALID_PACKAGE_INFO = makeValidPackageInfo();
+
+    private static PackageInfo makeValidPackageInfo() {
+        PackageInfo packageInfo = new PackageInfo();
+        packageInfo.signatures = new Signature[2];
+        packageInfo.signatures[0] = new Signature(VALID_SIGNATURE_BYTES);
+        packageInfo.signatures[1] = new Signature(new byte[16]);
+
+        return packageInfo;
+    }
 
     @Mock
     PackageManager mockPackageManager;
     @Mock
     Context mockContext;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        packageInfo = new PackageInfo();
-        packageInfo.signatures = new Signature[2];
-        packageInfo.signatures[0] = new Signature(sigBytes);
-        packageInfo.signatures[1] = new Signature(new byte[16]);
-
-        when(mockPackageManager.getPackageInfo("com.example.app", PackageManager.GET_SIGNATURES))
-                .thenReturn(packageInfo);
 
-        when(mockContext.getPackageName()).thenReturn(SELF_PACKAGE_NAME);
+        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
+                .thenReturn(VALID_PACKAGE_INFO);
+        when(mockContext.getPackageName()).thenReturn(VALID_PACKAGE_NAME);
         when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
-
     }
 
     @Test
-    public void testGetSelfAuthDomain() throws Exception {
+    public void getSelfAuthDomain_withValidInput_returnsValidDomain() throws Exception {
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+
         assertThat(authDomain).isNotNull();
         assertThat(authDomain.isAndroidAuthDomain()).isTrue();
         assertThat(authDomain.toString())
-                .isEqualTo("android://" + sigSha512HashBase64 + "@com.example.app");
-    }
-
-    @Test
-    public void testListForPackage() {
-        assertThat(AuthenticationDomain.listForPackage(mockContext, "com.example.app")).contains(
-                new AuthenticationDomain("android://" + sigSha512HashBase64 + "@com.example.app"));
+                .isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test
-    public void testListForPackage_nullPackageName() throws Exception {
-        assertThat(AuthenticationDomain.listForPackage(mockContext, null)).isEmpty();
+    public void listForPackage_forValidPackage_containsValidAuthenticationDomain() {
+        assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME))
+                .contains(new AuthenticationDomain(VALID_AUTHENTICATION_DOMAIN_STRING));
     }
 
     @Test
-    public void testEquals() throws Exception {
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        AuthenticationDomain authDomain2 = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        assertTrue(authDomain.equals(authDomain2));
+    public void listForPackage_forNullPackageName_returnsEmpty() throws Exception {
+        assertThat(AuthenticationDomain.listForPackage(mockContext, null /* package */)).isEmpty();
     }
 
     @Test
-    public void testEquals_differentType() throws Exception {
-        AuthenticationDomain domain = new AuthenticationDomain("https://www.example.com");
-        assertFalse(domain.equals("https://www.example.com"));
+    public void listForPackage_packageDoesNotExist_returnsEmpty() throws Exception {
+        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
+                .thenAnswer(new Answer<PackageInfo>() {
+                    @Override
+                    public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
+                        throw new NameNotFoundException();
+                    }
+                });
+
+        assertThat(AuthenticationDomain.listForPackage(mockContext, VALID_PACKAGE_NAME)).isEmpty();
     }
 
     @Test
-    public void testGetUri() throws Exception{
+    public void getUri_returnsExpectedValue() throws Exception{
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        String expectedUri = "android://" +
-                "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_" +
-                "Uhps_I87V4Lo8BdCxaA307H0HYkAw==@com.example.app";
-        assertEquals(expectedUri, authDomain.getUri().toString());
+
+        assertThat(authDomain.getUri().toString()).isEqualTo(VALID_AUTHENTICATION_DOMAIN_STRING);
     }
 
     @Test(expected = RequireViolation.class)
-    public void testCreateAndroidAuthDomain_nullDomain() throws Exception{
-        AuthenticationDomain.createAndroidAuthDomain(null, new Signature(""));
+    public void CreateAndroidAuthDomain_withNullDomain_throwsRequireViolation() throws Exception{
+        AuthenticationDomain.createAndroidAuthDomain(null /* authDomain */, mock(Signature.class));
     }
 
     @Test
-    public void testIsWebAuthDomain(){
-        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        assertFalse(authDomain.isWebAuthDomain());
+    public void validWebAuthDomain_hasExpectedBehaviour() {
+        AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
+
+        assertThat(authDomain.isAndroidAuthDomain()).isFalse();
+        assertThat(authDomain.isWebAuthDomain()).isTrue();
+
+        try {
+            authDomain.getAndroidPackageName();
+
+            failBecauseExceptionWasNotThrown(IllegalStateException.class);
+        } catch (IllegalStateException ex) {}
     }
 
     @Test
-    public void testGetAndroidPackageName(){
+    public void validAndroidAuthDomain_hasExpectedBehaviour(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        assertEquals("com.example.app", authDomain.getAndroidPackageName());
+
+        assertThat(authDomain.isAndroidAuthDomain()).isTrue();
+        assertThat(authDomain.isWebAuthDomain()).isFalse();
+
+        assertThat(authDomain.getAndroidPackageName()).isEqualTo(VALID_PACKAGE_NAME);
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void testGetAndroidPackageName_fromWebDomain() {
-        AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
-        authDomain.getAndroidPackageName();
+    @Test
+    public void getSelfAuthDomain_packageNotFoundException_throwsException() throws Exception {
+        when(mockPackageManager.getPackageInfo(VALID_PACKAGE_NAME, PackageManager.GET_SIGNATURES))
+            .thenAnswer(new Answer<PackageInfo>() {
+                @Override
+                public PackageInfo answer(InvocationOnMock invocation) throws Throwable {
+                    throw new NameNotFoundException();
+                }
+            });
+
+        try {
+            AuthenticationDomain.getSelfAuthDomain(mockContext);
+
+            failBecauseExceptionWasNotThrown(IllegalStateException.class);
+        } catch (IllegalStateException ex) {}
     }
 
     @Test
-    public void stringsToAuthDomains() throws Exception {
+    public void stringsToAuthDomainsConverter_withValidInput_returnsExpectValues()
+            throws Exception {
         List<String> domains = new ArrayList<>();
         domains.add("https://www.google.com");
         domains.add("https://www.yahoo.com");
         domains.add("https://www.facebook.com");
+
         List<AuthenticationDomain> result =
                 CollectionConverter.toList(
                         domains,
                         AuthenticationDomain.CONVERTER_STRING_TO_DOMAIN);
-        assertEquals(3, result.size());
-        assertEquals(result.get(0).getUri().toString(), domains.get(0));
-        assertEquals(result.get(1).getUri().toString(), domains.get(1));
-        assertEquals(result.get(2).getUri().toString(), domains.get(2));
+
+        assertThat(result.size()).isEqualTo(3);
+
+        assertThat(result.get(0).getUri().toString()).isEqualTo(domains.get(0));
+        assertThat(result.get(1).getUri().toString()).isEqualTo(domains.get(1));
+        assertThat(result.get(2).getUri().toString()).isEqualTo(domains.get(2));
     }
 
     @Test
-    public void testGetHashCode(){
+    public void hashCode_ofAuthDomainAndEquivalentUri_areEqual(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        assertEquals(authDomain.getUri().hashCode(), authDomain.hashCode());
+        Uri authDomainUri = authDomain.getUri();
+
+        assertThat(authDomain.hashCode()).isEqualTo(authDomainUri.hashCode());
     }
 
     @Test
-    public void testCompareTo(){
+    public void hashCode_ofAuthDomainAndUnequalUri_areNotEqual(){
         AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
-        AuthenticationDomain authDomain1 = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        Uri authDomainUri = authDomain.getUri();
+
+        assertThat(authDomain.hashCode()).isEqualTo(authDomainUri.hashCode());
+    }
+
+    @Test
+    public void equals_withEquivalent_returnsTrue() throws Exception {
+        AuthenticationDomain authDomainA = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        AuthenticationDomain authDomainB = AuthenticationDomain.getSelfAuthDomain(mockContext);
 
-        assertEquals(0, authDomain.compareTo(authDomain1));
+        assertThat(authDomainA).isEqualTo(authDomainA);
+        assertThat(authDomainA).isEqualTo(authDomainB);
+
+        assertThat(authDomainA.compareTo(authDomainB)).isEqualTo(0);
+    }
+
+    @Test
+    public void equals_withDifferentType_returnsFalse() throws Exception {
+        final String authenticationDomainString = "https://www.example.com";
+        AuthenticationDomain domain = new AuthenticationDomain(authenticationDomainString);
+
+        assertThat(domain).isNotEqualTo(authenticationDomainString);
     }
+
 }
diff --git a/api/javatests/org/openyolo/api/RetrieveRequestTest.java b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
index 4a85115..229738e 100644
--- a/api/javatests/org/openyolo/api/RetrieveRequestTest.java
+++ b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
@@ -19,22 +19,11 @@ package org.openyolo.api;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.Signature;
+
+import android.net.Uri;
 import android.os.Parcel;
 import java.io.IOException;
-import java.util.List;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import org.junit.Before;
@@ -42,4 +31,2 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
 import org.openyolo.proto.CredentialRetrieveRequest;
@@ -49,102 +36,89 @@ import org.robolectric.annotation.Config;
 /**
  * Battery of tests for RetrieveRequest
  */
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = Config.NONE)
 public class RetrieveRequestTest {
 
-    private static final AuthenticationDomain DOMAIN = new AuthenticationDomain(
-            "android://2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8" +
-            "7V4Lo8BdCxaA307H0HYkAw==@com.example.app");
-
     private static final byte[] testBytes = new byte[]
             {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 
     private RetrieveRequest request;
 
     @Before
     public void setUp() {
-        request = new RetrieveRequest.Builder(DOMAIN)
+        request = new RetrieveRequest.Builder()
                 .setAuthenticationMethods(AuthenticationMethods.ID_AND_PASSWORD)
                 .addAdditionalParameter("a", "b")
                 .addAdditionalParameter("c", testBytes)
                 .build();
     }
 
-    @SuppressLint("PackageManagerGetSignatures")
-    @Test
-    public void testForSelf() throws Exception {
-        Context mockContext = mock(Context.class);
-        PackageInfo packageInfo = new PackageInfo();
-        packageInfo.signatures = new Signature[2];
-        packageInfo.signatures[0] = new Signature(testBytes);
-        packageInfo.signatures[1] = new Signature(new byte[16]);
-
-        PackageManager pm = mock(PackageManager.class);
-        when(pm.getPackageInfo("com.example.app", PackageManager.GET_SIGNATURES))
-                .thenReturn(packageInfo);
-        when(mockContext.getPackageName()).thenReturn("com.example.app");
-        when(mockContext.getPackageManager()).thenReturn(pm);
-
-        RetrieveRequest request = RetrieveRequest.forSelf(mockContext);
-
-        assertThat(request).isNotNull();
-        assertThat(request.getAuthenticationDomains().size()).isEqualTo(1);
-        assertThat(request.getAuthenticationDomains()).contains(DOMAIN);
-        assertThat(request.getAuthenticationMethods()).isEmpty();
-        assertThat(request.getAdditionalParameters()).isEmpty();
-    }
-
     @Test
     public void testWriteAndRead() {
         Parcel p = Parcel.obtain();
         try {
             request.writeToParcel(p, 0);
             p.setDataPosition(0);
             RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
             assertThat(deserialized).isNotNull();
-            assertThat(deserialized.getAuthenticationDomains())
-                    .isEqualTo(request.getAuthenticationDomains());
             assertThat(deserialized.getAuthenticationMethods())
                     .isEqualTo(request.getAuthenticationMethods());
             assertMapsEqual(
                     deserialized.getAdditionalParameters(),
                     request.getAdditionalParameters());
         } finally {
             p.recycle();
         }
     }
 
+    @Test
+    public void forAuthenticationMethods_withValidAuthenticationMethodsUsingVarArgs_returnsValidRequest() {
+        RetrieveRequest request = RetrieveRequest
+            .forAuthenticationMethods(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
+
+        assertThat(request.getAuthenticationMethods())
+            .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
+    }
+
+    @Test
+    public void forAuthenticationMethods_withValidAuthenticationMethodUsingSet_returnsValidRequest() {
+        Set<Uri> authenticationMethods = new HashSet<>();
+        Collections.addAll(
+            authenticationMethods,
+            AuthenticationMethods.GOOGLE,
+            AuthenticationMethods.FACEBOOK);
+
+        RetrieveRequest request = RetrieveRequest.forAuthenticationMethods(authenticationMethods);
+
+        assertThat(request.getAuthenticationMethods())
+            .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
+    }
+
     @Test
     public void testGetAdditionalParameters() {
         assertThat(request.getAdditionalParameters()).isNotNull();
         assertThat(request.getAdditionalParameters()).hasSize(2);
         assertThat(request.getAdditionalParameterAsString("a")).isEqualTo("b");
         assertThat(request.getAdditionalParameter("c")).isEqualTo(testBytes);
     }
 
-    @Test
-    public void testGetAuthDomains() {
-        assertThat(request.getAuthenticationDomains()).hasSize(1);
-        assertThat(request.getAuthenticationDomains()).contains(DOMAIN);
-    }
-
     @Test
     public void testGetAuthMethods() {
         assertThat(request.getAuthenticationMethods()).hasSize(1);
         assertThat(request.getAuthenticationMethods())
-                .contains(AuthenticationMethods.ID_AND_PASSWORD);
+                .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
     }
 
     @Test(expected = NullPointerException.class)
     public void testAdapter_nullArray() throws IOException {
         CredentialRetrieveRequest.ADAPTER.decode((byte[]) null);
     }
 
     private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
         assertThat(a.keySet()).isEqualTo(b.keySet());
         for (T key : a.keySet()) {
             assertThat(a.get(key)).isEqualTo(b.get(key));
         }
     }
 }
\ No newline at end of file
diff --git a/api/proto/openyolo.proto b/api/proto/openyolo.proto
index 3eda1a7..3c5cf5e 100644
--- a/api/proto/openyolo.proto
+++ b/api/proto/openyolo.proto
@@ -23,5 +23,13 @@ option java_package = "org.openyolo.proto";
 message CredentialRetrieveRequest {
-    repeated string       authDomains        = 1; // at least one required
+    /**
+     * Deprecated since 03/07/17
+     * Filtering credentials by authentication domains has been deprecated. The
+     * authentication domain must instead be determined implicitly by via the
+     * calling package name.
+     * @see <a href="https://github.com/openid/OpenYOLO-Android/issues/5">
+     *     Original discussion to deprecate</a>
+     */
+    repeated string       authDomains        = 1 [deprecated=true];
     repeated string       authMethods        = 2; // at least one required
     repeated KeyValuePair additionalParams   = 3;
 }
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
index 9df1169..0a8ded8 100644
--- a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
@@ -23,3 +23,2 @@ import com.google.bbq.proto.BroadcastQuery;
 import java.io.IOException;
-import java.util.HashSet;
 import java.util.Iterator;
@@ -35,80 +34,63 @@ import org.openyolo.spi.BaseCredentialQueryReceiver;
 /**
  * Implements the OpenYOLO credential query receiver. This receiver is able to determine whether
  * a credential exists for the claimed set of authentication domains without unlocking the
  * password store.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull final Context context,
             @NonNull final BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
         // NOTE: in a more complete implementation, this is where we would expand the set of
         // authentication domains listed in requestorDomains to all equivalent authentication
         // domains (such as affiliated apps and sites). This potentially larger list would then be
         // matched against the requested set of domains.
 
-        final Set<AuthenticationDomain> matchingDomains = new HashSet<>();
-        for (AuthenticationDomain domain : request.getAuthenticationDomains()) {
-            if (requestorDomains.contains(domain)) {
-                matchingDomains.add(domain);
-            } else {
-                Log.i(LOG_TAG, "Access to credentials in domain " + domain
-                        + " denied to " + query.requestingApp);
-            }
-        }
-
-        if (matchingDomains.isEmpty()) {
-            Log.w(LOG_TAG, "Credential request from " + query.requestingApp
-                    + " does not match any permitted domains");
-            responseSender.sendResponse(query, null);
-            return;
-        }
-
         Log.i(LOG_TAG, "Processing query for " + query.requestingApp);
 
         CredentialStorage storage;
         try {
             storage = new CredentialStorage(context);
         }  catch (IOException ex) {
             Log.w(LOG_TAG, "Failed to open credential storage", ex);
             responseSender.sendResponse(query, null);
             return;
         }
 
         boolean credentialsFound = false;
         byte[] responseBytes = null;
 
-        Iterator<AuthenticationDomain> authDomainIter = matchingDomains.iterator();
+        Iterator<AuthenticationDomain> authDomainIter = requestorDomains.iterator();
         while (!credentialsFound && authDomainIter.hasNext()) {
             credentialsFound = storage.hasCredentialFor(authDomainIter.next().toString());
         }
 
         Log.d(LOG_TAG, "Credentials found for " + query.requestingApp + ": " + credentialsFound);
 
         if (credentialsFound) {
             Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context);
             CredentialRetrieveResponse response = new CredentialRetrieveResponse.Builder()
                     .retrieveIntent(ByteString.of(IntentUtil.toBytes(retrieveIntent)))
                     .build();
             responseBytes = response.encode();
         }
 
         responseSender.sendResponse(query, responseBytes);
     }
 }
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
index b6a6f4e..8707af9 100644
--- a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -22,7 +22,6 @@ import com.google.bbq.QueryResponseSender;
 import com.google.bbq.proto.BroadcastQuery;
-import java.util.HashSet;
 import java.util.Set;
-import java.util.TreeSet;
 import okio.ByteString;
 import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
 import org.openyolo.api.RetrieveRequest;
@@ -31,51 +30,46 @@ import org.openyolo.proto.CredentialRetrieveResponse;
 import org.openyolo.spi.BaseCredentialQueryReceiver;
 
 /**
  * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
- * we respond to all requests with an intent as long as at least one of the requested authentication
- * domains is explicitly associated with the requesting app, and that the
+ * we respond to all requests with an intent as long as the
  * {@link org.openyolo.api.AuthenticationMethods#ID_AND_PASSWORD id and password} authentication
  * method is supported.
  */
 public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
 
     private static final String LOG_TAG = "CredentialQueryReceiver";
 
     /**
      * Creates the query receiver.
      */
     public CredentialQueryReceiver() {
         super(LOG_TAG);
     }
 
     @Override
     protected void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains) {
 
         Log.i(LOG_TAG, "Processing retrieve query from claimed caller: " + query.requestingApp);
 
         final Context applicationContext = context.getApplicationContext();
         final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
 
-        TreeSet<AuthenticationDomain> matchingDomains =
-                new TreeSet<AuthenticationDomain>(requestorDomains);
-        matchingDomains.retainAll(new HashSet<Object>(request.getAuthenticationDomains()));
-
-        if (matchingDomains.isEmpty()) {
-            Log.i(LOG_TAG, "Caller does not match any requested auth domains - ignoring");
-            responseSender.sendResponse(query, null);
+        // Ensure the caller supports the Id and Password authentication method
+        if (!request.getAuthenticationMethods().contains(AuthenticationMethods.ID_AND_PASSWORD)) {
+            responseSender.sendResponse(query,  null /* response */);
             return;
         }
 
         Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
         CredentialRetrieveResponse response = new CredentialRetrieveResponse.Builder()
                 .retrieveIntent(ByteString.of(IntentUtil.toBytes(retrieveIntent)))
                 .build();
 
         Log.i(LOG_TAG, "Accepting credential request for claimed caller: " + query.requestingApp);
         responseSender.sendResponse(query, response.encode());
     }
 }
diff --git a/spec/en/openyolo-overview.md b/spec/en/openyolo-overview.md
index 096144e..61cfc98 100644
--- a/spec/en/openyolo-overview.md
+++ b/spec/en/openyolo-overview.md
@@ -184,5 +184,3 @@ recipients specified by package name in order to asynchronously deliver
 requests and responses. A retrieval request carries the following information:
 
-- A set of authentication domains from which a credential is required.
-
 - The set of authentication mechanisms that are supported by the requester.
diff --git a/spec/en/retrieving-credentials.md b/spec/en/retrieving-credentials.md
index 2d60666..b28a215 100644
--- a/spec/en/retrieving-credentials.md
+++ b/spec/en/retrieving-credentials.md
@@ -9,21 +9,14 @@ NOTE: writing this chapter is *in progress*.
 ```protobuf
 message CredentialRetrieveRequest {
-    repeated string       authDomains        = 1; // at least one required
     repeated string       authMethods        = 2; // at least one required
     repeated KeyValuePair additionalParams   = 3;
 }
 ```
 
-The set of authentication domains specified in the request _may_ be disjoint
-from the set of domains known to be related to the requester (via its package
-name): such requests would allow trusted intermediaries (e.g. keyboard apps,
-mail clients, etc.) to request credentials that they do not directly own.
-It is the responsibility of the credential provider to determine whether to
-permit such requests. Typically, requests should only be permitted for
-an authentication domain that is provably associated with to the requester,
-or if the app has been explicitly whitelisted (by the user or provider) to
-request credentials outside its equivalence class.
+The CredentialRetrieveRequest must explicitly specify all credentials qualifiers the client
+supports with the exception of the authentication domain which will determined implicitly via the
+callers package name.
 
 ## Retrieve response messages
 
 ```protobuf
diff --git a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
index ac9eaf6..7d16e8d 100644
--- a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
+++ b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
@@ -30,49 +30,55 @@ import org.openyolo.proto.CredentialRetrieveRequest;
 /**
  * Partial implementation of an OpenYOLO request receiver, that should be extended by providers.
  * This implementation handles some basic validation and decoding of the request before
  * handing the request to
  * {@link #processCredentialRequest(Context, BroadcastQuery, RetrieveRequest, Set)}.
  */
 public abstract class BaseCredentialQueryReceiver extends BaseBroadcastQueryReceiver {
 
     /**
      * Creates a receiver that will log errors to the specified log tag.
      */
     public BaseCredentialQueryReceiver(String logTag) {
         super(logTag);
     }
 
     @Override
     protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
         CredentialRetrieveRequest requestProto;
         try {
             requestProto = CredentialRetrieveRequest.ADAPTER.decode(query.queryMessage);
         } catch (NullPointerException | IOException ex) {
             Log.w(mLogTag, "Failed to parse credential request message", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         RetrieveRequest request;
         try {
             request = new RetrieveRequest.Builder(requestProto).build();
         } catch (NullPointerException | IllegalArgumentException ex) {
-            // respond with no result
             Log.w(mLogTag, "Credential request message failed field validation", ex);
             new QueryResponseSender(context).sendResponse(query, null);
             return;
         }
 
         // TODO: validate claimed authentication domains
         Set<AuthenticationDomain> requestorDomains =
                 new HashSet<>(AuthenticationDomain.listForPackage(context, query.requestingApp));
 
+        // Ensure the authentication domain of the requesting app can be determined
+        if (requestorDomains.isEmpty()) {
+            Log.w(mLogTag, "Unable to determine the authentication domain of the requesting app");
+            new QueryResponseSender(context).sendResponse(query, null);
+            return;
+        }
+
         processCredentialRequest(context, query, request, requestorDomains);
     }
 
     protected abstract void processCredentialRequest(
             @NonNull Context context,
             @NonNull BroadcastQuery query,
             @NonNull RetrieveRequest request,
             @NonNull Set<AuthenticationDomain> requestorDomains);
 }
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
index ad80b0f..f066a07 100644
--- a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -19,15 +19,16 @@ package org.openyolo.spi;
 
-import static junit.framework.TestCase.assertNotNull;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
 import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.Signature;
 import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
 import com.google.bbq.proto.BroadcastQuery;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
@@ -46,87 +47,149 @@ import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
 
 /**
- * Battery of tests for BaseCredentialQueryReceiver
+ * Unit tests for {@link BaseCredentialQueryReceiver}.
  */
 @RunWith(RobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
+@Config(manifest = Config.NONE,
+        shadows = {
+                ShadowQueryResponseSender.class,
+                ShadowAuthenticationDomain.class
+        })
 public class BaseCredentialQueryReceiverTest {
-    private BaseCredentialQueryReceiver underTest;
+
+    private BaseCredentialQueryReceiver credentialQueryReceiver;
+
     @Mock
     Context mockContext;
-    @Mock
-    PackageManager mockPackageManager;
-    @Mock
-    Intent mockIntent;
 
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        underTest = new BaseCredentialQueryReceiver("testTage") {
-            @Override
-            protected void processCredentialRequest(
-                    @NonNull Context context,
-                    @NonNull BroadcastQuery query,
-                    @NonNull RetrieveRequest request,
-                    @NonNull Set<AuthenticationDomain> requestorDomains) {
-                assertNotNull(context);
-                assertNotNull(query);
-                assertNotNull(request);
-                assertNotNull(requestorDomains);
-            }
-        };
-        PackageInfo mockPackageInfo = new PackageInfo();
-        Signature[] signatures = new Signature[1];
-        signatures[0] = mock(Signature.class);
-        when(signatures[0].toByteArray()).thenReturn(new byte[10]);
-        mockPackageInfo.signatures = signatures;
-        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
-        when(mockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mockPackageInfo);
+    private static final String CALLING_PACKAGE_NAME = "org.openyolo.supercoolapp";
 
-    }
+    private static final BroadcastQuery BROADCAST_QUERY_WITH_NULL_MESSAGE =
+            new BroadcastQuery.Builder()
+                    .requestingApp(CALLING_PACKAGE_NAME)
+                    .dataType("blah")
+                    .requestId(101L)
+                    .responseId(102L)
+                    .queryMessage(null)
+                    .build();
 
-    @Test
-    public void testOnReceive() throws Exception {
-        underTest.onReceive(mockContext, mockIntent);
-    }
+    private static final CredentialRetrieveRequest VALID_CREDENTIAL_RETRIEVE_REQUEST =
+            makeValidCredentialRetrieveRequest();
 
-    @Test
-    public void testProcessQuery_nullPointer() throws Exception {
-
-        BroadcastQuery local = new BroadcastQuery.Builder()
-                .requestingApp("org.openyolo")
-                .dataType("blah")
-                .requestId(101L)
-                .responseId(102L)
-                .queryMessage(null)
-                .build();
-        underTest.processQuery(mockContext, local);
-    }
+    private static final ByteString VALID_CREDENTIAL_RETRIEVE_REQUEST_BYTE_STRING =
+            ByteString.of(
+                    CredentialRetrieveRequest.ADAPTER.encode(VALID_CREDENTIAL_RETRIEVE_REQUEST));
 
-    @Test
-    public void testProcessQuery_nonNull() throws Exception {
+    private static final BroadcastQuery BROADCAST_QUERY_WITH_VALID_MESSAGE =
+            new BroadcastQuery.Builder()
+                    .requestingApp(CALLING_PACKAGE_NAME)
+                    .dataType("blah")
+                    .requestId(101L)
+                    .responseId(102L)
+                    .queryMessage(VALID_CREDENTIAL_RETRIEVE_REQUEST_BYTE_STRING)
+                    .build();
+
+    private static final List<AuthenticationDomain> VALID_AUTHENTICATION_DOMAINS =
+            makeValidAuthenticationDomains();
+
+    private static List<AuthenticationDomain> makeValidAuthenticationDomains() {
+        List<AuthenticationDomain> authenticationDomains = new ArrayList<>();
+        authenticationDomains.add(mock(AuthenticationDomain.class));
+
+        return authenticationDomains;
+    }
 
+    private static CredentialRetrieveRequest makeValidCredentialRetrieveRequest() {
         List<String> authDomains = new ArrayList<>();
-        authDomains.add("https://www.google.com");
-        authDomains.add("https://www.yahoo.com");
         List<String> authMethods = new ArrayList<>();
         authMethods.add("custom://one");
         authMethods.add("custom://two");
         List<KeyValuePair> additionalParams = new ArrayList<>();
-        CredentialRetrieveRequest query = new CredentialRetrieveRequest(
+
+        return new CredentialRetrieveRequest(
                 authDomains,
                 authMethods,
                 additionalParams,
                 ByteString.EMPTY);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        ShadowQueryResponseSender.intializeForTest();
+
+        credentialQueryReceiver = spy(
+                new BaseCredentialQueryReceiver("TestCredentialQueryReceiver") {
+                    @Override
+                    protected void processCredentialRequest(
+                            @NonNull Context context,
+                            @NonNull BroadcastQuery query,
+                            @NonNull RetrieveRequest request,
+                            @NonNull Set<AuthenticationDomain> requestorDomains) {
+                        // Do nothing
+                    }
+                });
+
+        ShadowAuthenticationDomain.setListForPackageResponse(VALID_AUTHENTICATION_DOMAINS);
+    }
+
+    @Test
+    public void processQuery_withNullQuery_sendsNullResponse() throws Exception {
+        credentialQueryReceiver.processQuery(mockContext, BROADCAST_QUERY_WITH_NULL_MESSAGE);
+
+        verifyProcessCredentialRequestWasNotCalled();
+        verifyQueryResponseIsSentWith(null /* response */);
+    }
+
+    @Test
+    public void processQuery_withValidQuery_processesRequest() throws Exception {
+        credentialQueryReceiver.processQuery(mockContext, BROADCAST_QUERY_WITH_VALID_MESSAGE);
+
+        verifyProcessCredentialRequestWasCalled();
+        verifyQueryResponseIsNotSent();
+    }
+
+    @Test
+    public void processQuery_withValidQueryAndUnableToDetermineAuthenticationDomain_sendsNullResponse()
+            throws Exception {
+        ShadowAuthenticationDomain.setListForPackageResponse(Collections.EMPTY_LIST);
+        credentialQueryReceiver.processQuery(mockContext, BROADCAST_QUERY_WITH_VALID_MESSAGE);
+
+        verifyProcessCredentialRequestWasNotCalled();
+        verifyQueryResponseIsSentWith(null /* response */);
+    }
+
+    private void verifyQueryResponseIsNotSent() {
+        verify(ShadowQueryResponseSender.mockQueryResponseSender, times(0))
+                .sendResponse((BroadcastQuery) any(), (byte[]) any());
+    }
+
+    private void verifyQueryResponseIsSentWith(@Nullable byte[] response) {
+        if (null == response) {
+            verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
+                    .sendResponse((BroadcastQuery) any(), (byte[]) isNull());
+            return;
+        }
+
+        verify(ShadowQueryResponseSender.mockQueryResponseSender, times(1))
+                .sendResponse((BroadcastQuery) any(), eq(response));
+    }
+
+    private void verifyProcessCredentialRequestWasCalled() {
+        verify(credentialQueryReceiver, times(1))
+                .processCredentialRequest(
+                        (Context) any(),
+                        (BroadcastQuery) any(),
+                        (RetrieveRequest) any(),
+                        (Set<AuthenticationDomain>) any());
+    }
 
-        byte[] data = CredentialRetrieveRequest.ADAPTER.encode(query);
-        BroadcastQuery local = new BroadcastQuery.Builder()
-                .requestingApp("org.openyolo")
-                .dataType("blah")
-                .requestId(101L)
-                .responseId(102L)
-                .queryMessage(ByteString.of(data))
-                .build();
-        underTest.processQuery(mockContext, local);
+    private void verifyProcessCredentialRequestWasNotCalled() {
+        verify(credentialQueryReceiver, times(0))
+                .processCredentialRequest(
+                        (Context) any(),
+                        (BroadcastQuery) any(),
+                        (RetrieveRequest) any(),
+                        (Set<AuthenticationDomain>) any());
     }
 }
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java b/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
new file mode 100644
index 0000000..eae5017
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/ShadowAuthenticationDomain.java
@@ -0,0 +1,31 @@
+package org.openyolo.spi;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.util.Collections;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+/**
+ * Shadow for {@link AuthenticationDomain}
+ */
+@Implements(AuthenticationDomain.class)
+public class ShadowAuthenticationDomain {
+
+    private static List<AuthenticationDomain> authenticationDomains = Collections.EMPTY_LIST;
+
+    public static void setListForPackageResponse(
+            List<AuthenticationDomain> authenticationDomainsResponse) {
+        authenticationDomains = authenticationDomainsResponse;
+    }
+
+    @Implementation
+    public static List<AuthenticationDomain> listForPackage(
+            @NonNull Context context,
+            @Nullable String packageName) {
+        return authenticationDomains;
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java b/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java
new file mode 100644
index 0000000..a3c4953
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/ShadowQueryResponseSender.java
@@ -0,0 +1,30 @@
+package org.openyolo.spi;
+
+import static org.mockito.Mockito.mock;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.google.bbq.QueryResponseSender;
+import com.google.bbq.proto.BroadcastQuery;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+/**
+ * Shadow for {@link QueryResponseSender}
+ */
+@Implements(QueryResponseSender.class)
+public class ShadowQueryResponseSender {
+    public ShadowQueryResponseSender() {}
+
+    public static QueryResponseSender mockQueryResponseSender = mock(QueryResponseSender.class);
+
+    public static void intializeForTest() {
+        mockQueryResponseSender = mock(QueryResponseSender.class);
+    }
+
+    @Implementation
+    public void sendResponse(@NonNull BroadcastQuery query, @Nullable byte[] responseMessage) {
+        mockQueryResponseSender.sendResponse(query, responseMessage);
+    }
+}
+
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index e88fd01..b5ff4aa 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -33,3 +33,2 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
-import org.openyolo.api.AuthenticationDomain;
 import org.openyolo.api.Credential;
@@ -41,116 +40,114 @@ import org.openyolo.api.RetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
     @BindView(R.id.authentication_methods_input)
     AuthenticationMethodsInputView mAuthenticationMethodsInputView;
 
     @BindView(R.id.retrieve_credential)
     CredentialView mCredentialView;
 
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
         mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         mCredentialView.clearFields();
 
-        AuthenticationDomain authenticationDomain =
-                AuthenticationDomain.getSelfAuthDomain(getContext());
         Set<Uri> authenticationMethods =
                 mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
-        RetrieveRequest request = new RetrieveRequest.Builder(authenticationDomain)
+        RetrieveRequest request = new RetrieveRequest.Builder()
                 .setAuthenticationMethods(authenticationMethods)
                 .build();
 
         mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 

commit 945add8ba143b7598e89b4b04dbcbf882f87434c
Author: David Samuelson <samuelsond@google.com>
Date:   Mon Mar 6 13:31:43 2017 -0800

    - Added support for selecting multiple authentication methods for the
    credential retrieve request.
    - Organized string values.

diff --git a/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
new file mode 100644
index 0000000..1e2c26b
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/AuthenticationMethodsInputView.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.content.Context;
+import android.net.Uri;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import java.util.HashSet;
+import java.util.Set;
+import org.openyolo.api.AuthenticationMethods;
+
+public final class AuthenticationMethodsInputView extends LinearLayout {
+
+    @BindView(R.id.facebook_authentication_method_checkbox)
+    CheckBox mFaceBookCheckBox;
+
+    @BindView(R.id.google_authentication_method_checkbox)
+    CheckBox mGoogleCheckBox;
+
+    @BindView(R.id.id_and_password_authentication_method_checkbox)
+    CheckBox mIdAndPasswordCheckBox;
+
+    @BindView(R.id.custom_authentication_method_checkbox)
+    CheckBox mCustomAuthenticationMethodCheckBox;
+
+    @BindView(R.id.custom_authentication_method)
+    EditText mCustomAuthenticationMethod;
+
+    AuthenticationMethodsInputView(Context context) {
+        super(context);
+        initialize(context);
+    }
+
+    AuthenticationMethodsInputView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initialize(context);
+    }
+
+    AuthenticationMethodsInputView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        initialize(context);
+    }
+
+    private void initialize(Context context) {
+        View view = View.inflate(context, R.layout.authentication_method_input_layout, this);
+
+        ButterKnife.bind(view);
+    }
+
+    /**
+     * @return A set of authentication domains that are marked as enabled.
+     */
+    public Set<Uri> getEnabledAuthenticationMethods() {
+        Set<Uri> authenticationMethods = new HashSet<>();
+
+        if (mFaceBookCheckBox.isChecked()) {
+            authenticationMethods.add(AuthenticationMethods.FACEBOOK);
+        }
+
+        if (mGoogleCheckBox.isChecked()) {
+            authenticationMethods.add(AuthenticationMethods.GOOGLE);
+        }
+
+        if (mIdAndPasswordCheckBox.isChecked()) {
+            authenticationMethods.add(AuthenticationMethods.ID_AND_PASSWORD);
+        }
+
+        if (mCustomAuthenticationMethodCheckBox.isChecked()) {
+            Uri authenticationMethod = Uri.parse(mCustomAuthenticationMethod.getText().toString());
+            authenticationMethods.add(authenticationMethod);
+        }
+
+        return authenticationMethods;
+    }
+}
diff --git a/testapp/java/org/openyolo/testapp/CredentialFragment.java b/testapp/java/org/openyolo/testapp/CredentialView.java
similarity index 83%
rename from testapp/java/org/openyolo/testapp/CredentialFragment.java
rename to testapp/java/org/openyolo/testapp/CredentialView.java
index 1ba6386..6c769a9 100644
--- a/testapp/java/org/openyolo/testapp/CredentialFragment.java
+++ b/testapp/java/org/openyolo/testapp/CredentialView.java
@@ -16,10 +16,8 @@ package org.openyolo.testapp;
 
+import android.content.Context;
 import android.net.Uri;
-import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
+import android.util.AttributeSet;
 import android.view.View;
-import android.view.ViewGroup;
 import android.widget.EditText;
@@ -27,2 +25,3 @@ import android.widget.ImageButton;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import butterknife.BindView;
@@ -36,205 +35,192 @@ import org.openyolo.api.Credential;
 import org.openyolo.api.PasswordSpecification;
 
-/**
- * A reusable fragment that displays an OpenYolo credential.
- */
-public final class CredentialFragment extends Fragment {
+public final class CredentialView extends LinearLayout {
 
-    private static final String EXTRA_ENABLE_INPUT_GENERATION = "EXTRA_ENABLE_INPUT_GENERATION";
     @BindView(R.id.generate_id_button)
     ImageButton mGenerateIdButton;
 
     @BindView(R.id.generate_password_button)
     ImageButton mGeneratePasswordButton;
 
     @BindView(R.id.openyolo_id_and_password_provider_button)
     ImageButton mIdAndPasswordProviderButton;
 
     @BindView(R.id.google_provider_button)
     ImageButton mGenerateProviderButton;
 
     @BindView(R.id.facebook_provider_button)
     ImageButton mFacebookProviderButton;
 
     @BindView(R.id.generate_display_name_button)
     ImageButton mGenerateDisplayNameButton;
 
     @BindView(R.id.generate_profile_picture_button)
     ImageButton mGenerateProfilePictureButton;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.authentication_method_field)
     EditText mAuthenticationMethodField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     private RandomData mRandomData;
 
-    /**
-     * Returns a new instance of a {@link CredentialFragment}.
-     */
-    public static CredentialFragment newInstance(boolean enableInputGeneration) {
-        Bundle args = new Bundle();
-        args.putBoolean(EXTRA_ENABLE_INPUT_GENERATION, enableInputGeneration);
-
-        CredentialFragment fragment = new CredentialFragment();
-        fragment.setArguments(args);
-        return fragment;
+    CredentialView(Context context) {
+        super(context);
+        initialize(context);
     }
 
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        mRandomData = new RandomData();
+    CredentialView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initialize(context);
     }
 
-    @Override
-    public View onCreateView(
-            LayoutInflater inflater,
-            ViewGroup container,
-            Bundle savedInstanceState) {
+    CredentialView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        initialize(context);
+    }
 
-        View view = inflater.inflate(R.layout.credential_layout, container, false);
-        ButterKnife.bind(this, view);
-        setEnableInputGeneration(getArguments().getBoolean(EXTRA_ENABLE_INPUT_GENERATION));
+    private void initialize(Context context) {
+        View view = View.inflate(context, R.layout.credential_layout, this);
 
-        return view;
+        mRandomData = new RandomData();
+        ButterKnife.bind(view);
     }
 
     /**
      * Hides or shows input generation buttons.
      */
-    private void setEnableInputGeneration(boolean isEnabled) {
+    public void setEnableInputGeneration(boolean isEnabled) {
         int visibility = View.GONE;
         if (isEnabled) {
             visibility = View.VISIBLE;
         }
 
         mGenerateIdButton.setVisibility(visibility);
         mGeneratePasswordButton.setVisibility(visibility);
         mGenerateProviderButton.setVisibility(visibility);
         mIdAndPasswordProviderButton.setVisibility(visibility);
         mFacebookProviderButton.setVisibility(visibility);
         mGenerateDisplayNameButton.setVisibility(visibility);
         mGenerateProfilePictureButton.setVisibility(visibility);
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.openyolo_id_and_password_provider_button)
     void setIdAndPasswordAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookAuthenticationMethod() {
         mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
-        Glide.with(this)
+        Glide.with(getContext())
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     /**
      * Clears all of the credential's fields.
      */
     public void clearFields() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mAuthenticationMethodField.setText("");
         mProfilePictureField.setText("");
     }
 
     /**
      * Populates the fragment's fields from a given OpenYolo credential.
+     *
      * @param credential an OpenYolo credential
      */
     public void setFieldsFromCredential(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
     }
 
     /**
      * Create an OpenYolo credential from the current fragment's fields.
+     *
      * @return an OpenYolo Credential .
      */
     @Nullable
     public Credential makeCredentialFromFields() {
         String authenticationMethod = mAuthenticationMethodField.getText().toString();
         Uri authMethodUri = Uri.parse(authenticationMethod);
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethodUri,
                 authenticationDomain)
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
             credentialBuilder.setPassword(mPasswordField.getText().toString());
         }
 
         return credentialBuilder.build();
     }
 
     private static String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
-
 }
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
index 4caeffd..ee0cf18 100644
--- a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -22,7 +22,4 @@ import android.net.Uri;
 import android.os.Bundle;
-import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
 import android.support.design.widget.Snackbar;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
 import android.view.LayoutInflater;
@@ -40,107 +37,98 @@ import org.openyolo.api.HintRequest;
 /**
  * Fragment which contains a method of testing the OpenYolo credential hint flow.
  */
 public final class HintTestPageFragment extends TestPageFragment {
 
     private static final int RC_HINT = 0;
 
-    @BindView(R.id.authentication_method)
-    EditText mAuthenticationMethod;
+    @BindView(R.id.authentication_method_text_input)
+    EditText mAuthenticationMethodInput;
+
+    @BindView(R.id.hint_credential)
+    CredentialView mCredentialView;
 
-    private CredentialFragment mCredentialFragment;
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Hint";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.hint_test_layout, container, false);
         ButterKnife.bind(this, view);
+        mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
-    @Override
-    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
-        FragmentManager fm = getChildFragmentManager();
-        mCredentialFragment = (CredentialFragment) fm.findFragmentById(R.id.hint_credential);
-        if (null == mCredentialFragment) {
-            FragmentTransaction fragmentTransaction = fm.beginTransaction();
-            mCredentialFragment = CredentialFragment.newInstance(false /* enableInputGeneration */);
-            fragmentTransaction.add(R.id.hint_credential, mCredentialFragment);
-            fragmentTransaction.commit();
-        }
-    }
-
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_HINT) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
-                mCredentialFragment.setFieldsFromCredential(credential);
+                mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
-        mCredentialFragment.clearFields();
+        mCredentialView.clearFields();
 
-        Uri authMethodUri = Uri.parse(mAuthenticationMethod.getText().toString());
+        Uri authMethodUri = Uri.parse(mAuthenticationMethodInput.getText().toString());
 
         HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethodUri);
 
         Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.openyolo_id_and_password_provider_button)
     void onIdAndPasswordAuthenticationMethod() {
-        mAuthenticationMethod.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
+        mAuthenticationMethodInput.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
     }
 
     @OnClick(R.id.google_provider_button)
     void onGoogleAuthenticationMethod() {
-        mAuthenticationMethod.setText(AuthenticationMethods.GOOGLE.toString());
+        mAuthenticationMethodInput.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void onFacebookAuthenticationMethod() {
-        mAuthenticationMethod.setText(AuthenticationMethods.FACEBOOK.toString());
+        mAuthenticationMethodInput.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
index 3ec2c8d..0b77c6e 100644
--- a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
+++ b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
@@ -28,52 +28,52 @@ import java.util.List;
 /**
  * The main OpenYolo test activity.
  */
-public class OpenYoloTestActivity extends AppCompatActivity {
+public final class OpenYoloTestActivity extends AppCompatActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.main_layout);
 
         setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
 
         final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
         DemoPagerAdapter demoPagerAdapter = new DemoPagerAdapter(getSupportFragmentManager());
         demoPagerAdapter.addPage(new RetrieveTestPageFragment());
         demoPagerAdapter.addPage(new SaveTestPageFragment());
         demoPagerAdapter.addPage(new HintTestPageFragment());
 
         viewPager.setAdapter(demoPagerAdapter);
         TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
         tabLayout.setupWithViewPager(viewPager);
     }
 
     private static class DemoPagerAdapter extends FragmentPagerAdapter {
 
         private final List<TestPageFragment> mPages = new ArrayList<>();
 
         DemoPagerAdapter(FragmentManager fragmentManager) {
             super(fragmentManager);
         }
 
         @Override
         public int getCount() {
             return mPages.size();
         }
 
         public void addPage(TestPageFragment pageFragment) {
             mPages.add(pageFragment);
         }
 
         @Override
         public Fragment getItem(int position) {
             return mPages.get(position);
         }
 
         @Override
         public CharSequence getPageTitle(int position) {
             return mPages.get(position).getPageTitle();
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
index 95a7c1d..e88fd01 100644
--- a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -23,7 +23,4 @@ import android.net.Uri;
 import android.os.Bundle;
-import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
 import android.support.design.widget.Snackbar;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
 import android.view.LayoutInflater;
@@ -31,3 +28,2 @@ import android.view.View;
 import android.view.ViewGroup;
-import android.widget.EditText;
 import butterknife.BindView;
@@ -35,5 +31,5 @@ import butterknife.ButterKnife;
 import butterknife.OnClick;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
 import org.openyolo.api.Credential;
@@ -45,138 +41,116 @@ import org.openyolo.api.RetrieveResult;
 /**
  * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
  */
 public final class RetrieveTestPageFragment extends TestPageFragment {
 
     private static final int RC_RETRIEVE = 0;
 
-    @BindView(R.id.authentication_method)
-    EditText mAuthenticationMethod;
+    @BindView(R.id.authentication_methods_input)
+    AuthenticationMethodsInputView mAuthenticationMethodsInputView;
+
+    @BindView(R.id.retrieve_credential)
+    CredentialView mCredentialView;
 
-    private CredentialFragment mCredentialFragment;
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Retrieve";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getContext());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
 
         ButterKnife.bind(this, view);
+        mCredentialView.setEnableInputGeneration(false);
 
         return view;
     }
 
-    @Override
-    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
-        FragmentManager fm = getChildFragmentManager();
-        mCredentialFragment = (CredentialFragment) fm.findFragmentById(R.id.retrieve_credential);
-        if (null == mCredentialFragment) {
-            FragmentTransaction fragmentTransaction = fm.beginTransaction();
-            mCredentialFragment = CredentialFragment.newInstance(false /* enableInputGeneration */);
-            fragmentTransaction.add(R.id.retrieve_credential, mCredentialFragment);
-            fragmentTransaction.commit();
-        }
-    }
-
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_RETRIEVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
-                mCredentialFragment.setFieldsFromCredential(credential);
+                mCredentialView.setFieldsFromCredential(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
-        mCredentialFragment.clearFields();
+        mCredentialView.clearFields();
 
-        Uri authenticationMethod = Uri.parse(mAuthenticationMethod.getText().toString());
         AuthenticationDomain authenticationDomain =
                 AuthenticationDomain.getSelfAuthDomain(getContext());
+        Set<Uri> authenticationMethods =
+                mAuthenticationMethodsInputView.getEnabledAuthenticationMethods();
 
         RetrieveRequest request = new RetrieveRequest.Builder(authenticationDomain)
-                .setAuthenticationMethods(authenticationMethod)
+                .setAuthenticationMethods(authenticationMethods)
                 .build();
-        mApi.retrieve(request, new HandleRetrieveResult());
-    }
-
-    @OnClick(R.id.openyolo_id_and_password_provider_button)
-    void onIdAndPasswordAuthenticationMethod() {
-        mAuthenticationMethod.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
-    }
 
-    @OnClick(R.id.google_provider_button)
-    void onGoogleAuthenticationMethod() {
-        mAuthenticationMethod.setText(AuthenticationMethods.GOOGLE.toString());
-    }
-
-    @OnClick(R.id.facebook_provider_button)
-    void onFacebookAuthenticationMethod() {
-        mAuthenticationMethod.setText(AuthenticationMethods.FACEBOOK.toString());
+        mApi.retrieve(request, new HandleRetrieveResult());
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             getActivity().runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 return;
             }
 
             try {
                 startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
             } catch (ActivityNotFoundException ex) {
                 showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
             }
         }
     }
 }
 
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
index 675a95b..116b93c 100644
--- a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -21,7 +21,4 @@ import android.content.Intent;
 import android.os.Bundle;
-import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
 import android.support.design.widget.Snackbar;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
 import android.view.LayoutInflater;
@@ -29,2 +26,3 @@ import android.view.View;
 import android.view.ViewGroup;
+import butterknife.BindView;
 import butterknife.ButterKnife;
@@ -35,80 +33,71 @@ import org.openyolo.api.CredentialClient;
 /**
  * Fragment which contains a method of testing the OpenYolo credential save flow.
  */
-public class SaveTestPageFragment extends TestPageFragment {
+public final class SaveTestPageFragment extends TestPageFragment {
 
     private static final int RC_SAVE = 0;
 
-    private CredentialFragment mCredentialFragment;
+    @BindView(R.id.save_credential)
+    CredentialView mCredentialView;
+
     private CredentialClient mApi;
 
     public String getPageTitle() {
         return "Save";
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mApi = CredentialClient.getApplicationBoundInstance(getActivity());
     }
 
     @Override
     public View onCreateView(
             LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.save_test_layout, container, false);
 
         ButterKnife.bind(this, view);
+        mCredentialView.setEnableInputGeneration(true);
 
         return view;
     }
 
-    @Override
-    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
-        FragmentManager fm = getChildFragmentManager();
-        mCredentialFragment = (CredentialFragment) fm.findFragmentById(R.id.save_credential);
-        if (null == mCredentialFragment) {
-            FragmentTransaction fragmentTransaction = fm.beginTransaction();
-            mCredentialFragment = CredentialFragment.newInstance(true /* enableInputGeneration */);
-            fragmentTransaction.add(R.id.save_credential, mCredentialFragment);
-            fragmentTransaction.commit();
-        }
-    }
-
     @OnClick(R.id.save_button)
     void onSave() {
-        Credential credential = mCredentialFragment.makeCredentialFromFields();
+        Credential credential = mCredentialView.makeCredentialFromFields();
         Intent saveIntent = mApi.getSaveIntent(credential);
         if (saveIntent == null) {
             showSnackbar(R.string.no_available_save_providers);
             return;
         }
 
         startActivityForResult(saveIntent, RC_SAVE);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         if (requestCode != RC_SAVE) {
             showSnackbar(R.string.unknown_response);
             return;
         }
 
         if (resultCode == RESULT_OK) {
             showSnackbar(R.string.credential_saved);
             return;
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.credential_save_canceled);
         } else {
             showSnackbar(R.string.unknown_response);
         }
     }
 }
diff --git a/testapp/res/layout/authentication_method_input_layout.xml b/testapp/res/layout/authentication_method_input_layout.xml
new file mode 100644
index 0000000..02a93dd
--- /dev/null
+++ b/testapp/res/layout/authentication_method_input_layout.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+  android:orientation="vertical"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent">
+
+  <android.support.v7.widget.AppCompatCheckBox
+    android:id="@+id/facebook_authentication_method_checkbox"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:text="@string/facebook_authentication_method_checkbox_text"/>
+  <android.support.v7.widget.AppCompatCheckBox
+    android:id="@+id/google_authentication_method_checkbox"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:text="@string/google_authentication_method_checkbox_text"/>
+  <android.support.v7.widget.AppCompatCheckBox
+    android:id="@+id/id_and_password_authentication_method_checkbox"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:text="@string/id_and_password_authentication_method_checkbox_text"/>
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+    <android.support.v7.widget.AppCompatCheckBox
+      android:id="@+id/custom_authentication_method_checkbox"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_gravity="center_vertical"/>
+
+    <android.support.design.widget.TextInputEditText
+      android:id="@+id/custom_authentication_method"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:hint="@string/custom_authentication_method_hint"
+      android:inputType="textNoSuggestions|textVisiblePassword"/>
+  </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/credential_layout.xml b/testapp/res/layout/credential_layout.xml
index 4ce86ad..b361a2f 100644
--- a/testapp/res/layout/credential_layout.xml
+++ b/testapp/res/layout/credential_layout.xml
@@ -1,181 +1,180 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_marginTop="16dp"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/id_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/id_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/id_field_hint"
         android:inputType="textNoSuggestions|textVisiblePassword"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/generate_id_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_id_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/password_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/password_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/password_field_hint"
         android:inputType="textVisiblePassword"
         android:typeface="monospace"/>
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/generate_password_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_password_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/display_name_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/display_name_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/display_name_field_hint"
         android:inputType="textPersonName"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/generate_display_name_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_display_name_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/federation_provider_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/authentication_method_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/authentication_method_field_hint"
         android:inputType="textUri"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageButton
       android:id="@+id/openyolo_id_and_password_provider_button"
       style="@style/SideButton"
       android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
       app:srcCompat="@drawable/account_box_24dp"/>
 
     <ImageButton
       android:id="@+id/google_provider_button"
       style="@style/SideButton"
       android:contentDescription="@string/google_provider_button_content_description"
       app:srcCompat="@drawable/google_24dp"/>
 
     <ImageButton
       android:id="@+id/facebook_provider_button"
       style="@style/SideButton"
       android:contentDescription="@string/facebook_provider_button_content_description"
       app:srcCompat="@drawable/facebook_24dp"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
     <android.support.design.widget.TextInputLayout
       android:id="@+id/profile_picture_layout"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1">
 
       <android.support.design.widget.TextInputEditText
         android:id="@+id/profile_picture_field"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/profile_picture_field_hint"
         android:inputType="textUri"
         />
 
     </android.support.design.widget.TextInputLayout>
 
     <ImageView
       android:id="@+id/profile_picture_view"
       android:layout_width="48dp"
       android:layout_height="48dp"
       android:layout_gravity="center"
       android:contentDescription="@string/profile_picture_view_content_description"/>
 
     <ImageButton
       android:id="@+id/generate_profile_picture_button"
       style="@style/SideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/generate_profile_picture_button_content_description"
       app:srcCompat="@drawable/dice_24dp"/>
 
   </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/hint_test_layout.xml b/testapp/res/layout/hint_test_layout.xml
index 9342f58..953670f 100644
--- a/testapp/res/layout/hint_test_layout.xml
+++ b/testapp/res/layout/hint_test_layout.xml
@@ -1,89 +1,87 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/request"/>
 
     <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:orientation="horizontal">
 
       <android.support.design.widget.TextInputLayout
         android:id="@+id/id_layout"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="1">
 
         <android.support.design.widget.TextInputEditText
-          android:id="@+id/authentication_method"
+          android:id="@+id/authentication_method_text_input"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
-          android:hint="@string/authentication_method_hint"
-          android:inputType="textNoSuggestions|textVisiblePassword"
-          />
+          android:hint="@string/authentication_method_field_hint"
+          android:inputType="textNoSuggestions|textVisiblePassword"/>
       </android.support.design.widget.TextInputLayout>
 
       <ImageButton
         android:id="@+id/openyolo_id_and_password_provider_button"
         style="@style/SideButton"
         android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
         app:srcCompat="@drawable/account_box_24dp"/>
 
       <ImageButton
         android:id="@+id/google_provider_button"
         style="@style/SideButton"
         android:contentDescription="@string/google_provider_button_content_description"
         app:srcCompat="@drawable/google_24dp"/>
 
       <ImageButton
         android:id="@+id/facebook_provider_button"
         style="@style/SideButton"
         android:contentDescription="@string/facebook_provider_button_content_description"
         app:srcCompat="@drawable/facebook_24dp"/>
 
     </LinearLayout>
 
     <Button
       android:id="@+id/hint_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/hint_button_content_description"
       android:text="@string/hint_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/response"/>
 
-    <LinearLayout
+    <org.openyolo.testapp.CredentialView
       android:id="@+id/hint_credential"
       android:layout_width="match_parent"
-      android:layout_height="match_parent"
-      android:orientation="vertical">
-    </LinearLayout>
+      android:layout_height="match_parent">
+    </org.openyolo.testapp.CredentialView>
 
   </LinearLayout>
-</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
+</android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/retrieve_test_layout.xml b/testapp/res/layout/retrieve_test_layout.xml
index 81a267b..83575f6 100644
--- a/testapp/res/layout/retrieve_test_layout.xml
+++ b/testapp/res/layout/retrieve_test_layout.xml
@@ -1,90 +1,58 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/request"/>
 
-    <LinearLayout
-      android:layout_width="match_parent"
+    <TextView
+      android:layout_width="wrap_content"
       android:layout_height="wrap_content"
-      android:layout_marginTop="16dp"
-      android:orientation="horizontal">
-
-      <android.support.design.widget.TextInputLayout
-        android:id="@+id/id_layout"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_weight="1">
-
-        <android.support.design.widget.TextInputEditText
-          android:id="@+id/authentication_method"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:hint="@string/authentication_method_hint"
-          android:inputType="textNoSuggestions|textVisiblePassword"
-          />
-      </android.support.design.widget.TextInputLayout>
+      android:text="@string/authentication_method_section_title"/>
 
-      <ImageButton
-        android:id="@+id/openyolo_id_and_password_provider_button"
-        style="@style/SideButton"
-        android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
-        app:srcCompat="@drawable/account_box_24dp"/>
-
-      <ImageButton
-        android:id="@+id/google_provider_button"
-        style="@style/SideButton"
-        android:contentDescription="@string/google_provider_button_content_description"
-        app:srcCompat="@drawable/google_24dp"/>
-
-      <ImageButton
-        android:id="@+id/facebook_provider_button"
-        style="@style/SideButton"
-        android:contentDescription="@string/facebook_provider_button_content_description"
-        app:srcCompat="@drawable/facebook_24dp"/>
-
-
-    </LinearLayout>
+    <org.openyolo.testapp.AuthenticationMethodsInputView
+      android:id="@+id/authentication_methods_input"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content">
+    </org.openyolo.testapp.AuthenticationMethodsInputView>
 
     <Button
       android:id="@+id/retrieve_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/retrieve_button_content_description"
       android:text="@string/retrieve_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/response"/>
 
-    <LinearLayout
+    <org.openyolo.testapp.CredentialView
       android:id="@+id/retrieve_credential"
       android:layout_width="match_parent"
-      android:layout_height="match_parent"
-      android:orientation="vertical">
-    </LinearLayout>
+      android:layout_height="wrap_content">
+    </org.openyolo.testapp.CredentialView>
 
   </LinearLayout>
-</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
+</android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/layout/save_test_layout.xml b/testapp/res/layout/save_test_layout.xml
index 9680e1f..75783a0 100644
--- a/testapp/res/layout/save_test_layout.xml
+++ b/testapp/res/layout/save_test_layout.xml
@@ -1,42 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.NestedScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   style="@style/DemoContent">
 
   <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
     <TextView
       style="@style/Headline"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/request"/>
 
-    <LinearLayout
+    <org.openyolo.testapp.CredentialView
       android:id="@+id/save_credential"
       android:layout_width="match_parent"
-      android:layout_height="match_parent"
-      android:orientation="vertical">
-    </LinearLayout>
+      android:layout_height="match_parent">
+    </org.openyolo.testapp.CredentialView>
 
     <Button
       android:id="@+id/save_button"
       style="@style/Widget.AppCompat.Button.Colored"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginTop="16dp"
       android:layout_marginLeft="8dp"
       android:layout_marginRight="8dp"
       android:layout_gravity="center_horizontal"
       android:contentDescription="@string/save_button_content_description"
       android:text="@string/save_button_label"
       android:theme="@style/GreenButtonThemeOverlay"/>
 
   </LinearLayout>
-</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
+</android.support.v4.widget.NestedScrollView>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index 8394b8d..b549ac3 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,36 +1,56 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
+
+    <!-- Retrieve Test -->
     <string name="retrieve_button_label">Get Credential</string>
-    <string name="save_button_label">Save Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
+    <string name="no_credentials">No credentials available</string>
+    <string name="retrieve_cancelled">Credential retrieve cancelled</string>
+    <string name="custom_authentication_method_hint">Custom</string>
+    <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
+    <string name="authentication_method_section_title">Authentication Methods:</string>
+
+    <string name="facebook_authentication_method_checkbox_text">https://facebook.com</string>
+    <string name="google_authentication_method_checkbox_text">https://accounts.google.com</string>
+    <string name="id_and_password_authentication_method_checkbox_text">openyolo://id-and-password</string>
+
+    <!-- Save Test -->
+    <string name="save_button_label">Save Credential</string>
     <string name="save_button_content_description">Save a credential</string>
+
+    <string name="credential_saved">Credential saved</string>
+    <string name="credential_save_canceled">Credential save canceled</string>
+    <string name="no_available_save_providers">"No available providers can save this credential</string>
+
+    <!-- Hint Test -->
+    <string name="hint_button_label">Get Hint</string>
+    <string name="hint_button_content_description">Hint for new account creation</string>
+    <string name="hint_cancelled">Hint retrieve cancelled</string>
+
+    <!-- Credential -->
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
+    <string name="no_available_hint_providers">"No available hint providers</string>
+
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
+
+    <string name="display_name_field_hint">Display name</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
-    <string name="authentication_method_field_hint">Authentication Method</string>
+
     <string name="profile_picture_field_hint">Profile Picture URI</string>
+    <string name="profile_picture_view_content_description">Profile picture display</string>
+    <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
+
+    <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
-    <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
-    <string name="profile_picture_view_content_description">Profile picture display</string>
-    <string name="display_name_field_hint">Display name</string>
+    <string name="open_yolo_id_and_password_button_content_description">Set authentication method to Id and password</string>
+
+    <!-- Misc -->
     <string name="request_failed">OpenYOLO request failed</string>
-    <string name="no_credentials">No credentials available</string>
-    <string name="retrieve_cancelled">Credential retrieve cancelled</string>
-    <string name="hint_cancelled">Hint retrieve cancelled</string>
-    <string name="no_credential_returned">No credential returned</string>
-    <string name="hint_button_label">Get Hint</string>
-    <string name="hint_button_content_description">Hint for new account creation</string>
-    <string name="no_available_save_providers">"No available providers can save this credential</string>
-    <string name="no_available_hint_providers">"No available hint providers</string>
-    <string name="credential_saved">Credential saved</string>
-    <string name="credential_save_canceled">Credential save canceled</string>
     <string name="unknown_response">Unknown response</string>
     <string name="response">Response</string>
     <string name="request">Request</string>
-    <string name="authentication_method_hint">Authentication Method</string>
-    <string name="open_yolo_id_and_password_button_content_description">Set authentication method to Id and password</string>
-    <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
+    <string name="no_credential_returned">No credential returned</string>
 </resources>
diff --git a/testapp/res/values/styles.xml b/testapp/res/values/styles.xml
index 2f8a496..adefe83 100644
--- a/testapp/res/values/styles.xml
+++ b/testapp/res/values/styles.xml
@@ -1,30 +1,31 @@
 <resources>
     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
         <item name="colorAccent">@color/colorAccent</item>
     </style>
 
     <style name="AppTheme.NoActionBar">
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>
     </style>
 
     <style name="SideButton" parent="Widget.AppCompat.Button.Small">
         <item name="android:layout_width">wrap_content</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_gravity">center</item>
     </style>
 
     <style name="GreenButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
         <item name="colorAccent">@color/material_color_green_600</item>
     </style>
 
     <style name="Headline" parent="TextAppearance.AppCompat.Headline">
+        <item name="android:layout_marginBottom">16dp</item>
     </style>
 
     <style name="DemoContent">
         <item name="android:padding">16dp</item>
     </style>
 
 </resources>

commit e2d59deeeb36d67a129a3321dbdc392119382b02
Author: Shirley Gaw <shirley.gaw@dashlane.com>
Date:   Mon Mar 6 11:34:46 2017 +0100

    Add sgaw@ to CONTRIBUTORS

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index b239f62..a9d1e05 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -15 +15,2 @@ Stan Kocken <stan.kocken@dashlane.com>
 Stanojko Markovikj <stanojko.markovikj@dashlane.com>
+Shirley Gaw <shirley.gaw@gmail.com>

commit 8008322a6c995ef93018719b306f44b049ea8705
Author: Shirley Gaw <shirley.gaw@dashlane.com>
Date:   Thu Mar 2 10:42:26 2017 +0100

    [proguard] matchesSafely() uses reflection
    
    java.lang.Error: Cannot determine correct type for matchesSafely() method.
            at org.hamcrest.internal.ReflectiveTypeFinder.findExpectedType(ReflectiveTypeFinder.java:49)
            at org.hamcrest.TypeSafeDiagnosingMatcher.<init>(TypeSafeDiagnosingMatcher.java:42)
            at org.hamcrest.TypeSafeDiagnosingMatcher.<init>(TypeSafeDiagnosingMatcher.java:49)
            at org.hamcrest.core.Every.<init>(Every.java:11)
            at org.hamcrest.core.Every.everyItem(Every.java:45)
            at org.hamcrest.CoreMatchers.everyItem(CoreMatchers.java:196)
            at org.openyolo.api.RetrieveRequest$Builder.setAuthenticationDomains(RetrieveRequest.java:251)
            at org.openyolo.api.RetrieveRequest$Builder.<init>(RetrieveRequest.java:177)
            at org.openyolo.spi.BaseCredentialQueryReceiver.processQuery(BaseCredentialQueryReceiver.java:58)
            at com.google.bbq.BaseBroadcastQueryReceiver.onReceive(BaseBroadcastQueryReceiver.java:66)
            at android.app.ActivityThread.handleReceiver(ActivityThread.java:3011)
            at android.app.ActivityThread.-wrap18(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1544)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:154)
            at android.app.ActivityThread.main(ActivityThread.java:6077)
            at java.lang.reflect.Method.invoke(Method.java)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

diff --git a/api/proguard-rules.txt b/api/proguard-rules.txt
index 64b8fce..bdd2a5b 100644
--- a/api/proguard-rules.txt
+++ b/api/proguard-rules.txt
@@ -1,8 +1,11 @@
 # it is safe to ignore the resources ids from OpenYOLO api. Without this flag we have issue with picker_title, provider_list
 -dontwarn org.openyolo.api.R$id
 
 # valid4j use reflection to inject Providers and Policy
 -keep class org.valid4j.** { *; }
 
 # it is safe to ignore okio warnings
--dontwarn okio.**
\ No newline at end of file
+-dontwarn okio.**
+
+# Hamcrest reflection
+-keep class org.hamcrest.** { *; }
\ No newline at end of file

commit 7d59b0ef1b49b7bd27ca7d2604d159a45721bebb
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Wed Mar 1 17:44:32 2017 -0800

    Improvements to test app (#4)
    
    Each demo action (Get, Save, Hint) their own section to allow for more specialized request/response UIs for each.

diff --git a/testapp/java/org/openyolo/testapp/CredentialFragment.java b/testapp/java/org/openyolo/testapp/CredentialFragment.java
new file mode 100644
index 0000000..1ba6386
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/CredentialFragment.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.OnTextChanged;
+import com.bumptech.glide.Glide;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.api.Credential;
+import org.openyolo.api.PasswordSpecification;
+
+/**
+ * A reusable fragment that displays an OpenYolo credential.
+ */
+public final class CredentialFragment extends Fragment {
+
+    private static final String EXTRA_ENABLE_INPUT_GENERATION = "EXTRA_ENABLE_INPUT_GENERATION";
+    @BindView(R.id.generate_id_button)
+    ImageButton mGenerateIdButton;
+
+    @BindView(R.id.generate_password_button)
+    ImageButton mGeneratePasswordButton;
+
+    @BindView(R.id.openyolo_id_and_password_provider_button)
+    ImageButton mIdAndPasswordProviderButton;
+
+    @BindView(R.id.google_provider_button)
+    ImageButton mGenerateProviderButton;
+
+    @BindView(R.id.facebook_provider_button)
+    ImageButton mFacebookProviderButton;
+
+    @BindView(R.id.generate_display_name_button)
+    ImageButton mGenerateDisplayNameButton;
+
+    @BindView(R.id.generate_profile_picture_button)
+    ImageButton mGenerateProfilePictureButton;
+
+    @BindView(R.id.id_field)
+    EditText mIdField;
+
+    @BindView(R.id.password_field)
+    EditText mPasswordField;
+
+    @BindView(R.id.display_name_field)
+    EditText mDisplayNameField;
+
+    @BindView(R.id.authentication_method_field)
+    EditText mAuthenticationMethodField;
+
+    @BindView(R.id.profile_picture_field)
+    EditText mProfilePictureField;
+
+    @BindView(R.id.profile_picture_view)
+    ImageView mProfilePictureView;
+
+    private RandomData mRandomData;
+
+    /**
+     * Returns a new instance of a {@link CredentialFragment}.
+     */
+    public static CredentialFragment newInstance(boolean enableInputGeneration) {
+        Bundle args = new Bundle();
+        args.putBoolean(EXTRA_ENABLE_INPUT_GENERATION, enableInputGeneration);
+
+        CredentialFragment fragment = new CredentialFragment();
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mRandomData = new RandomData();
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+
+        View view = inflater.inflate(R.layout.credential_layout, container, false);
+        ButterKnife.bind(this, view);
+        setEnableInputGeneration(getArguments().getBoolean(EXTRA_ENABLE_INPUT_GENERATION));
+
+        return view;
+    }
+
+    /**
+     * Hides or shows input generation buttons.
+     */
+    private void setEnableInputGeneration(boolean isEnabled) {
+        int visibility = View.GONE;
+        if (isEnabled) {
+            visibility = View.VISIBLE;
+        }
+
+        mGenerateIdButton.setVisibility(visibility);
+        mGeneratePasswordButton.setVisibility(visibility);
+        mGenerateProviderButton.setVisibility(visibility);
+        mIdAndPasswordProviderButton.setVisibility(visibility);
+        mFacebookProviderButton.setVisibility(visibility);
+        mGenerateDisplayNameButton.setVisibility(visibility);
+        mGenerateProfilePictureButton.setVisibility(visibility);
+    }
+
+    @OnClick(R.id.generate_id_button)
+    void generateId() {
+        mIdField.setText(mRandomData.generateEmailAddress());
+    }
+
+    @OnClick(R.id.generate_password_button)
+    void generatePassword() {
+        mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
+    }
+
+    @OnClick(R.id.openyolo_id_and_password_provider_button)
+    void setIdAndPasswordAuthenticationMethod() {
+        mAuthenticationMethodField.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
+    }
+
+    @OnClick(R.id.google_provider_button)
+    void setGoogleAuthenticationMethod() {
+        mAuthenticationMethodField.setText(AuthenticationMethods.GOOGLE.toString());
+    }
+
+    @OnClick(R.id.facebook_provider_button)
+    void setFacebookAuthenticationMethod() {
+        mAuthenticationMethodField.setText(AuthenticationMethods.FACEBOOK.toString());
+    }
+
+    @OnClick(R.id.generate_display_name_button)
+    void generateDisplayName() {
+        mDisplayNameField.setText(mRandomData.generateDisplayName());
+    }
+
+    @OnClick(R.id.generate_profile_picture_button)
+    void generateProfilePicture() {
+        mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
+    }
+
+    @OnTextChanged(R.id.profile_picture_field)
+    void loadProfilePicture() {
+        Glide.with(this)
+                .load(Uri.parse(mProfilePictureField.getText().toString()))
+                .fitCenter()
+                .into(mProfilePictureView);
+    }
+
+    /**
+     * Clears all of the credential's fields.
+     */
+    public void clearFields() {
+        mIdField.setText("");
+        mPasswordField.setText("");
+        mDisplayNameField.setText("");
+        mAuthenticationMethodField.setText("");
+        mProfilePictureField.setText("");
+    }
+
+    /**
+     * Populates the fragment's fields from a given OpenYolo credential.
+     * @param credential an OpenYolo credential
+     */
+    public void setFieldsFromCredential(Credential credential) {
+        copyIfNotNull(credential.getIdentifier(), mIdField);
+        copyIfNotNull(credential.getPassword(), mPasswordField);
+        copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
+        copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
+        copyIfNotNull(credential.getAuthenticationMethod(), mAuthenticationMethodField);
+    }
+
+    /**
+     * Create an OpenYolo credential from the current fragment's fields.
+     * @return an OpenYolo Credential .
+     */
+    @Nullable
+    public Credential makeCredentialFromFields() {
+        String authenticationMethod = mAuthenticationMethodField.getText().toString();
+        Uri authMethodUri = Uri.parse(authenticationMethod);
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.getSelfAuthDomain(getContext());
+
+        Credential.Builder credentialBuilder = new Credential.Builder(
+                mIdField.getText().toString(),
+                authMethodUri,
+                authenticationDomain)
+                .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
+                .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
+
+        if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
+            credentialBuilder.setPassword(mPasswordField.getText().toString());
+        }
+
+        return credentialBuilder.build();
+    }
+
+    private static String convertEmptyToNull(@NonNull String str) {
+        if (str.isEmpty()) {
+            return null;
+        }
+
+        return str;
+    }
+
+    private static void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
+        if (value != null) {
+            field.setText(value.toString());
+        }
+    }
+
+}
diff --git a/testapp/java/org/openyolo/testapp/HintTestPageFragment.java b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
new file mode 100644
index 0000000..4caeffd
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/HintTestPageFragment.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import static android.app.Activity.RESULT_CANCELED;
+import static android.app.Activity.RESULT_OK;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.api.Credential;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.api.HintRequest;
+
+/**
+ * Fragment which contains a method of testing the OpenYolo credential hint flow.
+ */
+public final class HintTestPageFragment extends TestPageFragment {
+
+    private static final int RC_HINT = 0;
+
+    @BindView(R.id.authentication_method)
+    EditText mAuthenticationMethod;
+
+    private CredentialFragment mCredentialFragment;
+    private CredentialClient mApi;
+
+    public String getPageTitle() {
+        return "Hint";
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mApi = CredentialClient.getApplicationBoundInstance(getContext());
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.hint_test_layout, container, false);
+        ButterKnife.bind(this, view);
+
+        return view;
+    }
+
+    @Override
+    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+        FragmentManager fm = getChildFragmentManager();
+        mCredentialFragment = (CredentialFragment) fm.findFragmentById(R.id.hint_credential);
+        if (null == mCredentialFragment) {
+            FragmentTransaction fragmentTransaction = fm.beginTransaction();
+            mCredentialFragment = CredentialFragment.newInstance(false /* enableInputGeneration */);
+            fragmentTransaction.add(R.id.hint_credential, mCredentialFragment);
+            fragmentTransaction.commit();
+        }
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (requestCode != RC_HINT) {
+            showSnackbar(R.string.unknown_response);
+            return;
+        }
+
+        if (resultCode == RESULT_OK) {
+            Credential credential = mApi.getCredentialFromActivityResult(data);
+            if (credential == null) {
+                showSnackbar(R.string.no_credential_returned);
+            } else {
+                mCredentialFragment.setFieldsFromCredential(credential);
+            }
+        } else if (resultCode == RESULT_CANCELED) {
+            showSnackbar(R.string.hint_cancelled);
+        } else {
+            showSnackbar(R.string.unknown_response);
+        }
+    }
+
+    @OnClick(R.id.hint_button)
+    void onHint() {
+        mCredentialFragment.clearFields();
+
+        Uri authMethodUri = Uri.parse(mAuthenticationMethod.getText().toString());
+
+        HintRequest.Builder requestBuilder = new HintRequest.Builder(authMethodUri);
+
+        Intent hintIntent = mApi.getHintRetrieveIntent(requestBuilder.build());
+        if (hintIntent == null) {
+            showSnackbar(R.string.no_available_hint_providers);
+            return;
+        }
+
+        startActivityForResult(hintIntent, RC_HINT);
+    }
+
+    @OnClick(R.id.openyolo_id_and_password_provider_button)
+    void onIdAndPasswordAuthenticationMethod() {
+        mAuthenticationMethod.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
+    }
+
+    @OnClick(R.id.google_provider_button)
+    void onGoogleAuthenticationMethod() {
+        mAuthenticationMethod.setText(AuthenticationMethods.GOOGLE.toString());
+    }
+
+    @OnClick(R.id.facebook_provider_button)
+    void onFacebookAuthenticationMethod() {
+        mAuthenticationMethod.setText(AuthenticationMethods.FACEBOOK.toString());
+    }
+
+    private void showSnackbar(@StringRes int messageId) {
+        Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
+    }
+}
+
diff --git a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
index f19ea0e..3ec2c8d 100644
--- a/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
+++ b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
@@ -1,13 +1,13 @@
 /*
- * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the
  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing permissions and
  * limitations under the License.
  */
@@ -16,287 +16,64 @@ package org.openyolo.testapp;
 
-import android.content.Intent;
-import android.net.Uri;
 import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.StringRes;
-import android.support.design.widget.Snackbar;
+import android.support.design.widget.TabLayout;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
 import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.ImageView;
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-import butterknife.OnTextChanged;
-import com.bumptech.glide.Glide;
-import java.util.concurrent.atomic.AtomicReference;
-import org.openyolo.api.AuthenticationDomain;
-import org.openyolo.api.AuthenticationMethods;
-import org.openyolo.api.Credential;
-import org.openyolo.api.CredentialClient;
-import org.openyolo.api.HintRequest;
-import org.openyolo.api.PasswordSpecification;
-import org.openyolo.api.RetrieveCallback;
-import org.openyolo.api.RetrieveRequest;
-import org.openyolo.api.RetrieveResult;
+import android.support.v7.widget.Toolbar;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
- * Interacts with the OpenYOLO API to retrieve and save credentials.
+ * The main OpenYolo test activity.
  */
 public class OpenYoloTestActivity extends AppCompatActivity {
 
-    private static final String LOG_TAG = "OpenYoloTestActivity";
-    private static final int RC_RETRIEVE = 100;
-    private static final int RC_SAVE = 200;
-    private static final int RC_HINT = 300;
-
-    private CredentialClient mApi;
-    private RandomData mRandomData;
-
-    @BindView(android.R.id.content)
-    View mRootView;
-
-    @BindView(R.id.id_field)
-    EditText mIdField;
-
-    @BindView(R.id.password_field)
-    EditText mPasswordField;
-
-    @BindView(R.id.display_name_field)
-    EditText mDisplayNameField;
-
-    @BindView(R.id.federation_provider_field)
-    EditText mFederationProviderField;
-
-    @BindView(R.id.profile_picture_field)
-    EditText mProfilePictureField;
-
-    @BindView(R.id.profile_picture_view)
-    ImageView mProfilePictureView;
-
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        mApi = CredentialClient.getApplicationBoundInstance(this);
-        mRandomData = new RandomData();
-        setContentView(R.layout.main_layout);
-        ButterKnife.bind(this);
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
-        switch (requestCode) {
-            case RC_RETRIEVE:
-                handleRetrieveResult(resultCode, data);
-                break;
-            case RC_SAVE:
-                handleSaveResult(resultCode);
-                break;
-            case RC_HINT:
-                handleHintResult(resultCode, data);
-                break;
-            default:
-                showSnackbar(R.string.unknown_response);
-        }
-    }
 
-    private void handleRetrieveResult(int resultCode, Intent data) {
-        if (resultCode == RESULT_OK) {
-            Credential credential = mApi.getCredentialFromActivityResult(data);
-            if (credential == null) {
-                showSnackbar(R.string.no_credential_returned);
-            } else {
-                copyCredentialFields(credential);
-            }
-        } else if (resultCode == RESULT_CANCELED) {
-            showSnackbar(R.string.retrieve_cancelled);
-        }
-    }
-
-    private void handleSaveResult(int resultCode) {
-        if (resultCode == RESULT_OK) {
-            showSnackbar(R.string.credential_saved);
-        } else {
-            showSnackbar(R.string.credential_save_canceled);
-        }
-    }
+        setContentView(R.layout.main_layout);
 
-    private void handleHintResult(int resultCode, Intent data) {
-        if (resultCode == RESULT_OK) {
-            Credential credential = mApi.getCredentialFromActivityResult(data);
-            if (credential == null) {
-                showSnackbar(R.string.no_credential_returned);
-            } else {
-                copyCredentialFields(credential);
-            }
-        } else if (resultCode == RESULT_CANCELED) {
-            showSnackbar(R.string.hint_cancelled);
-        }
-    }
+        setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
 
-    private void copyCredentialFields(Credential credential) {
-        copyIfNotNull(credential.getIdentifier(), mIdField);
-        copyIfNotNull(credential.getPassword(), mPasswordField);
-        copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
-        copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
-        copyIfNotNull(credential.getAuthenticationMethod(), mFederationProviderField);
-    }
+        final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
+        DemoPagerAdapter demoPagerAdapter = new DemoPagerAdapter(getSupportFragmentManager());
+        demoPagerAdapter.addPage(new RetrieveTestPageFragment());
+        demoPagerAdapter.addPage(new SaveTestPageFragment());
+        demoPagerAdapter.addPage(new HintTestPageFragment());
 
-    @OnClick(R.id.retrieve_button)
-    void onRetrieve() {
-        clearData();
-        mApi.retrieve(RetrieveRequest.forSelf(this), new HandleRetrieveResult());
+        viewPager.setAdapter(demoPagerAdapter);
+        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
+        tabLayout.setupWithViewPager(viewPager);
     }
 
-    @OnClick(R.id.save_button)
-    void onSave() {
-        String authMethod = mFederationProviderField.getText().toString().trim();
-        Uri authMethodUri = authMethod.isEmpty()
-                ? AuthenticationMethods.ID_AND_PASSWORD
-                : Uri.parse(authMethod);
-
-        Credential.Builder credentialBuilder = new Credential.Builder(
-                mIdField.getText().toString(),
-                authMethodUri,
-                AuthenticationDomain.getSelfAuthDomain(this))
-                .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
-                .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
-
-        if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
-            credentialBuilder.setPassword(mPasswordField.getText().toString());
-        }
+    private static class DemoPagerAdapter extends FragmentPagerAdapter {
 
-        Credential credential = credentialBuilder.build();
+        private final List<TestPageFragment> mPages = new ArrayList<>();
 
-        Intent saveIntent = mApi.getSaveIntent(credential);
-        if (saveIntent == null) {
-            showSnackbar(R.string.no_available_save_providers);
-            return;
+        DemoPagerAdapter(FragmentManager fragmentManager) {
+            super(fragmentManager);
         }
 
-        startActivityForResult(saveIntent, RC_SAVE);
-    }
-
-    @OnClick(R.id.hint_button)
-    void onHint() {
-        Intent hintIntent = mApi.getHintRetrieveIntent(new HintRequest.Builder(
-                AuthenticationMethods.ID_AND_PASSWORD,
-                AuthenticationMethods.GOOGLE,
-                AuthenticationMethods.FACEBOOK)
-                .build());
-
-        if (hintIntent == null) {
-            showSnackbar(R.string.no_available_hint_providers);
-            return;
-        }
-
-        startActivityForResult(hintIntent, RC_HINT);
-    }
-
-    @OnClick(R.id.clear_button)
-    void clearDataClicked() {
-        clearData();
-        showSnackbar(R.string.cleared_fields);
-    }
-
-    private void clearData() {
-        mIdField.setText("");
-        mPasswordField.setText("");
-        mDisplayNameField.setText("");
-        mFederationProviderField.setText("");
-        mProfilePictureField.setText("");
-        mIdField.requestFocus();
-    }
-
-    @OnClick(R.id.generate_id_button)
-    void generateId() {
-        mIdField.setText(mRandomData.generateEmailAddress());
-    }
-
-    @OnClick(R.id.generate_password_button)
-    void generatePassword() {
-        mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
-    }
-
-    @OnClick(R.id.google_provider_button)
-    void setGoogleProvider() {
-        mFederationProviderField.setText(AuthenticationMethods.GOOGLE.toString());
-    }
-
-    @OnClick(R.id.facebook_provider_button)
-    void setFacebookProvider() {
-        mFederationProviderField.setText(AuthenticationMethods.FACEBOOK.toString());
-    }
-
-    @OnClick(R.id.generate_display_name_button)
-    void generateDisplayName() {
-        mDisplayNameField.setText(mRandomData.generateDisplayName());
-    }
-
-    @OnClick(R.id.generate_profile_picture_button)
-    void generateProfilePicture() {
-        mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
-    }
-
-    @OnTextChanged(R.id.profile_picture_field)
-    void loadProfilePicture() {
-        Glide.with(this)
-                .load(Uri.parse(mProfilePictureField.getText().toString()))
-                .fitCenter()
-                .into(mProfilePictureView);
-    }
-
-    private void showSnackbar(@StringRes int messageId) {
-        Snackbar.make(mRootView, messageId, Snackbar.LENGTH_SHORT).show();
-    }
-
-    private void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
-        if (value != null) {
-            field.setText(value.toString());
+        @Override
+        public int getCount() {
+            return mPages.size();
         }
-    }
 
-    private String convertEmptyToNull(@NonNull String str) {
-        if (str.isEmpty()) {
-            return null;
+        public void addPage(TestPageFragment pageFragment) {
+            mPages.add(pageFragment);
         }
 
-        return str;
-    }
-
-    private class HandleRetrieveResult implements RetrieveCallback, Runnable {
-
-        private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
-        private final AtomicReference<Throwable> mError = new AtomicReference<>();
-
         @Override
-        public void onComplete(RetrieveResult result, Throwable error) {
-            mResult.set(result);
-            mError.set(error);
-            runOnUiThread(this);
+        public Fragment getItem(int position) {
+            return mPages.get(position);
         }
 
         @Override
-        public void run() {
-            if (mError.get() != null) {
-                showSnackbar(R.string.request_failed);
-                Log.w(LOG_TAG, "OpenYOLO request failed", mError.get());
-                return;
-            }
-
-            RetrieveResult result = mResult.get();
-            if (result.getRetrieveIntent() == null) {
-                showSnackbar(R.string.no_credentials);
-                Log.i(LOG_TAG, "OpenYOLO retrieve result: No credentials available");
-                return;
-            }
-
-            Log.i(LOG_TAG, "OpenYOLO retrieve result: Credentials available");
-            startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
+        public CharSequence getPageTitle(int position) {
+            return mPages.get(position).getPageTitle();
         }
     }
 }
diff --git a/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
new file mode 100644
index 0000000..95a7c1d
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/RetrieveTestPageFragment.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import static android.app.Activity.RESULT_CANCELED;
+import static android.app.Activity.RESULT_OK;
+
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import java.util.concurrent.atomic.AtomicReference;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.api.Credential;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.api.RetrieveCallback;
+import org.openyolo.api.RetrieveRequest;
+import org.openyolo.api.RetrieveResult;
+
+/**
+ * Fragment which contains a method of testing the OpenYolo credential retrieve flow.
+ */
+public final class RetrieveTestPageFragment extends TestPageFragment {
+
+    private static final int RC_RETRIEVE = 0;
+
+    @BindView(R.id.authentication_method)
+    EditText mAuthenticationMethod;
+
+    private CredentialFragment mCredentialFragment;
+    private CredentialClient mApi;
+
+    public String getPageTitle() {
+        return "Retrieve";
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mApi = CredentialClient.getApplicationBoundInstance(getContext());
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.retrieve_test_layout, container, false);
+
+        ButterKnife.bind(this, view);
+
+        return view;
+    }
+
+    @Override
+    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+        FragmentManager fm = getChildFragmentManager();
+        mCredentialFragment = (CredentialFragment) fm.findFragmentById(R.id.retrieve_credential);
+        if (null == mCredentialFragment) {
+            FragmentTransaction fragmentTransaction = fm.beginTransaction();
+            mCredentialFragment = CredentialFragment.newInstance(false /* enableInputGeneration */);
+            fragmentTransaction.add(R.id.retrieve_credential, mCredentialFragment);
+            fragmentTransaction.commit();
+        }
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (requestCode != RC_RETRIEVE) {
+            showSnackbar(R.string.unknown_response);
+            return;
+        }
+
+        if (resultCode == RESULT_OK) {
+            Credential credential = mApi.getCredentialFromActivityResult(data);
+            if (credential == null) {
+                showSnackbar(R.string.no_credential_returned);
+            } else {
+                mCredentialFragment.setFieldsFromCredential(credential);
+            }
+        } else if (resultCode == RESULT_CANCELED) {
+            showSnackbar(R.string.retrieve_cancelled);
+        } else {
+            showSnackbar(R.string.unknown_response);
+        }
+    }
+
+    @OnClick(R.id.retrieve_button)
+    void onRetrieve() {
+        mCredentialFragment.clearFields();
+
+        Uri authenticationMethod = Uri.parse(mAuthenticationMethod.getText().toString());
+        AuthenticationDomain authenticationDomain =
+                AuthenticationDomain.getSelfAuthDomain(getContext());
+
+        RetrieveRequest request = new RetrieveRequest.Builder(authenticationDomain)
+                .setAuthenticationMethods(authenticationMethod)
+                .build();
+        mApi.retrieve(request, new HandleRetrieveResult());
+    }
+
+    @OnClick(R.id.openyolo_id_and_password_provider_button)
+    void onIdAndPasswordAuthenticationMethod() {
+        mAuthenticationMethod.setText(AuthenticationMethods.ID_AND_PASSWORD.toString());
+    }
+
+    @OnClick(R.id.google_provider_button)
+    void onGoogleAuthenticationMethod() {
+        mAuthenticationMethod.setText(AuthenticationMethods.GOOGLE.toString());
+    }
+
+    @OnClick(R.id.facebook_provider_button)
+    void onFacebookAuthenticationMethod() {
+        mAuthenticationMethod.setText(AuthenticationMethods.FACEBOOK.toString());
+    }
+
+    private void showSnackbar(@StringRes int messageId) {
+        Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
+    }
+
+    private class HandleRetrieveResult implements RetrieveCallback, Runnable {
+
+        private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
+        private final AtomicReference<Throwable> mError = new AtomicReference<>();
+
+        @Override
+        public void onComplete(RetrieveResult result, Throwable error) {
+            mResult.set(result);
+            mError.set(error);
+            getActivity().runOnUiThread(this);
+        }
+
+        @Override
+        public void run() {
+            if (mError.get() != null) {
+                showSnackbar(R.string.request_failed);
+                return;
+            }
+
+            RetrieveResult result = mResult.get();
+            if (result.getRetrieveIntent() == null) {
+                showSnackbar(R.string.no_credentials);
+                return;
+            }
+
+            try {
+                startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
+            } catch (ActivityNotFoundException ex) {
+                showSnackbar(R.string.credential_retrieve_activity_does_not_exist);
+            }
+        }
+    }
+}
+
diff --git a/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
new file mode 100644
index 0000000..675a95b
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/SaveTestPageFragment.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import static android.app.Activity.RESULT_CANCELED;
+import static android.app.Activity.RESULT_OK;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import org.openyolo.api.Credential;
+import org.openyolo.api.CredentialClient;
+
+/**
+ * Fragment which contains a method of testing the OpenYolo credential save flow.
+ */
+public class SaveTestPageFragment extends TestPageFragment {
+
+    private static final int RC_SAVE = 0;
+
+    private CredentialFragment mCredentialFragment;
+    private CredentialClient mApi;
+
+    public String getPageTitle() {
+        return "Save";
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mApi = CredentialClient.getApplicationBoundInstance(getActivity());
+    }
+
+    @Override
+    public View onCreateView(
+            LayoutInflater inflater,
+            ViewGroup container,
+            Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.save_test_layout, container, false);
+
+        ButterKnife.bind(this, view);
+
+        return view;
+    }
+
+    @Override
+    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+        FragmentManager fm = getChildFragmentManager();
+        mCredentialFragment = (CredentialFragment) fm.findFragmentById(R.id.save_credential);
+        if (null == mCredentialFragment) {
+            FragmentTransaction fragmentTransaction = fm.beginTransaction();
+            mCredentialFragment = CredentialFragment.newInstance(true /* enableInputGeneration */);
+            fragmentTransaction.add(R.id.save_credential, mCredentialFragment);
+            fragmentTransaction.commit();
+        }
+    }
+
+    @OnClick(R.id.save_button)
+    void onSave() {
+        Credential credential = mCredentialFragment.makeCredentialFromFields();
+        Intent saveIntent = mApi.getSaveIntent(credential);
+        if (saveIntent == null) {
+            showSnackbar(R.string.no_available_save_providers);
+            return;
+        }
+
+        startActivityForResult(saveIntent, RC_SAVE);
+    }
+
+    private void showSnackbar(@StringRes int messageId) {
+        Snackbar.make(getView().getRootView(), messageId, Snackbar.LENGTH_SHORT).show();
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (requestCode != RC_SAVE) {
+            showSnackbar(R.string.unknown_response);
+            return;
+        }
+
+        if (resultCode == RESULT_OK) {
+            showSnackbar(R.string.credential_saved);
+            return;
+        } else if (resultCode == RESULT_CANCELED) {
+            showSnackbar(R.string.credential_save_canceled);
+        } else {
+            showSnackbar(R.string.unknown_response);
+        }
+    }
+}
diff --git a/testapp/java/org/openyolo/testapp/TestPageFragment.java b/testapp/java/org/openyolo/testapp/TestPageFragment.java
new file mode 100644
index 0000000..2241749
--- /dev/null
+++ b/testapp/java/org/openyolo/testapp/TestPageFragment.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.testapp;
+
+import android.support.v4.app.Fragment;
+
+abstract class TestPageFragment extends Fragment {
+
+    public abstract String getPageTitle();
+}
diff --git a/testapp/res/drawable/account_box_24dp.xml b/testapp/res/drawable/account_box_24dp.xml
new file mode 100644
index 0000000..37af34b
--- /dev/null
+++ b/testapp/res/drawable/account_box_24dp.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+  android:width="24dp"
+  android:height="24dp"
+  android:viewportWidth="24"
+  android:viewportHeight="24">
+
+  <path
+    android:fillColor="#000000"
+    android:pathData="M3 5v14c0 1.1 .89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2
+2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3zm-9 8c0-2 4-3.1
+6-3.1s6 1.1 6 3.1v1H6v-1z" />
+  <path
+    android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/testapp/res/layout/credential_layout.xml b/testapp/res/layout/credential_layout.xml
new file mode 100644
index 0000000..4ce86ad
--- /dev/null
+++ b/testapp/res/layout/credential_layout.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent"
+  android:orientation="vertical">
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="16dp"
+    android:orientation="horizontal">
+
+    <android.support.design.widget.TextInputLayout
+      android:id="@+id/id_layout"
+      android:layout_width="0dp"
+      android:layout_height="wrap_content"
+      android:layout_weight="1">
+
+      <android.support.design.widget.TextInputEditText
+        android:id="@+id/id_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/id_field_hint"
+        android:inputType="textNoSuggestions|textVisiblePassword"
+        />
+
+    </android.support.design.widget.TextInputLayout>
+
+    <ImageButton
+      android:id="@+id/generate_id_button"
+      style="@style/SideButton"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:contentDescription="@string/generate_id_button_content_description"
+      app:srcCompat="@drawable/dice_24dp"/>
+
+  </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+    <android.support.design.widget.TextInputLayout
+      android:id="@+id/password_layout"
+      android:layout_width="0dp"
+      android:layout_height="wrap_content"
+      android:layout_weight="1">
+
+      <android.support.design.widget.TextInputEditText
+        android:id="@+id/password_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/password_field_hint"
+        android:inputType="textVisiblePassword"
+        android:typeface="monospace"/>
+
+    </android.support.design.widget.TextInputLayout>
+
+    <ImageButton
+      android:id="@+id/generate_password_button"
+      style="@style/SideButton"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:contentDescription="@string/generate_password_button_content_description"
+      app:srcCompat="@drawable/dice_24dp"/>
+
+  </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+    <android.support.design.widget.TextInputLayout
+      android:id="@+id/display_name_layout"
+      android:layout_width="0dp"
+      android:layout_height="wrap_content"
+      android:layout_weight="1">
+
+      <android.support.design.widget.TextInputEditText
+        android:id="@+id/display_name_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/display_name_field_hint"
+        android:inputType="textPersonName"
+        />
+
+    </android.support.design.widget.TextInputLayout>
+
+    <ImageButton
+      android:id="@+id/generate_display_name_button"
+      style="@style/SideButton"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:contentDescription="@string/generate_display_name_button_content_description"
+      app:srcCompat="@drawable/dice_24dp"/>
+
+  </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+    <android.support.design.widget.TextInputLayout
+      android:id="@+id/federation_provider_layout"
+      android:layout_width="0dp"
+      android:layout_height="wrap_content"
+      android:layout_weight="1">
+
+      <android.support.design.widget.TextInputEditText
+        android:id="@+id/authentication_method_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/authentication_method_field_hint"
+        android:inputType="textUri"
+        />
+
+    </android.support.design.widget.TextInputLayout>
+
+    <ImageButton
+      android:id="@+id/openyolo_id_and_password_provider_button"
+      style="@style/SideButton"
+      android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
+      app:srcCompat="@drawable/account_box_24dp"/>
+
+    <ImageButton
+      android:id="@+id/google_provider_button"
+      style="@style/SideButton"
+      android:contentDescription="@string/google_provider_button_content_description"
+      app:srcCompat="@drawable/google_24dp"/>
+
+    <ImageButton
+      android:id="@+id/facebook_provider_button"
+      style="@style/SideButton"
+      android:contentDescription="@string/facebook_provider_button_content_description"
+      app:srcCompat="@drawable/facebook_24dp"/>
+
+  </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+    <android.support.design.widget.TextInputLayout
+      android:id="@+id/profile_picture_layout"
+      android:layout_width="0dp"
+      android:layout_height="wrap_content"
+      android:layout_weight="1">
+
+      <android.support.design.widget.TextInputEditText
+        android:id="@+id/profile_picture_field"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/profile_picture_field_hint"
+        android:inputType="textUri"
+        />
+
+    </android.support.design.widget.TextInputLayout>
+
+    <ImageView
+      android:id="@+id/profile_picture_view"
+      android:layout_width="48dp"
+      android:layout_height="48dp"
+      android:layout_gravity="center"
+      android:contentDescription="@string/profile_picture_view_content_description"/>
+
+    <ImageButton
+      android:id="@+id/generate_profile_picture_button"
+      style="@style/SideButton"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:contentDescription="@string/generate_profile_picture_button_content_description"
+      app:srcCompat="@drawable/dice_24dp"/>
+
+  </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/hint_test_layout.xml b/testapp/res/layout/hint_test_layout.xml
new file mode 100644
index 0000000..9342f58
--- /dev/null
+++ b/testapp/res/layout/hint_test_layout.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.NestedScrollView
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent"
+  app:layout_behavior="@string/appbar_scrolling_view_behavior"
+  style="@style/DemoContent">
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <TextView
+      style="@style/Headline"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/request"/>
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="16dp"
+      android:orientation="horizontal">
+
+      <android.support.design.widget.TextInputLayout
+        android:id="@+id/id_layout"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1">
+
+        <android.support.design.widget.TextInputEditText
+          android:id="@+id/authentication_method"
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:hint="@string/authentication_method_hint"
+          android:inputType="textNoSuggestions|textVisiblePassword"
+          />
+      </android.support.design.widget.TextInputLayout>
+
+      <ImageButton
+        android:id="@+id/openyolo_id_and_password_provider_button"
+        style="@style/SideButton"
+        android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
+        app:srcCompat="@drawable/account_box_24dp"/>
+
+      <ImageButton
+        android:id="@+id/google_provider_button"
+        style="@style/SideButton"
+        android:contentDescription="@string/google_provider_button_content_description"
+        app:srcCompat="@drawable/google_24dp"/>
+
+      <ImageButton
+        android:id="@+id/facebook_provider_button"
+        style="@style/SideButton"
+        android:contentDescription="@string/facebook_provider_button_content_description"
+        app:srcCompat="@drawable/facebook_24dp"/>
+
+    </LinearLayout>
+
+    <Button
+      android:id="@+id/hint_button"
+      style="@style/Widget.AppCompat.Button.Colored"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="16dp"
+      android:layout_marginLeft="8dp"
+      android:layout_marginRight="8dp"
+      android:layout_gravity="center_horizontal"
+      android:contentDescription="@string/hint_button_content_description"
+      android:text="@string/hint_button_label"
+      android:theme="@style/GreenButtonThemeOverlay"/>
+
+    <TextView
+      style="@style/Headline"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/response"/>
+
+    <LinearLayout
+      android:id="@+id/hint_credential"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:orientation="vertical">
+    </LinearLayout>
+
+  </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
diff --git a/testapp/res/layout/main_layout.xml b/testapp/res/layout/main_layout.xml
index 58e0c68..beae6aa 100644
--- a/testapp/res/layout/main_layout.xml
+++ b/testapp/res/layout/main_layout.xml
@@ -1,255 +1,33 @@
-<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent">
 
-<android.support.design.widget.CoordinatorLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+  <android.support.design.widget.AppBarLayout
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <android.support.v4.widget.NestedScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:padding="16dp"
-            android:orientation="vertical">
-
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/main_header"
-                android:layout_gravity="center_horizontal"
-                style="@style/Base.TextAppearance.AppCompat.Headline" />
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="16dp"
-                android:orientation="horizontal">
-
-                <Button
-                    android:id="@+id/retrieve_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:layout_marginLeft="8dp"
-                    android:layout_marginRight="8dp"
-                    android:text="@string/retrieve_button_label"
-                    android:contentDescription="@string/retrieve_button_content_description"
-                    android:theme="@style/BlueButtonThemeOverlay"
-                    style="@style/Widget.AppCompat.Button.Colored" />
-
-                <Button
-                    android:id="@+id/save_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:layout_marginLeft="8dp"
-                    android:layout_marginRight="8dp"
-                    android:text="@string/save_button_label"
-                    android:contentDescription="@string/save_button_content_description"
-                    style="@style/Widget.AppCompat.Button.Colored"
-                    android:theme="@style/GreenButtonThemeOverlay"/>
-
-                <Button
-                    android:id="@+id/hint_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:layout_marginLeft="8dp"
-                    android:layout_marginRight="8dp"
-                    android:text="@string/hint_button_label"
-                    android:contentDescription="@string/hint_button_content_description"
-                    style="@style/Widget.AppCompat.Button.Colored"
-                    android:theme="@style/RedButtonThemeOverlay" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="16dp"
-                android:orientation="horizontal">
-
-                <android.support.design.widget.TextInputLayout
-                    android:id="@+id/id_layout"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1">
-
-                    <android.support.design.widget.TextInputEditText
-                        android:id="@+id/id_field"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:inputType="textNoSuggestions|textVisiblePassword"
-                        android:hint="@string/id_field_hint"
-                        />
-
-                </android.support.design.widget.TextInputLayout>
-
-                <ImageButton
-                    android:id="@+id/generate_id_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:contentDescription="@string/generate_id_button_content_description"
-                    app:srcCompat="@drawable/dice_24dp"
-                    style="@style/SideButton" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal">
-
-                <android.support.design.widget.TextInputLayout
-                    android:id="@+id/password_layout"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1">
-
-                    <android.support.design.widget.TextInputEditText
-                        android:id="@+id/password_field"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:inputType="textVisiblePassword"
-                        android:hint="@string/password_field_hint"
-                        android:typeface="monospace"/>
-
-                </android.support.design.widget.TextInputLayout>
-
-                <ImageButton
-                    android:id="@+id/generate_password_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:contentDescription="@string/generate_password_button_content_description"
-                    app:srcCompat="@drawable/dice_24dp"
-                    style="@style/SideButton" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal">
-
-                <android.support.design.widget.TextInputLayout
-                    android:id="@+id/display_name_layout"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1">
-
-                    <android.support.design.widget.TextInputEditText
-                        android:id="@+id/display_name_field"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:inputType="textPersonName"
-                        android:hint="@string/display_name_field_hint"
-                        />
-
-                </android.support.design.widget.TextInputLayout>
-
-                <ImageButton
-                    android:id="@+id/generate_display_name_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:contentDescription="@string/generate_display_name_button_content_description"
-                    app:srcCompat="@drawable/dice_24dp"
-                    style="@style/SideButton" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal">
-
-                <android.support.design.widget.TextInputLayout
-                    android:id="@+id/federation_provider_layout"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1">
-
-                    <android.support.design.widget.TextInputEditText
-                        android:id="@+id/federation_provider_field"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:inputType="textUri"
-                        android:hint="@string/federation_provider_field_hint"
-                        />
-
-                </android.support.design.widget.TextInputLayout>
-
-                <ImageButton
-                    android:id="@+id/google_provider_button"
-                    android:contentDescription="@string/google_provider_button_content_description"
-                    app:srcCompat="@drawable/google_24dp"
-                    style="@style/SideButton"/>
-
-                <ImageButton
-                    android:id="@+id/facebook_provider_button"
-                    android:contentDescription="@string/facebook_provider_button_content_description"
-                    app:srcCompat="@drawable/facebook_24dp"
-                    style="@style/SideButton"/>
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal">
-
-                <android.support.design.widget.TextInputLayout
-                    android:id="@+id/profile_picture_layout"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1">
-
-                    <android.support.design.widget.TextInputEditText
-                        android:id="@+id/profile_picture_field"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:inputType="textUri"
-                        android:hint="@string/profile_picture_field_hint"
-                        />
-
-                </android.support.design.widget.TextInputLayout>
-
-                <ImageView
-                    android:id="@+id/profile_picture_view"
-                    android:layout_width="48dp"
-                    android:layout_height="48dp"
-                    android:layout_gravity="center"
-                    android:contentDescription="@string/profile_picture_view_content_description"/>
-
-                <ImageButton
-                    android:id="@+id/generate_profile_picture_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:contentDescription="@string/generate_profile_picture_button_content_description"
-                    app:srcCompat="@drawable/dice_24dp"
-                    style="@style/SideButton" />
-
-            </LinearLayout>
-
-            <Button
-                android:id="@+id/clear_button"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="16dp"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="8dp"
-                android:layout_gravity="center_horizontal"
-                android:text="@string/clear_button_label"
-                android:contentDescription="@string/clear_button_content_description"
-                android:theme="@style/RedButtonThemeOverlay"
-                style="@style/Widget.AppCompat.Button.Colored"/>
-
-        </LinearLayout>
-
-    </android.support.v4.widget.NestedScrollView>
+    android:layout_height="wrap_content"
+    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+    <android.support.v7.widget.Toolbar
+      android:id="@+id/toolbar"
+      android:layout_width="match_parent"
+      android:layout_height="?attr/actionBarSize"
+      android:background="?attr/colorPrimary"
+      app:layout_scrollFlags="scroll|enterAlways"
+      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
+
+    <android.support.design.widget.TabLayout
+      android:id="@+id/tabs"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      app:tabGravity="fill"
+      app:tabMode="fixed"/>
+  </android.support.design.widget.AppBarLayout>
+
+  <android.support.v4.view.ViewPager
+    android:id="@+id/viewPager"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
+</android.support.design.widget.CoordinatorLayout>
 
-</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/testapp/res/layout/retrieve_test_layout.xml b/testapp/res/layout/retrieve_test_layout.xml
new file mode 100644
index 0000000..81a267b
--- /dev/null
+++ b/testapp/res/layout/retrieve_test_layout.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.NestedScrollView
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent"
+  app:layout_behavior="@string/appbar_scrolling_view_behavior"
+  style="@style/DemoContent">
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <TextView
+      style="@style/Headline"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/request"/>
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="16dp"
+      android:orientation="horizontal">
+
+      <android.support.design.widget.TextInputLayout
+        android:id="@+id/id_layout"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1">
+
+        <android.support.design.widget.TextInputEditText
+          android:id="@+id/authentication_method"
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:hint="@string/authentication_method_hint"
+          android:inputType="textNoSuggestions|textVisiblePassword"
+          />
+      </android.support.design.widget.TextInputLayout>
+
+      <ImageButton
+        android:id="@+id/openyolo_id_and_password_provider_button"
+        style="@style/SideButton"
+        android:contentDescription="@string/open_yolo_id_and_password_button_content_description"
+        app:srcCompat="@drawable/account_box_24dp"/>
+
+      <ImageButton
+        android:id="@+id/google_provider_button"
+        style="@style/SideButton"
+        android:contentDescription="@string/google_provider_button_content_description"
+        app:srcCompat="@drawable/google_24dp"/>
+
+      <ImageButton
+        android:id="@+id/facebook_provider_button"
+        style="@style/SideButton"
+        android:contentDescription="@string/facebook_provider_button_content_description"
+        app:srcCompat="@drawable/facebook_24dp"/>
+
+
+    </LinearLayout>
+
+    <Button
+      android:id="@+id/retrieve_button"
+      style="@style/Widget.AppCompat.Button.Colored"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="16dp"
+      android:layout_marginLeft="8dp"
+      android:layout_marginRight="8dp"
+      android:layout_gravity="center_horizontal"
+      android:contentDescription="@string/retrieve_button_content_description"
+      android:text="@string/retrieve_button_label"
+      android:theme="@style/GreenButtonThemeOverlay"/>
+
+    <TextView
+      style="@style/Headline"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/response"/>
+
+    <LinearLayout
+      android:id="@+id/retrieve_credential"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:orientation="vertical">
+    </LinearLayout>
+
+  </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
diff --git a/testapp/res/layout/save_test_layout.xml b/testapp/res/layout/save_test_layout.xml
new file mode 100644
index 0000000..9680e1f
--- /dev/null
+++ b/testapp/res/layout/save_test_layout.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.NestedScrollView
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent"
+  app:layout_behavior="@string/appbar_scrolling_view_behavior"
+  style="@style/DemoContent">
+
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <TextView
+      style="@style/Headline"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/request"/>
+
+    <LinearLayout
+      android:id="@+id/save_credential"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:orientation="vertical">
+    </LinearLayout>
+
+    <Button
+      android:id="@+id/save_button"
+      style="@style/Widget.AppCompat.Button.Colored"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="16dp"
+      android:layout_marginLeft="8dp"
+      android:layout_marginRight="8dp"
+      android:layout_gravity="center_horizontal"
+      android:contentDescription="@string/save_button_content_description"
+      android:text="@string/save_button_label"
+      android:theme="@style/GreenButtonThemeOverlay"/>
+
+  </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
diff --git a/testapp/res/values/colors.xml b/testapp/res/values/colors.xml
index 1e59826..a5c49da 100644
--- a/testapp/res/values/colors.xml
+++ b/testapp/res/values/colors.xml
@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <color name="colorPrimary">#1E88E5</color>
     <color name="colorPrimaryDark">#0288D1</color>
     <color name="colorAccent">#43A047</color>
 
     <color name="material_color_green_600">#43A047</color>
-    <color name="material_color_red_600">#e53935</color>
 </resources>
diff --git a/testapp/res/values/strings.xml b/testapp/res/values/strings.xml
index fe2d988..8394b8d 100644
--- a/testapp/res/values/strings.xml
+++ b/testapp/res/values/strings.xml
@@ -1,35 +1,36 @@
 <resources>
     <string name="app_name_short">OpenYOLO</string>
-    <string name="retrieve_button_label">Get</string>
-    <string name="save_button_label">Save</string>
-    <string name="clear_button_label">Clear fields</string>
+    <string name="retrieve_button_label">Get Credential</string>
+    <string name="save_button_label">Save Credential</string>
     <string name="retrieve_button_content_description">Retrieve a credential</string>
     <string name="save_button_content_description">Save a credential</string>
-    <string name="clear_button_content_description">Clear data entry fields</string>
     <string name="id_field_hint">Identifier</string>
     <string name="generate_id_button_content_description">Generate a random identifier</string>
     <string name="password_field_hint">Password</string>
     <string name="generate_password_button_content_description">Generate a random password</string>
     <string name="generate_display_name_button_content_description">Generate random display name</string>
-    <string name="federation_provider_field_hint">Federation provider</string>
+    <string name="authentication_method_field_hint">Authentication Method</string>
     <string name="profile_picture_field_hint">Profile Picture URI</string>
     <string name="google_provider_button_content_description">Set federation provider to Google</string>
     <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
     <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
     <string name="profile_picture_view_content_description">Profile picture display</string>
-    <string name="main_header">OpenYOLO demo</string>
     <string name="display_name_field_hint">Display name</string>
     <string name="request_failed">OpenYOLO request failed</string>
     <string name="no_credentials">No credentials available</string>
     <string name="retrieve_cancelled">Credential retrieve cancelled</string>
     <string name="hint_cancelled">Hint retrieve cancelled</string>
-    <string name="cleared_fields">Cleared fields</string>
     <string name="no_credential_returned">No credential returned</string>
-    <string name="hint_button_label">Hint</string>
+    <string name="hint_button_label">Get Hint</string>
     <string name="hint_button_content_description">Hint for new account creation</string>
     <string name="no_available_save_providers">"No available providers can save this credential</string>
     <string name="no_available_hint_providers">"No available hint providers</string>
     <string name="credential_saved">Credential saved</string>
     <string name="credential_save_canceled">Credential save canceled</string>
     <string name="unknown_response">Unknown response</string>
+    <string name="response">Response</string>
+    <string name="request">Request</string>
+    <string name="authentication_method_hint">Authentication Method</string>
+    <string name="open_yolo_id_and_password_button_content_description">Set authentication method to Id and password</string>
+    <string name="credential_retrieve_activity_does_not_exist">Credential retrieve activity does not exist</string>
 </resources>
diff --git a/testapp/res/values/styles.xml b/testapp/res/values/styles.xml
index e397cb3..2f8a496 100644
--- a/testapp/res/values/styles.xml
+++ b/testapp/res/values/styles.xml
@@ -1,30 +1,30 @@
 <resources>
     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
         <item name="colorAccent">@color/colorAccent</item>
     </style>
+
     <style name="AppTheme.NoActionBar">
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>
     </style>
 
     <style name="SideButton" parent="Widget.AppCompat.Button.Small">
         <item name="android:layout_width">wrap_content</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_gravity">center</item>
     </style>
 
-    <style name="BlueButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
-        <item name="colorAccent">@color/colorPrimary</item>
-    </style>
-
     <style name="GreenButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
         <item name="colorAccent">@color/material_color_green_600</item>
     </style>
 
-    <style name="RedButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
-        <item name="colorAccent">@color/material_color_red_600</item>
+    <style name="Headline" parent="TextAppearance.AppCompat.Headline">
+    </style>
+
+    <style name="DemoContent">
+        <item name="android:padding">16dp</item>
     </style>
 
 </resources>

commit 02fc6d136e4e92eab9f717fa7b6b6b4138482bbc
Author: David Samuelson <davidhlemon@gmail.com>
Date:   Tue Feb 21 18:43:13 2017 -0800

    Corrected outdated proto message names in documentation (#2)

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index b4359cd..b239f62 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -11,2 +11,3 @@
 David Larson <dlarson@keepersecurity.com>
+David Samuelson <samuelsond@google.com>
 Iain McGinniss <iainmcgin@google.com>
diff --git a/spec/en/retrieving-credentials.md b/spec/en/retrieving-credentials.md
index 456a5d7..2d60666 100644
--- a/spec/en/retrieving-credentials.md
+++ b/spec/en/retrieving-credentials.md
@@ -9,7 +9,7 @@ NOTE: writing this chapter is *in progress*.
 ```protobuf
-message FindRequest {
+message CredentialRetrieveRequest {
     repeated string       authDomains        = 1; // at least one required
     repeated string       authMethods        = 2; // at least one required
     repeated KeyValuePair additionalParams   = 3;
 }
 ```
@@ -29,6 +29,6 @@ request credentials outside its equivalence class.
 ```protobuf
-message FindResponse {
+message CredentialRetrieveResponse {
     optional bytes        retrieveIntent   = 1; // required
     repeated KeyValuePair additionalParams = 2;
 }
 ```

commit 9c410fbc538c1ee883dcbbc22b508904f432eae2
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Feb 13 17:58:29 2017 -0800

    Rename demoapp to testapp
    
    'demoapp' isn't representative of normal usage of the API, but
    rather is intended for manual testing of providers and their
    interactions.

diff --git a/settings.gradle b/settings.gradle
index 989fef4..bf89c77 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':bbq', ':api', ':spi', ':demoapp', ':demoproviders:barbican', ':demoproviders:trapdoor'
+include ':bbq', ':api', ':spi', ':testapp', ':demoproviders:barbican', ':demoproviders:trapdoor'
diff --git a/demoapp/AndroidManifest.xml b/testapp/AndroidManifest.xml
similarity index 93%
rename from demoapp/AndroidManifest.xml
rename to testapp/AndroidManifest.xml
index 8de414e..ed37bec 100644
--- a/demoapp/AndroidManifest.xml
+++ b/testapp/AndroidManifest.xml
@@ -1,35 +1,35 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="org.openyolo.demoapp" >
+        package="org.openyolo.testapp" >
 
     <uses-permission android:name="android.permission.INTERNET" />
 
     <application
             android:allowBackup="false"
             android:fullBackupContent="false"
             android:icon="@mipmap/ic_launcher"
             android:label="@string/app_name_short"
             android:theme="@style/AppTheme"
             android:supportsRtl="false" >
 
         <activity
-                android:name=".OpenYoloDemoActivity"
+                android:name=".OpenYoloTestActivity"
                 android:label="@string/app_name_short"
                 android:theme="@style/AppTheme.NoActionBar"
                 android:windowSoftInputMode="stateHidden"
                 android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:host="openyolo.demo-app.io"
                    android:scheme="https" />
             </intent-filter>
         </activity>
 
     </application>
 </manifest>
diff --git a/demoapp/build.gradle b/testapp/build.gradle
similarity index 90%
rename from demoapp/build.gradle
rename to testapp/build.gradle
index 79cab5d..3409028 100644
--- a/demoapp/build.gradle
+++ b/testapp/build.gradle
@@ -7,13 +7,13 @@ apply from:'../config/android-common.gradle'
 android {
     defaultConfig {
-        applicationId "org.openyolo.demoapp"
-        project.archivesBaseName = "openyolo-demoapp"
+        applicationId "org.openyolo.testapp"
+        project.archivesBaseName = "openyolo-testapp"
         vectorDrawables.useSupportLibrary = true
     }
     buildTypes {
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android.txt')
         }
     }
 }
diff --git a/demoapp/java/org/openyolo/demoapp/OpenYoloDemoActivity.java b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
similarity index 98%
rename from demoapp/java/org/openyolo/demoapp/OpenYoloDemoActivity.java
rename to testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
index 6c61504..f19ea0e 100644
--- a/demoapp/java/org/openyolo/demoapp/OpenYoloDemoActivity.java
+++ b/testapp/java/org/openyolo/testapp/OpenYoloTestActivity.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.demoapp;
+package org.openyolo.testapp;
 
@@ -45,258 +45,258 @@ import org.openyolo.api.RetrieveResult;
 /**
  * Interacts with the OpenYOLO API to retrieve and save credentials.
  */
-public class OpenYoloDemoActivity extends AppCompatActivity {
+public class OpenYoloTestActivity extends AppCompatActivity {
 
-    private static final String LOG_TAG = "OpenYoloDemoActivity";
+    private static final String LOG_TAG = "OpenYoloTestActivity";
     private static final int RC_RETRIEVE = 100;
     private static final int RC_SAVE = 200;
     private static final int RC_HINT = 300;
 
     private CredentialClient mApi;
     private RandomData mRandomData;
 
     @BindView(android.R.id.content)
     View mRootView;
 
     @BindView(R.id.id_field)
     EditText mIdField;
 
     @BindView(R.id.password_field)
     EditText mPasswordField;
 
     @BindView(R.id.display_name_field)
     EditText mDisplayNameField;
 
     @BindView(R.id.federation_provider_field)
     EditText mFederationProviderField;
 
     @BindView(R.id.profile_picture_field)
     EditText mProfilePictureField;
 
     @BindView(R.id.profile_picture_view)
     ImageView mProfilePictureView;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         mApi = CredentialClient.getApplicationBoundInstance(this);
         mRandomData = new RandomData();
         setContentView(R.layout.main_layout);
         ButterKnife.bind(this);
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
         switch (requestCode) {
             case RC_RETRIEVE:
                 handleRetrieveResult(resultCode, data);
                 break;
             case RC_SAVE:
                 handleSaveResult(resultCode);
                 break;
             case RC_HINT:
                 handleHintResult(resultCode, data);
                 break;
             default:
                 showSnackbar(R.string.unknown_response);
         }
     }
 
     private void handleRetrieveResult(int resultCode, Intent data) {
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 copyCredentialFields(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.retrieve_cancelled);
         }
     }
 
     private void handleSaveResult(int resultCode) {
         if (resultCode == RESULT_OK) {
             showSnackbar(R.string.credential_saved);
         } else {
             showSnackbar(R.string.credential_save_canceled);
         }
     }
 
     private void handleHintResult(int resultCode, Intent data) {
         if (resultCode == RESULT_OK) {
             Credential credential = mApi.getCredentialFromActivityResult(data);
             if (credential == null) {
                 showSnackbar(R.string.no_credential_returned);
             } else {
                 copyCredentialFields(credential);
             }
         } else if (resultCode == RESULT_CANCELED) {
             showSnackbar(R.string.hint_cancelled);
         }
     }
 
     private void copyCredentialFields(Credential credential) {
         copyIfNotNull(credential.getIdentifier(), mIdField);
         copyIfNotNull(credential.getPassword(), mPasswordField);
         copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
         copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
         copyIfNotNull(credential.getAuthenticationMethod(), mFederationProviderField);
     }
 
     @OnClick(R.id.retrieve_button)
     void onRetrieve() {
         clearData();
         mApi.retrieve(RetrieveRequest.forSelf(this), new HandleRetrieveResult());
     }
 
     @OnClick(R.id.save_button)
     void onSave() {
         String authMethod = mFederationProviderField.getText().toString().trim();
         Uri authMethodUri = authMethod.isEmpty()
                 ? AuthenticationMethods.ID_AND_PASSWORD
                 : Uri.parse(authMethod);
 
         Credential.Builder credentialBuilder = new Credential.Builder(
                 mIdField.getText().toString(),
                 authMethodUri,
                 AuthenticationDomain.getSelfAuthDomain(this))
                 .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
                 .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
 
         if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
             credentialBuilder.setPassword(mPasswordField.getText().toString());
         }
 
         Credential credential = credentialBuilder.build();
 
         Intent saveIntent = mApi.getSaveIntent(credential);
         if (saveIntent == null) {
             showSnackbar(R.string.no_available_save_providers);
             return;
         }
 
         startActivityForResult(saveIntent, RC_SAVE);
     }
 
     @OnClick(R.id.hint_button)
     void onHint() {
         Intent hintIntent = mApi.getHintRetrieveIntent(new HintRequest.Builder(
                 AuthenticationMethods.ID_AND_PASSWORD,
                 AuthenticationMethods.GOOGLE,
                 AuthenticationMethods.FACEBOOK)
                 .build());
 
         if (hintIntent == null) {
             showSnackbar(R.string.no_available_hint_providers);
             return;
         }
 
         startActivityForResult(hintIntent, RC_HINT);
     }
 
     @OnClick(R.id.clear_button)
     void clearDataClicked() {
         clearData();
         showSnackbar(R.string.cleared_fields);
     }
 
     private void clearData() {
         mIdField.setText("");
         mPasswordField.setText("");
         mDisplayNameField.setText("");
         mFederationProviderField.setText("");
         mProfilePictureField.setText("");
         mIdField.requestFocus();
     }
 
     @OnClick(R.id.generate_id_button)
     void generateId() {
         mIdField.setText(mRandomData.generateEmailAddress());
     }
 
     @OnClick(R.id.generate_password_button)
     void generatePassword() {
         mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
     }
 
     @OnClick(R.id.google_provider_button)
     void setGoogleProvider() {
         mFederationProviderField.setText(AuthenticationMethods.GOOGLE.toString());
     }
 
     @OnClick(R.id.facebook_provider_button)
     void setFacebookProvider() {
         mFederationProviderField.setText(AuthenticationMethods.FACEBOOK.toString());
     }
 
     @OnClick(R.id.generate_display_name_button)
     void generateDisplayName() {
         mDisplayNameField.setText(mRandomData.generateDisplayName());
     }
 
     @OnClick(R.id.generate_profile_picture_button)
     void generateProfilePicture() {
         mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
     }
 
     @OnTextChanged(R.id.profile_picture_field)
     void loadProfilePicture() {
         Glide.with(this)
                 .load(Uri.parse(mProfilePictureField.getText().toString()))
                 .fitCenter()
                 .into(mProfilePictureView);
     }
 
     private void showSnackbar(@StringRes int messageId) {
         Snackbar.make(mRootView, messageId, Snackbar.LENGTH_SHORT).show();
     }
 
     private void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
         if (value != null) {
             field.setText(value.toString());
         }
     }
 
     private String convertEmptyToNull(@NonNull String str) {
         if (str.isEmpty()) {
             return null;
         }
 
         return str;
     }
 
     private class HandleRetrieveResult implements RetrieveCallback, Runnable {
 
         private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
         private final AtomicReference<Throwable> mError = new AtomicReference<>();
 
         @Override
         public void onComplete(RetrieveResult result, Throwable error) {
             mResult.set(result);
             mError.set(error);
             runOnUiThread(this);
         }
 
         @Override
         public void run() {
             if (mError.get() != null) {
                 showSnackbar(R.string.request_failed);
                 Log.w(LOG_TAG, "OpenYOLO request failed", mError.get());
                 return;
             }
 
             RetrieveResult result = mResult.get();
             if (result.getRetrieveIntent() == null) {
                 showSnackbar(R.string.no_credentials);
                 Log.i(LOG_TAG, "OpenYOLO retrieve result: No credentials available");
                 return;
             }
 
             Log.i(LOG_TAG, "OpenYOLO retrieve result: Credentials available");
             startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
         }
     }
 }
diff --git a/demoapp/java/org/openyolo/demoapp/RandomData.java b/testapp/java/org/openyolo/testapp/RandomData.java
similarity index 99%
rename from demoapp/java/org/openyolo/demoapp/RandomData.java
rename to testapp/java/org/openyolo/testapp/RandomData.java
index 81daf36..0cf09c4 100644
--- a/demoapp/java/org/openyolo/demoapp/RandomData.java
+++ b/testapp/java/org/openyolo/testapp/RandomData.java
@@ -14,3 +14,3 @@
 
-package org.openyolo.demoapp;
+package org.openyolo.testapp;
 
diff --git a/demoapp/java/org/openyolo/demoapp/package-info.java b/testapp/java/org/openyolo/testapp/package-info.java
similarity index 95%
rename from demoapp/java/org/openyolo/demoapp/package-info.java
rename to testapp/java/org/openyolo/testapp/package-info.java
index 8bc6a81..456265a 100644
--- a/demoapp/java/org/openyolo/demoapp/package-info.java
+++ b/testapp/java/org/openyolo/testapp/package-info.java
@@ -15,4 +15,4 @@
 /**
  * Example usage of the OpenYOLO API to retrieve and save credentials.
  */
-package org.openyolo.demoapp;
+package org.openyolo.testapp;
diff --git a/demoapp/res/drawable/dice_24dp.xml b/testapp/res/drawable/dice_24dp.xml
similarity index 100%
rename from demoapp/res/drawable/dice_24dp.xml
rename to testapp/res/drawable/dice_24dp.xml
diff --git a/demoapp/res/drawable/facebook_24dp.xml b/testapp/res/drawable/facebook_24dp.xml
similarity index 100%
rename from demoapp/res/drawable/facebook_24dp.xml
rename to testapp/res/drawable/facebook_24dp.xml
diff --git a/demoapp/res/drawable/google_24dp.xml b/testapp/res/drawable/google_24dp.xml
similarity index 100%
rename from demoapp/res/drawable/google_24dp.xml
rename to testapp/res/drawable/google_24dp.xml
diff --git a/demoapp/res/layout/main_layout.xml b/testapp/res/layout/main_layout.xml
similarity index 100%
rename from demoapp/res/layout/main_layout.xml
rename to testapp/res/layout/main_layout.xml
diff --git a/demoapp/res/mipmap-hdpi/ic_launcher.png b/testapp/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from demoapp/res/mipmap-hdpi/ic_launcher.png
rename to testapp/res/mipmap-hdpi/ic_launcher.png
diff --git a/demoapp/res/mipmap-mdpi/ic_launcher.png b/testapp/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from demoapp/res/mipmap-mdpi/ic_launcher.png
rename to testapp/res/mipmap-mdpi/ic_launcher.png
diff --git a/demoapp/res/mipmap-xhdpi/ic_launcher.png b/testapp/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from demoapp/res/mipmap-xhdpi/ic_launcher.png
rename to testapp/res/mipmap-xhdpi/ic_launcher.png
diff --git a/demoapp/res/mipmap-xxhdpi/ic_launcher.png b/testapp/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from demoapp/res/mipmap-xxhdpi/ic_launcher.png
rename to testapp/res/mipmap-xxhdpi/ic_launcher.png
diff --git a/demoapp/res/mipmap-xxxhdpi/ic_launcher.png b/testapp/res/mipmap-xxxhdpi/ic_launcher.png
similarity index 100%
rename from demoapp/res/mipmap-xxxhdpi/ic_launcher.png
rename to testapp/res/mipmap-xxxhdpi/ic_launcher.png
diff --git a/demoapp/res/values/colors.xml b/testapp/res/values/colors.xml
similarity index 100%
rename from demoapp/res/values/colors.xml
rename to testapp/res/values/colors.xml
diff --git a/demoapp/res/values/strings.xml b/testapp/res/values/strings.xml
similarity index 100%
rename from demoapp/res/values/strings.xml
rename to testapp/res/values/strings.xml
diff --git a/demoapp/res/values/styles.xml b/testapp/res/values/styles.xml
similarity index 100%
rename from demoapp/res/values/styles.xml
rename to testapp/res/values/styles.xml

commit d4a793d2a53bf3bcbcfd8630160f29583d167e5e
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Feb 13 17:36:56 2017 -0800

    Add build status and coverage badges

diff --git a/README.md b/README.md
index 98ecd80..b46bd2c 100644
--- a/README.md
+++ b/README.md
@@ -2,2 +2,5 @@
 
+[![Build Status](https://www.bitrise.io/app/e7b1a2bcce9d787c.svg?token=kvggLFAJ-Tx48g6I671NSg)](https://www.bitrise.io/app/e7b1a2bcce9d787c)
+[![codecov](https://codecov.io/gh/openid/OpenYOLO-Android/branch/master/graph/badge.svg)](https://codecov.io/gh/openid/OpenYOLO-Android)
+
 OpenYOLO for Android is a protocol for storing, updating and assisting in the 

commit eeca9887089aca1c215efbfcefe1c6a1dd5dda50
Author: Iain McGinniss <iainmcgin@google.com>
Date:   Mon Feb 13 14:15:07 2017 -0800

    Initial contribution of the OpenYOLO specification and sources
    from Google, with thanks to the following contributors
    and reviewers:
    
    - AgileBits
        - Michael Verde
    - Dashlane
        - Frederic Rivain
        - Stan Kocken
        - Stanojko Markovikj
    - Google
        - Iain McGinniss
        - Lee Denison
        - Rahul Ravikumar
    - Keeper Security
        - Craig Lurey
        - David Larson
        - Darren Phillips
    - LastPass
        - Anatoly Iyasyuk
    - Roboform
        - Simon Davies
        - Vadim Maslov

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d6dbe4e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+*.keystore
+.gradle
+build
+.idea
+*.iml
+gradle.properties
+local.properties
+node-modules
+java_gen
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..13565a3
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,12 @@
+# This is the official list of authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+# Names should be added to this file as:
+# Name or Organization <email address>
+# The email address is not required for organizations.
+#
+# This list is maintained in lexicographic order.
+
+Dashlane, Inc.
+Google, Inc.
+Keeper Security, Inc.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..e062a84
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,58 @@
+# Contributing to OpenYOLO for Android
+
+All contributions to OpenYOLO for Android are welcome!
+
+Note that as this library is planned to be used in high-profile production code,
+we insist on a very high standards for the code and design, but don't feel shy:
+discuss your plans over
+[GitHub Issues](https://github.com/openid/OpenYOLO-Android/issues) and the
+[mailing list](http://groups.google.com/group/oidf-account-chooser-list), and
+send in pull requests!
+
+# Signing the Agreements
+
+In order to contribute to this project, you need to execute two legal agreements
+that cover your contributions.  Pull requests from users who have not signed
+these agreements will not be merged.
+
+## Execute the Contributor License Agreement (CLA)
+
+1. Visit http://openid.net/contribution-license-agreement/
+2. Tap *Execute OpenID Foundation Contribution License Agreement* for the
+   version relevant to you (Individual or Corporate).
+3. Follow the instructions to sign the agreement.
+
+## Execute the Working Group Contribution Agreement
+
+In addition to the Code License Agreement, the OpenID Foundation also requires
+a working group contribution agreement to cover any contributions you may make
+towards the OpenID Connect spec itself (e.g. in comments, bug reports, feature
+requests).
+
+1. Visit http://openid.net/intellectual-property/
+2. Tap *Execute Contributor Agreement By Electronic Signature* in the box
+   marked *Resources*.
+3. Follow the instructions to sign the document, state 'Account Chooser &
+   OpenYOLO' as the Initial Working Group.
+
+# Making a Pull Request
+
+## Before you Start
+
+Before you work on a big new feature, get in touch to make sure that your work
+is inline with the direction of the project and get input on your architecture.
+You can file an [Issue](https://github.com/openid/OpenYOLO-Android/issues)
+discussing your proposal, or email the
+[list](http://groups.google.com/group/oidf-account-chooser-list).
+
+## Coding Standards
+
+The OpenYOLO Android library follows the
+[Google Coding Style](https://google.github.io/styleguide/javaguide.html) for
+the Java language. Please review your own code for adherence to the standard
+and make sure to run the `check` gradle target.
+
+## Pull Request Reviews
+
+All pull requests, even by members who have repository write access need to be
+reviewed and marked as "LGTM" before they will be merged.
\ No newline at end of file
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
new file mode 100644
index 0000000..b4359cd
--- /dev/null
+++ b/CONTRIBUTORS
@@ -0,0 +1,14 @@
+# People who have agreed to one of the CLAs and can contribute patches.
+# The AUTHORS file lists the copyright holders; this file
+# lists people. For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+# Names should be added to this file as:
+#     Name <email address>
+#
+# This list is maintained in the lexicographic order of the author's full name.
+
+David Larson <dlarson@keepersecurity.com>
+Iain McGinniss <iainmcgin@google.com>
+Stan Kocken <stan.kocken@dashlane.com>
+Stanojko Markovikj <stanojko.markovikj@dashlane.com>
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d9a10c0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,176 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..98ecd80
--- /dev/null
+++ b/README.md
@@ -0,0 +1,24 @@
+# OpenYOLO for Android
+
+OpenYOLO for Android is a protocol for storing, updating and assisting in the 
+creation of user credentials apps. It can be used to assist in the sign-in 
+and sign-up process for Android apps, and queries can be responded to by 
+any installed credential provider on the device.
+
+This repository contains the
+[OpenYOLO Specification](https://github.com/openid/OpenYOLO-Android/tree/master/spec/en) and
+reference implementation.
+
+OpenYOLO is inspired by, and ultimately intended to replace, Google's
+[Smart Lock for Passwords][yolo] API, which is
+internally known as YOLO (You Only Login Once).
+
+## OpenYOLO is *not* production ready
+
+OpenYOLO is currently in the *experimental* stage; both the specification and
+reference implementation are *unstable*. We do not recommend that it be used
+in production Android apps. At such a time that OpenYOLO is considered stable
+and ready for production use, an official announcement shall be made and both
+the specification and reference implementation will be promoted to v1.0.0.
+
+[yolo]: https://developers.google.com/identity/smartlock-passwords/android/
diff --git a/api/AndroidManifest.xml b/api/AndroidManifest.xml
new file mode 100644
index 0000000..8c8fd2c
--- /dev/null
+++ b/api/AndroidManifest.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.openyolo.api">
+
+    <application>
+        <activity android:name=".ui.ProviderPickerActivity"
+            android:theme="@style/PickerTheme"
+            android:exported="false" />
+    </application>
+</manifest>
diff --git a/api/build.gradle b/api/build.gradle
new file mode 100644
index 0000000..5acfc7b
--- /dev/null
+++ b/api/build.gradle
@@ -0,0 +1,26 @@
+apply plugin: 'com.android.library'
+
+apply from:'../config/android-common.gradle'
+apply from:'../config/wire-proto.gradle'
+
+android {
+    defaultConfig {
+        vectorDrawables.useSupportLibrary = true
+        consumerProguardFiles 'proguard-rules.txt'
+        project.archivesBaseName = 'openyolo-api'
+    }
+}
+
+dependencies {
+    compile project(":bbq")
+    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    compile "org.hamcrest:hamcrest-core:1.3"
+    compile "org.valid4j:valid4j:0.5.0"
+    apply from:'../config/testdeps.gradle', to:it
+}
+
+apply from: '../config/style.gradle'
+apply from: '../config/coverage.gradle'
+apply from: '../config/javadoc.gradle'
diff --git a/api/java/org/openyolo/api/AuthenticationDomain.java b/api/java/org/openyolo/api/AuthenticationDomain.java
new file mode 100644
index 0000000..55ba5bb
--- /dev/null
+++ b/api/java/org/openyolo/api/AuthenticationDomain.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationDomain;
+import static org.valid4j.Assertive.require;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.util.Base64;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.openyolo.api.internal.ValueConverter;
+
+
+/**
+ * A URI-based representation of an authentication domain, which determines the scope within which
+ * a credential is valid. An authentication domain may have multiple equivalent representations,
+ * such as when apps and sites share the same authentication system. The responsibility for
+ * determining whether two given authentication domains are equivalent lies with the credential
+ * provider.
+ *
+ * <p>Two broad classes of authentication domain are defined in the OpenYOLO
+ * specification : Android authentication domains, of form
+ * {@code android://<signature>@<packageName>}, and Web authentication domains, of form
+ * {@code http(s)://host@port}. Formally, authentication domains are absolute hierarchical URIs
+ * with no path, query or fragment. They must therefore always be of form
+ * {@code scheme://authority}.
+ */
+@SuppressLint("PackageManagerGetSignatures")
+public final class AuthenticationDomain implements Comparable<AuthenticationDomain> {
+
+    static final ValueConverter<String, AuthenticationDomain> CONVERTER_STRING_TO_DOMAIN =
+            new StringToAuthenticationDomainConverter();
+
+    static final ValueConverter<AuthenticationDomain, String> CONVERTER_DOMAIN_TO_STRING =
+            new AuthenticationDomainToStringConverter();
+
+    private static final String DIGEST_SHA_512 = "SHA-512";
+    private static final String SCHEME_ANDROID = "android";
+    private static final String SCHEME_HTTP = "http";
+    private static final String SCHEME_HTTPS = "https";
+
+    private final Uri mUri;
+
+    /**
+     * Creates an authentication domain that represents the current package, as identified
+     * by the provided context's {@link Context#getPackageName() getPackageName} method.
+     */
+    @NonNull
+    public static AuthenticationDomain getSelfAuthDomain(@NonNull Context context) {
+        require(context, notNullValue());
+
+        PackageManager pm = context.getPackageManager();
+        String packageName = context.getPackageName();
+        PackageInfo packageInfo;
+        try {
+            packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
+        } catch (PackageManager.NameNotFoundException e) {
+            throw new IllegalStateException("Unable to find package info for " + packageName);
+        }
+
+        return createAndroidAuthDomain(packageName, packageInfo.signatures[0]);
+    }
+
+    /**
+     * Creates the list of all authentication domains that represent the specified package.
+     * The list will contain a distinct entry for every signature related to the application.
+     */
+    @NonNull
+    public static List<AuthenticationDomain> listForPackage(
+            @NonNull Context context,
+            @Nullable String packageName) {
+        require(context, notNullValue());
+
+        PackageManager pm = context.getPackageManager();
+        PackageInfo packageInfo;
+        if (TextUtils.isEmpty(packageName)) {
+            return Collections.emptyList();
+        }
+        try {
+            packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
+        } catch (PackageManager.NameNotFoundException e) {
+            return Collections.emptyList();
+        }
+
+        ArrayList<AuthenticationDomain> authDomains =
+                new ArrayList<>(packageInfo.signatures.length);
+        for (Signature signature : packageInfo.signatures) {
+            authDomains.add(createAndroidAuthDomain(packageName, signature));
+        }
+
+        return authDomains;
+    }
+
+    /**
+     * Creates an Android authentication domain (of form {@code android://SIGNATURE@PACKAGE}),
+     * given the provided package name and signature.
+     */
+    @NonNull
+    public static AuthenticationDomain createAndroidAuthDomain(
+            @NonNull String packageName,
+            @NonNull Signature signature) {
+        require(!TextUtils.isEmpty(packageName), "packageName must not be null or empty");
+        require(signature, notNullValue());
+
+        return new AuthenticationDomain(
+                new Uri.Builder()
+                        .scheme(SCHEME_ANDROID)
+                        .encodedAuthority(generateSignatureHash(signature) + "@" + packageName)
+                        .build());
+    }
+
+    @NonNull
+    static String generateSignatureHash(@NonNull Signature signature) {
+        try {
+            MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_512);
+            byte[] hashBytes = digest.digest(signature.toByteArray());
+            return Base64.encodeToString(hashBytes, Base64.URL_SAFE).replace("\n", "");
+        } catch (NoSuchAlgorithmException e) {
+            throw new IllegalStateException(
+                    "Platform does not support" + DIGEST_SHA_512 + " hashing");
+        }
+    }
+
+    /**
+     * Creates an authentication domain from the provided String representation. If the string
+     * provided is not a valid authentication domain, an {@link IllegalArgumentException}
+     * will be thrown.
+     */
+    public AuthenticationDomain(@NonNull String authDomainString) {
+        mUri = require(Uri.parse(authDomainString), isValidAuthenticationDomain());
+    }
+
+    private AuthenticationDomain(@NonNull Uri authDomainUri) {
+        mUri = authDomainUri;
+    }
+
+    /**
+     * Determines whether the authentication domain refers to an Android application.
+     */
+    public boolean isAndroidAuthDomain() {
+        return SCHEME_ANDROID.equals(mUri.getScheme());
+    }
+
+    /**
+     * Determines whether the authentication domain refers to a Web domain.
+     */
+    public boolean isWebAuthDomain() {
+        return SCHEME_HTTP.equals(mUri.getScheme())
+                || SCHEME_HTTPS.equals(mUri.getScheme());
+    }
+
+    /**
+     * Retrieves the Android package name from the authentication domain. If the authentication
+     * domain does not represent an Android application, an {@link IllegalStateException} will
+     * be thrown.
+     */
+    @NonNull
+    public String getAndroidPackageName() {
+        if (!isAndroidAuthDomain()) {
+            throw new IllegalStateException("Authentication domain is not an Android domain");
+        }
+        return mUri.getHost();
+    }
+
+    /**
+     * Retrieves the URI form of the authentication domain.
+     */
+    @NonNull
+    public Uri getUri() {
+        return mUri;
+    }
+
+    /**
+     * Retrieves the string form of the authentication domain.
+     */
+    @NonNull
+    public String toString() {
+        return mUri.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (!(obj instanceof AuthenticationDomain)) {
+            return false;
+        }
+
+        AuthenticationDomain other = (AuthenticationDomain) obj;
+
+        return mUri.equals(other.getUri());
+    }
+
+    @Override
+    public int hashCode() {
+        return mUri.hashCode();
+    }
+
+    @Override
+    public int compareTo(@NonNull AuthenticationDomain authenticationDomain) {
+        return mUri.compareTo(authenticationDomain.getUri());
+    }
+
+    static class AuthenticationDomainToStringConverter
+            implements ValueConverter<AuthenticationDomain, String> {
+        @Override
+        public String convert(AuthenticationDomain value) {
+            return value.toString();
+        }
+    }
+
+    static class StringToAuthenticationDomainConverter
+            implements ValueConverter<String, AuthenticationDomain> {
+        @Override
+        public AuthenticationDomain convert(String value) {
+            return new AuthenticationDomain(value);
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/AuthenticationMethods.java b/api/java/org/openyolo/api/AuthenticationMethods.java
new file mode 100644
index 0000000..fdf020e
--- /dev/null
+++ b/api/java/org/openyolo/api/AuthenticationMethods.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import android.net.Uri;
+
+/**
+ * A set of well-known authentication method URIs for use with
+ * {@link org.openyolo.api.Credential.Builder#setAuthenticationMethod(String)}.
+ */
+public final class AuthenticationMethods {
+
+    /**
+     * Identifier and password based authentication.
+     */
+    public static final Uri ID_AND_PASSWORD = Uri.parse("openyolo://id-and-password");
+
+    /**
+     * Google Sign-in authentication.
+     *
+     * @see <a href="https://developers.google.com/identity/sign-in/android/">Google Sign-in for
+     *     Android</a>.
+     */
+    public static final Uri GOOGLE = Uri.parse("https://accounts.google.com");
+
+    /**
+     * Facebook Login authentication.
+     *
+     * @see <a href="https://developers.facebook.com/docs/facebook-login/android">Facebook Login
+     *     for Android</a>.
+     */
+    public static final Uri FACEBOOK = Uri.parse("https://www.facebook.com");
+
+    /**
+     * LinkedIn OAuth2 authentication.
+     *
+     * @see <a href="https://developer.linkedin.com/docs/oauth2">"Authenticating with OAuth2"</a>
+     * @see <a href="https://developer.linkedin.com/docs/android-sdk-auth">Authenticating with
+     *     the Mobile SDK for Android</a>
+     */
+    public static final Uri LINKEDIN = Uri.parse("https://www.linkedin.com");
+
+    /**
+     * Microsoft OpenID Connect authentication.
+     */
+    public static final Uri MICROSOFT = Uri.parse("https://login.live.com");
+
+    /**
+     * Paypal OpenID Connect authentication.
+     *
+     * @see <a href="https://developer.paypal.com/docs/integration/direct/identity/log-in-with-paypal/">
+     *     Integrate login with Paypal</a>
+     */
+    public static final Uri PAYPAL = Uri.parse("https://www.paypal.com");
+
+    /**
+     * Yahoo OAuth2 authentication.
+     *
+     * @see <a href="https://developer.yahoo.com/oauth2/guide/">Yahoo OAuth 2.0 Guide</a>
+     */
+    public static final Uri YAHOO = Uri.parse("https://login.yahoo.com");
+}
diff --git a/api/java/org/openyolo/api/Credential.java b/api/java/org/openyolo/api/Credential.java
new file mode 100644
index 0000000..5292d02
--- /dev/null
+++ b/api/java/org/openyolo/api/Credential.java
@@ -0,0 +1,352 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.api.internal.CustomMatchers.isWebUri;
+import static org.openyolo.api.internal.CustomMatchers.nullOr;
+import static org.valid4j.Assertive.require;
+
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.openyolo.api.internal.CollectionConverter;
+import org.openyolo.api.internal.KeyValuePairConverters;
+import org.openyolo.proto.KeyValuePair;
+
+/**
+ * A representation of a credential for use in sign-in or sign-up. This provides a
+ * higher-level, data-verifying wrapper for the underlying {@link org.openyolo.proto.Credential
+ * protocol buffer} that is returned by the app.
+ *
+ * <p>Credentials must have an {@link #getIdentifier() identifier},
+ * an {@link #getAuthenticationMethod() authentication method} and an
+ * {@link #getAuthenticationDomain() authentication domain}, but all other properties are optional.
+ */
+public final class Credential implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link Credential} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<Credential> CREATOR = new CredentialCreator();
+
+    @NonNull
+    private final org.openyolo.proto.Credential mProto;
+
+    /**
+     * Deserializes and validates a credential protocol buffer.
+     * @throws IOException if the credential is invalid.
+     */
+    public static Credential fromProtoBytes(byte[] credentialProtoBytes) throws IOException {
+        return new Credential.Builder(
+                org.openyolo.proto.Credential.ADAPTER.decode(credentialProtoBytes))
+                .build();
+    }
+
+    private Credential(@NonNull org.openyolo.proto.Credential proto) {
+        mProto = proto;
+    }
+
+    /**
+     * The underlying protocol buffer form of the credential.
+     */
+    public org.openyolo.proto.Credential getProto() {
+        return mProto;
+    }
+
+    /**
+     * The credential identifier, which is typically unique within the authentication domain.
+     * Must be non-empty.
+     */
+    @NonNull
+    public String getIdentifier() {
+        return mProto.id;
+    }
+
+    /**
+     * The authentication domain against which this credential can be used, if specified.
+     */
+    @NonNull
+    public AuthenticationDomain getAuthenticationDomain() {
+        return new AuthenticationDomain(mProto.authDomain);
+    }
+
+    /**
+     * The credential password, if defined. Must be non-empty, but any further restrictions are
+     * the responsibility of the authentication domain to define and validate.
+     */
+    @Nullable
+    public String getPassword() {
+        return mProto.password;
+    }
+
+    /**
+     * The display name for the credential, if defined. This is typically the user's
+     * full name or an alias for the account that will be recognizable and distinguishable between
+     * multiple credentials that the user may have.
+     */
+    @Nullable
+    public String getDisplayName() {
+        return mProto.displayName;
+    }
+
+    /**
+     * The display picture for the credential, if defined. This is typically a picture of the
+     * user, or some chosen avatar for the account that will be recognizable and distinguishable
+     * between multiple credentials that the user may have.
+     */
+    @Nullable
+    public Uri getDisplayPicture() {
+        return (mProto.displayPictureUri != null)
+                ? Uri.parse(mProto.displayPictureUri)
+                : null;
+    }
+
+    /**
+     * The authentication method for the credential, which describes the mechanism by which
+     * it should be verified by the receiving app. This may be any valid URI, but is typically
+     * one of the {@link AuthenticationMethods standard values}.
+     */
+    @NonNull
+    public Uri getAuthenticationMethod() {
+        return Uri.parse(mProto.authMethod);
+    }
+
+    /**
+     * Additional, non-standard properties associated with the credential.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalProperties() {
+        Map<String, byte[]> additionalProps = new HashMap<>();
+
+        for (KeyValuePair pair : mProto.additionalProps) {
+            byte[] value = pair.value != null ? pair.value.toByteArray() : null;
+            additionalProps.put(pair.name, value);
+        }
+
+        return additionalProps;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        byte[] encoded = org.openyolo.proto.Credential.ADAPTER.encode(mProto);
+        dest.writeInt(encoded.length);
+        dest.writeByteArray(encoded);
+    }
+
+    /**
+     * Creates instances of {@link Credential}.
+     */
+    public static final class Builder {
+
+        private org.openyolo.proto.Credential.Builder mProtoBuilder;
+
+        /**
+         * Starts the process of creating a credential, based on the properties of the
+         * provided protocol buffer representation of the credential. The protocol buffer
+         * must contain valid data for a credential.
+         */
+        public Builder(@NonNull org.openyolo.proto.Credential proto) {
+            mProtoBuilder = new org.openyolo.proto.Credential.Builder();
+
+            // required properties
+            setIdentifier(proto.id);
+            setAuthenticationDomain(new AuthenticationDomain(proto.authDomain));
+            setAuthenticationMethod(proto.authMethod);
+
+            // optional properties
+            setDisplayName(proto.displayName);
+            setDisplayPicture(proto.displayPictureUri);
+            setPassword(proto.password);
+            setAdditionalProperties(
+                    CollectionConverter.toMap(
+                            proto.additionalProps,
+                            KeyValuePairConverters.CONVERTER_KVP_TO_PAIR));
+        }
+
+        /**
+         * Starts the process of creating a credential, with the mandatory identifier,
+         * authentication method and authentication domain. To create a credential for your
+         * own application, do:
+         *
+         * <pre>{@code
+         * Credential cr = new Credential.Builder(
+         *     id,
+         *     authMethod,
+         *     AuthenticationDomain.getSelfAuthDomain(context))
+         *     .setPassword(pass)
+         *     ...
+         *     .build();
+         * }</pre>
+         * @param identifier the identifier for the credential. Must not be null or empty.
+         */
+        public Builder(
+                @NonNull String identifier,
+                @NonNull Uri authenticationMethod,
+                @NonNull AuthenticationDomain authenticationDomain) {
+            mProtoBuilder = new org.openyolo.proto.Credential.Builder();
+            setIdentifier(identifier);
+            setAuthenticationMethod(authenticationMethod);
+            setAuthenticationDomain(authenticationDomain);
+        }
+
+        /**
+         * Specifies the identifier for the credential. The provided value must not be null or
+         * empty.
+         */
+        @NonNull
+        public Builder setIdentifier(@NonNull String identifier) {
+            require(!TextUtils.isEmpty(identifier), "identifer must not be null or empty");
+            mProtoBuilder.id = identifier;
+            return this;
+        }
+
+        /**
+         * Specifies the authentication domain against which this credential is valid.
+         */
+        @NonNull
+        public Builder setAuthenticationDomain(@NonNull AuthenticationDomain domain) {
+            require(domain, notNullValue());
+            mProtoBuilder.authDomain = extractString(domain);
+            return this;
+        }
+
+        /**
+         * Specifies the authentication method for verifying the credential. This may be any
+         * URI of form {@code scheme://authority}, but is typically one of the
+         * {@link AuthenticationMethods standard values}.
+         */
+        @NonNull
+        public Builder setAuthenticationMethod(@NonNull Uri provider) {
+            require(provider, isValidAuthenticationMethod());
+            mProtoBuilder.authMethod = extractString(provider);
+            return this;
+        }
+
+        /**
+         * Specifies the authentication method for the credential, in string form for convenience.
+         * @see #setAuthenticationMethod(Uri)
+         */
+        @NonNull
+        public Builder setAuthenticationMethod(@NonNull String provider) {
+            return setAuthenticationMethod(Uri.parse(provider));
+        }
+
+        /**
+         * Specifies the password for the credential. If a non-null value is provided, it must
+         * not be empty.
+         */
+        @NonNull
+        public Builder setPassword(@Nullable String password) {
+            if (password != null) {
+                require(!TextUtils.isEmpty(password), "password must be null or not empty");
+            }
+            mProtoBuilder.password = password;
+            return this;
+        }
+
+        /**
+         * Specifies the display name for the credential. If a non-null value is provided, it
+         * must not be empty.
+         */
+        @NonNull
+        public Builder setDisplayName(@Nullable String displayName) {
+            if (displayName != null) {
+                require(!TextUtils.isEmpty(displayName),
+                        "display name must be null or not empty");
+            }
+            mProtoBuilder.displayName = displayName;
+            return this;
+        }
+
+        /**
+         * Specifies the display picture for the credential, which must be a HTTP or HTTPS URI
+         * to an image resource.
+         */
+        @NonNull
+        public Builder setDisplayPicture(@Nullable Uri displayPicture) {
+            require(displayPicture, nullOr(isWebUri()));
+            mProtoBuilder.displayPictureUri = extractString(displayPicture);
+            return this;
+        }
+
+        /**
+         * Specifies the display picture for the credential, in string form for convenience.
+         * @see #setDisplayPicture(Uri)
+         */
+        @NonNull
+        public Builder setDisplayPicture(@Nullable String displayPicture) {
+            return setDisplayPicture(
+                    displayPicture != null ? Uri.parse(displayPicture) : null);
+        }
+
+        /**
+         * Specifies any additional, non-standard properties associated with the credential.
+         */
+        public Builder setAdditionalProperties(@Nullable Map<String, byte[]> additionalProps) {
+            mProtoBuilder.additionalProps = CollectionConverter.toList(
+                    additionalProps.entrySet(),
+                    KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP);
+            return this;
+        }
+
+        /**
+         * Creates the {@link Credential credential} instance with all properties specified.
+         */
+        @NonNull
+        public Credential build() {
+            return new Credential(mProtoBuilder.build());
+        }
+
+        private String extractString(@Nullable Object obj) {
+            return (obj != null) ? obj.toString() : null;
+        }
+    }
+
+    static final class CredentialCreator implements Creator<Credential> {
+        @Override
+        public Credential createFromParcel(Parcel source) {
+            int encodedLength = source.readInt();
+            byte[] encodedBytes = new byte[encodedLength];
+            source.readByteArray(encodedBytes);
+
+            try {
+                org.openyolo.proto.Credential proto =
+                        org.openyolo.proto.Credential.ADAPTER.decode(encodedBytes);
+                return new Credential(proto);
+            } catch (IOException ex) {
+                throw new IllegalStateException("Unable to decode credential proto", ex);
+            }
+        }
+
+        @Override
+        public Credential[] newArray(int size) {
+            return new Credential[0];
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/CredentialClient.java b/api/java/org/openyolo/api/CredentialClient.java
new file mode 100644
index 0000000..157619b
--- /dev/null
+++ b/api/java/org/openyolo/api/CredentialClient.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.Log;
+import com.google.bbq.BroadcastQueryClient;
+import com.google.bbq.QueryCallback;
+import com.google.bbq.QueryResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.openyolo.api.internal.IntentUtil;
+import org.openyolo.api.ui.ProviderPickerActivity;
+import org.openyolo.proto.CredentialRetrieveResponse;
+
+/**
+ * Interact with credential providers on the device which support OpenYOLO.
+ */
+public class CredentialClient {
+
+    /**
+     * The data type used for credential queries using the BBQ protocol.
+     */
+    public static final String CREDENTIAL_DATA_TYPE = "org.openyolo.credential";
+
+    /**
+     * The extra value key used to store the credential in a retrieve intent response.
+     */
+    public static final String EXTRA_CREDENTIAL = "org.openyolo.retrieve.credential";
+
+    /**
+     * The extra key value used to carry a hint request to a credential provider.
+     */
+    public static final String EXTRA_HINT_REQUEST = "org.openyolo.hint.request";
+
+    /**
+     * The category used for all OpenYOLO-related intents.
+     */
+    public static final String OPENYOLO_CATEGORY = "org.openyolo";
+
+    /**
+     * The action used for hint intents.
+     */
+    public static final String HINT_CREDENTIAL_ACTION = "org.openyolo.hint";
+
+    /**
+     * The action used for save intents.
+     */
+    public static final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
+
+    private static final String LOG_TAG = "CredentialClient";
+
+    private static final AtomicReference<CredentialClient> INSTANCE_REF
+            = new AtomicReference<>();
+
+    private final Context mApplicationContext;
+
+    private final BroadcastQueryClient mQueryClient;
+
+    /**
+     * Retrieves the singleton credential client instance associated with the application.
+     */
+    public static CredentialClient getApplicationBoundInstance(Context context) {
+        Context applicationContext = context.getApplicationContext();
+        CredentialClient client = new CredentialClient(applicationContext);
+        if (!INSTANCE_REF.compareAndSet(null, client)) {
+            client = INSTANCE_REF.get();
+        }
+
+        return client;
+    }
+
+    CredentialClient(Context applicationContext) {
+        mApplicationContext = applicationContext;
+        mQueryClient = BroadcastQueryClient.getApplicationBoundInstance(applicationContext);
+    }
+
+    /**
+     * Provides an intent to request a login hint. This will target the user's prefered credential
+     * provider, if this can be determined. If no providers are available, {@code null} is
+     * returned.
+     */
+    @Nullable
+    public Intent getHintRetrieveIntent(final HintRequest request) {
+        List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION, null);
+
+        if (hintProviders.isEmpty()) {
+            return null;
+        }
+
+        byte[] encodedRequest = request.toProtocolBuffer().encode();
+
+        // TODO: if a preferred credential provider is set, directly invoke it.
+        ArrayList<Intent> hintIntents = new ArrayList<>();
+        for (ComponentName providerActivity : hintProviders) {
+            Intent hintIntent = createIntent(providerActivity, HINT_CREDENTIAL_ACTION);
+            hintIntent.putExtra(EXTRA_HINT_REQUEST, encodedRequest);
+            hintIntents.add(hintIntent);
+        }
+
+        return ProviderPickerActivity.createHintIntent(mApplicationContext, hintIntents);
+    }
+
+    /**
+     * Requests and retrieves any available credentials from the credential providers on the device.
+     * @param request  Properties of the credential request
+     * @param callback Handler for the result of the credential request.
+     */
+    public void retrieve(
+            final RetrieveRequest request,
+            final RetrieveCallback callback) {
+        mQueryClient.queryFor(
+                CREDENTIAL_DATA_TYPE,
+                request.toProtocolBuffer(),
+                new CredentialRetrieveQueryCallback(callback));
+    }
+
+    /**
+     * Provides an intent to save the provided credential. If no compatible credential providers
+     * exist on the device, {@code null} will be returned. The intent should be started with a
+     * call to
+     * {@link android.app.Activity#startActivityForResult(Intent, int) startActivityForResult}.
+     *
+     * <p>If the credential is successfully saved, {@link android.app.Activity#RESULT_OK} will
+     * be returned. Otherwise, {@link android.app.Activity#RESULT_CANCELED} will be returned.
+     */
+    @Nullable
+    public Intent getSaveIntent(Credential credentialToSave) {
+        List<ComponentName> saveProviders =
+                findProviders(SAVE_CREDENTIAL_ACTION, credentialToSave.getAuthenticationMethod());
+
+        if (saveProviders.isEmpty()) {
+            return null;
+        }
+
+        // TODO: if a preferred password manager is set, directly invoke it if it is in the list,
+        // otherwise return no intent.
+
+        byte[] encodedCredential = credentialToSave.getProto().encode();
+
+        ArrayList<Intent> saveIntents = new ArrayList<>(saveProviders.size());
+        for (ComponentName providerActivity : saveProviders) {
+            Intent saveIntent = createIntent(providerActivity, SAVE_CREDENTIAL_ACTION);
+            saveIntent.setData(credentialToSave.getAuthenticationMethod());
+            saveIntent.putExtra(EXTRA_CREDENTIAL, encodedCredential);
+            saveIntents.add(saveIntent);
+        }
+
+        return ProviderPickerActivity.createSaveIntent(mApplicationContext, saveIntents);
+    }
+
+    private Intent createIntent(ComponentName component, String action) {
+        Intent intent = new Intent(action);
+        intent.setClassName(
+                component.getPackageName(),
+                component.getClassName());
+        intent.addCategory(OPENYOLO_CATEGORY);
+        return intent;
+    }
+
+    /**
+     * Extracts a credential from the data returned via
+     * {@link android.app.Activity#onActivityResult(int, int, Intent) onActivityResult},
+     * after a credential retrieve intent completes.
+     */
+    @Nullable
+    public Credential getCredentialFromActivityResult(@NonNull Intent resultData) {
+        if (resultData == null) {
+            Log.e(LOG_TAG, "resultData is null, exiting (returning null)");
+            return null;
+        }
+
+        if (!resultData.hasExtra(EXTRA_CREDENTIAL)) {
+            Log.i(LOG_TAG, "credential data missing from response");
+            return null;
+        }
+
+        byte[] credentialBytes = resultData.getByteArrayExtra(EXTRA_CREDENTIAL);
+        if (credentialBytes == null) {
+            Log.i(LOG_TAG, "No credential found in response");
+            return null;
+        }
+
+        org.openyolo.proto.Credential credentialProto;
+        try {
+            credentialProto = org.openyolo.proto.Credential.ADAPTER.decode(credentialBytes);
+        } catch (IOException ex) {
+            Log.e(LOG_TAG, "failed to decode credential from response data");
+            return null;
+        }
+
+        try {
+            return new Credential.Builder(credentialProto).build();
+        } catch (IllegalArgumentException ex) {
+            Log.e(LOG_TAG, "validation of received credential failed", ex);
+            return null;
+        }
+    }
+
+    private List<ComponentName> findProviders(
+            @NonNull String action,
+            @Nullable Uri data) {
+        Intent saveIntent = new Intent(action);
+        saveIntent.addCategory(OPENYOLO_CATEGORY);
+        if (data != null) {
+            saveIntent.setData(data);
+        }
+
+        List<ResolveInfo> resolveInfos =
+                mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0);
+
+        ArrayList<ComponentName> responders = new ArrayList<>();
+        for (ResolveInfo info : resolveInfos) {
+            responders.add(new ComponentName(
+                    info.activityInfo.packageName,
+                    info.activityInfo.name));
+        }
+
+        return responders;
+    }
+
+    private class CredentialRetrieveQueryCallback implements QueryCallback {
+
+        private final RetrieveCallback mCallback;
+
+        CredentialRetrieveQueryCallback(RetrieveCallback callback) {
+            mCallback = callback;
+        }
+
+        @Override
+        public void onResponse(long queryId, List<QueryResponse> queryResponses) {
+            ArrayList<Intent> retrieveIntents = new ArrayList<>();
+            Map<String, CredentialRetrieveResponse> protoResponses = new HashMap<>();
+            for (QueryResponse queryResponse : queryResponses) {
+                CredentialRetrieveResponse response;
+                try {
+                    response = CredentialRetrieveResponse.ADAPTER.decode(
+                            queryResponse.responseMessage);
+                } catch (IOException e) {
+                    Log.w(LOG_TAG, "Failed to decode credential retrieve response");
+                    continue;
+                }
+
+                protoResponses.put(queryResponse.responderPackage, response);
+
+                if (response.retrieveIntent != null) {
+                    // TODO: handle failure to decode retrieve intent gracefully
+                    // (i.e. ignore the response)
+                    Intent retrieveIntent =
+                            IntentUtil.fromBytes(response.retrieveIntent.toByteArray());
+
+                    if (!queryResponse.responderPackage.equals(
+                            retrieveIntent.getComponent().getPackageName())) {
+                        Log.w(LOG_TAG, "Package mismatch between provider and retrieve intent");
+                        continue;
+                    }
+
+                    retrieveIntents.add(retrieveIntent);
+                }
+            }
+
+            Intent retrieveIntent = null;
+            if (retrieveIntents.size() == 1) {
+                retrieveIntent = retrieveIntents.get(0);
+            } else if (retrieveIntents.size() > 1) {
+                retrieveIntent = ProviderPickerActivity.createRetrieveIntent(
+                        mApplicationContext,
+                        retrieveIntents);
+            }
+
+            mCallback.onComplete(
+                    new RetrieveResult.Builder()
+                            .setProtoResponses(protoResponses)
+                            .setRetrieveIntent(retrieveIntent)
+                            .build(),
+                    null);
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/HintRequest.java b/api/java/org/openyolo/api/HintRequest.java
new file mode 100644
index 0000000..00aa98d
--- /dev/null
+++ b/api/java/org/openyolo/api/HintRequest.java
@@ -0,0 +1,471 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static java.util.Collections.unmodifiableMap;
+import static java.util.Collections.unmodifiableSet;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.api.internal.CollectionConverter.toList;
+import static org.openyolo.api.internal.CollectionConverter.toMap;
+import static org.openyolo.api.internal.CollectionConverter.toSet;
+import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationDomain;
+import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.api.internal.CustomMatchers.isValidIdentifierType;
+import static org.openyolo.api.internal.CustomMatchers.notNullOrEmptyString;
+import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP;
+import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_KVP_TO_PAIR;
+import static org.openyolo.api.internal.UriConverters.CONVERTER_STRING_TO_URI;
+import static org.openyolo.api.internal.UriConverters.CONVERTER_URI_TO_STRING;
+import static org.valid4j.Assertive.require;
+
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.openyolo.api.internal.NoopValueConverter;
+import org.openyolo.api.internal.UriConverters;
+import org.openyolo.proto.HintRetrieveRequest;
+
+/**
+ * A request for a login hint, to be sent to credential providers on the device. Hints provide
+ * the basic set of information that can help with account creation, or re-discovering an
+ * existing account.
+ */
+public class HintRequest implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link HintRequest} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<HintRequest> CREATOR = new HintRequestCreator();
+
+    @NonNull
+    private final Set<Uri> mAuthMethods;
+
+    @NonNull
+    private final Set<Uri> mIdTypes;
+
+    @NonNull
+    private final PasswordSpecification mPasswordSpec;
+
+    @NonNull
+    private final Map<String, byte[]> mAdditionalParams;
+
+    /**
+     * Creates a hint request for email and password based accounts.
+     */
+    public static HintRequest forEmailAndPasswordAccount() {
+        return new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes(IdentifierTypes.EMAIL)
+                .build();
+    }
+
+    /**
+     * Reads a hint request from its protocol buffer byte array form.
+     * @throws IOException if the hint request could not be decoded.
+     *
+     * @see {{@link #toProtocolBuffer()}}.
+     */
+    @NonNull
+    public static HintRequest fromProtoBytes(byte[] hintRequestProtoBytes)
+            throws IOException {
+        if (hintRequestProtoBytes == null) {
+            throw new IOException("Unable to decode hint request from null array");
+        }
+        return new HintRequest.Builder(
+                org.openyolo.proto.HintRetrieveRequest.ADAPTER.decode(hintRequestProtoBytes))
+                .build();
+    }
+
+    private HintRequest(
+            @NonNull Set<Uri> authMethods,
+            @NonNull Set<Uri> idTypes,
+            @NonNull PasswordSpecification passwordSpec,
+            @NonNull Map<String, byte[]> additionalParams) {
+        mAuthMethods = authMethods;
+        mIdTypes = idTypes;
+        mPasswordSpec = passwordSpec;
+        mAdditionalParams = additionalParams;
+    }
+
+    /**
+     * The set of authentication methods supported by the client for login.
+     */
+    @NonNull
+    public Set<Uri> getAuthenticationMethods() {
+        return mAuthMethods;
+    }
+
+    /**
+     * The set of identifier types that the requester uses. This is used to filter the
+     * set of hints to just those which are potentially usable. If no identifier type is
+     * specified, then any identifier string can be returned.
+     */
+    @NonNull
+    public Set<Uri> getIdentifierTypes() {
+        return mIdTypes;
+    }
+
+    /**
+     * A password specification which describes the "shape" of passwords that the requester
+     * allows. This can be used for password generation by the credential provider, to
+     * facilitate the creation of accounts with secure, unique passwords across all of the
+     * user's accounts.
+     */
+    @NonNull
+    public PasswordSpecification getPasswordSpecification() {
+        return mPasswordSpec;
+    }
+
+    /**
+     * The map of additional, non-standard properties included with this request.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalParameters() {
+        return mAdditionalParams;
+    }
+
+    /**
+     * Retrieves the value of the named additional parameter, where the value is a UTF-8
+     * encoded string.
+     */
+    @Nullable
+    public String getAdditionalParameterAsString(@NonNull String key) {
+        require(key, notNullValue());
+        if (mAdditionalParams.containsKey(key)) {
+            return new String(mAdditionalParams.get(key), Charset.forName("UTF-8"));
+        }
+        return null;
+    }
+
+    /**
+     * Retrieves the raw, byte-array value of the named additional parameter.
+     */
+    @Nullable
+    public byte[] getAdditionalParameter(@NonNull String key) {
+        require(key, notNullValue());
+        return mAdditionalParams.get(key);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        byte[] protoBytes = toProtocolBuffer().encode();
+        dest.writeInt(protoBytes.length);
+        dest.writeByteArray(protoBytes);
+    }
+
+    /**
+     * Converts the request into a protocol buffer, for storage or transmission.
+     */
+    @NonNull
+    public HintRetrieveRequest toProtocolBuffer() {
+        return new HintRetrieveRequest.Builder()
+                .authMethods(toList(mAuthMethods, CONVERTER_URI_TO_STRING))
+                .idTypes(toList(mIdTypes, CONVERTER_URI_TO_STRING))
+                .additionalParams(toList(mAdditionalParams.entrySet(), CONVERTER_ENTRY_TO_KVP))
+                .passwordSpec(mPasswordSpec.toProtocolBuffer())
+                .build();
+    }
+
+    /**
+     * Creates {@link HintRequest} instances.
+     */
+    public static final class Builder {
+
+        private Set<Uri> mAuthMethods = new HashSet<>();
+        private Set<Uri> mIdTypes = new HashSet<>();
+        private Map<String, byte[]> mAdditionalParams = new HashMap<>();
+        private PasswordSpecification mPasswordSpec = PasswordSpecification.DEFAULT;
+
+        /**
+         * Recreates a hint request from its protocol buffer form.
+         *
+         * @see {@link HintRequest#toProtocolBuffer()}
+         */
+        public Builder(@NonNull HintRetrieveRequest requestProto) {
+            require(requestProto, notNullValue());
+            setAuthenticationMethods(toSet(requestProto.authMethods, CONVERTER_STRING_TO_URI));
+            setIdentifierTypes(toSet(requestProto.idTypes, CONVERTER_STRING_TO_URI));
+            setPasswordSpecification(
+                    new PasswordSpecification.Builder(requestProto.passwordSpec).build());
+            setAdditionalParameters(toMap(requestProto.additionalParams, CONVERTER_KVP_TO_PAIR));
+        }
+
+        /**
+         * Starts the process of defining a hint request, specifying at least one supported
+         * authentication method.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        public Builder(@NonNull Uri authMethod, @NonNull Uri... additionalAuthMethods) {
+            setAuthenticationMethods(authMethod, additionalAuthMethods);
+        }
+
+        /**
+         * Starts the process of defining a hint request, specifying at least one supported
+         * authentication method in string form.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        public Builder(@NonNull String authMethod, @NonNull String... additionalAuthMethods) {
+            setAuthenticationMethods(authMethod, additionalAuthMethods);
+        }
+
+        /**
+         * Starts the process of defining a hint request, specifying at least one supported
+         * authentication method in string form.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        public Builder(@NonNull Set<Uri> authMethods) {
+            setAuthenticationMethods(authMethods);
+        }
+
+        /**
+         * Specifies the authentication methods supported by the requester. At least one
+         * authentication method must be specified.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        @NonNull
+        public Builder setAuthenticationMethods(
+                @NonNull Uri authMethod,
+                Uri... additionalAuthMethods) {
+            setAuthenticationMethods(
+                    toSet(
+                            authMethod,
+                            additionalAuthMethods,
+                            NoopValueConverter.<Uri>getInstance()));
+            return this;
+        }
+
+        /**
+         * Specifies the authentication methods supported by the requester, in string form. At
+         * least one authentication method must be specified.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        public Builder setAuthenticationMethods(
+                @NonNull String authMethod,
+                @NonNull String... additionalAuthMethods) {
+            setAuthenticationMethods(
+                    toSet(
+                            authMethod,
+                            additionalAuthMethods,
+                            UriConverters.CONVERTER_STRING_TO_URI));
+            return this;
+        }
+
+        /**
+         * Specifies the authentication methods supported by the requester. At least one
+         * authentication method must be specified.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        @NonNull
+        public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
+            require(authMethods, notNullValue());
+            require(!authMethods.isEmpty(), "At least one authentication method must be specified");
+            require(authMethods, everyItem(isValidAuthenticationMethod()));
+            mAuthMethods = authMethods;
+            return this;
+        }
+
+        /**
+         * Adds an authentication method (in string form) supported by the requester.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        @NonNull
+        public Builder addAuthenticationMethod(@NonNull String authMethodStr) {
+            require(authMethodStr, notNullOrEmptyString());
+            addAuthenticationMethod(Uri.parse(authMethodStr));
+            return this;
+        }
+
+        /**
+         * Adds an authentication method supported by the requester.
+         *
+         * @see {@link AuthenticationMethods}
+         */
+        @NonNull
+        public Builder addAuthenticationMethod(@NonNull Uri authenticationMethod) {
+            require(authenticationMethod, isValidAuthenticationDomain());
+            mAuthMethods.add(authenticationMethod);
+            return this;
+        }
+
+        /**
+         * Specifies the identifier types that the requester supports. If no identifier types
+         * are specified, then credentials with any form of identifier can be returned.
+         *
+         * @see {@link IdentifierTypes}
+         */
+        @NonNull
+        public Builder setIdentifierTypes(@NonNull String... idTypes) {
+            setIdentifierTypes(
+                    toSet(null, idTypes, UriConverters.CONVERTER_STRING_TO_URI));
+            return this;
+        }
+
+        /**
+         * Specifies the identifier types that the requester supports. If no identifier types
+         * are specified, then credentials with any form of identifier can be returned.
+         *
+         * @see {@link IdentifierTypes}
+         */
+        @NonNull
+        public Builder setIdentifierTypes(@NonNull Uri... idTypes) {
+            setIdentifierTypes(
+                    toSet(null, idTypes, NoopValueConverter.<Uri>getInstance()));
+            return this;
+        }
+
+        /**
+         * Specifies the identifier types that the requester supports. If no identifier types
+         * are specified, then credentials with any form of identifier can be returned.
+         *
+         * @see {@link IdentifierTypes}
+         */
+        @NonNull
+        public Builder setIdentifierTypes(@NonNull Set<Uri> identifierTypes) {
+            require(identifierTypes, notNullValue());
+            require(identifierTypes, everyItem(isValidIdentifierType()));
+            mIdTypes = identifierTypes;
+            return this;
+        }
+
+        /**
+         * Adds a supported identifier type to the hint request.
+         *
+         * @see {@link IdentifierTypes}
+         */
+        @NonNull
+        public Builder addIdentifierType(@NonNull String identifierTypeStr) {
+            require(identifierTypeStr, notNullOrEmptyString());
+            addIdentifierType(Uri.parse(identifierTypeStr));
+            return this;
+        }
+
+        /**
+         * Adds a supported identifier type to the hint request.
+         *
+         * @see {@link IdentifierTypes}
+         */
+        @NonNull
+        public Builder addIdentifierType(@NonNull Uri identifierType) {
+            require(identifierType, isValidIdentifierType());
+            mIdTypes.add(identifierType);
+            return this;
+        }
+
+        /**
+         * Specifies additional, non-standard hint request parameters. The provided map
+         * must be non-null, and contain only non-empty keys and non-null values.
+         */
+        @NonNull
+        public Builder setAdditionalParameters(@NonNull Map<String, byte[]> additionalParams) {
+            require(additionalParams, notNullValue());
+            require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
+            require(additionalParams.values(), everyItem(notNullValue()));
+            mAdditionalParams = additionalParams;
+            return this;
+        }
+
+        /**
+         * Adds an additional, non-standard parameter to the hint request with a string value, that
+         * will be encoded as UTF-8. The parameter name and value must both be non-null, and the
+         * key must be non-empty.
+         */
+        @NonNull
+        public Builder addAdditionalParameter(@NonNull String name, @NonNull String value) {
+            require(value, notNullValue());
+            addAdditionalParameter(name, value.getBytes(Charset.forName("UTF-8")));
+            return this;
+        }
+
+        /**
+         * Adds an additional, non-standard parameter to the hint request, that will be encoded as
+         * UTF-8. The parameter name and value must both be non-null, and the key must be non-empty.
+         */
+        @NonNull
+        public Builder addAdditionalParameter(@NonNull String name, @NonNull byte[] value) {
+            require(name, notNullOrEmptyString());
+            require(value, notNullValue());
+            mAdditionalParams.put(name, value);
+            return this;
+        }
+
+        /**
+         * Specifies the "shape" of passwords that the requester supports. This will be used
+         * for password generation by the credential provider. If no value is explicitly provided,
+         * the {@link PasswordSpecification#DEFAULT default password specification} will be used.
+         */
+        @NonNull
+        public Builder setPasswordSpecification(@NonNull PasswordSpecification passwordSpec) {
+            require(passwordSpec, notNullValue());
+            mPasswordSpec = passwordSpec;
+            return this;
+        }
+
+        /**
+         * Creates a {@link HintRequest} with the properties specified on the builder.
+         */
+        @NonNull
+        public HintRequest build() {
+            return new HintRequest(
+                    unmodifiableSet(mAuthMethods),
+                    unmodifiableSet(mIdTypes),
+                    mPasswordSpec,
+                    unmodifiableMap(mAdditionalParams));
+        }
+    }
+
+    private static final class HintRequestCreator implements Creator<HintRequest> {
+        @Override
+        public HintRequest createFromParcel(Parcel in) {
+
+            int protoLength = in.readInt();
+            byte[] protoBytes = new byte[protoLength];
+            in.readByteArray(protoBytes);
+
+            try {
+                return new HintRequest.Builder(
+                        HintRetrieveRequest.ADAPTER.decode(protoBytes))
+                        .build();
+            } catch (IOException ex) {
+                throw new IllegalStateException("Unable to read proto from parcel", ex);
+            }
+        }
+
+        @Override
+        public HintRequest[] newArray(int size) {
+            return new HintRequest[size];
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/IdentifierTypes.java b/api/java/org/openyolo/api/IdentifierTypes.java
new file mode 100644
index 0000000..411e0b4
--- /dev/null
+++ b/api/java/org/openyolo/api/IdentifierTypes.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import android.net.Uri;
+
+/**
+ * The standard identifier types defined in the OpenYOLO specification. Any URI of form
+ * {@code scheme://authority} can be used as an identifier type, but the values defined here
+ * have a common meaning across all credential providers.
+ */
+public final class IdentifierTypes {
+
+    /**
+     * Designates identifiers which are composed of alphanumeric characters only. This is typical
+     * of sites with "usernames" instead of email addresses as the primary identifier, e.g.
+     * "bob" instead of "bob@example.com".
+     */
+    public static final Uri ALPHANUMERIC = Uri.parse("openyolo://alphanumeric-identifier");
+
+    /**
+     * Designates email address based identifiers.
+     */
+    public static final Uri EMAIL = Uri.parse("openyolo://email-identifier");
+
+    /**
+     * Designates phone number based identifiers.
+     */
+    public static final Uri PHONE = Uri.parse("openyolo://phone-identifier");
+
+    private IdentifierTypes() {
+        throw new IllegalStateException("Not intended to be constructed");
+    }
+}
diff --git a/api/java/org/openyolo/api/KnownProviders.java b/api/java/org/openyolo/api/KnownProviders.java
new file mode 100644
index 0000000..cead4db
--- /dev/null
+++ b/api/java/org/openyolo/api/KnownProviders.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Manages a list of known providers, identified by their package name and a hash of their
+ * signing certificate. This class will attempt to dynamically retrieve a list of known providers
+ * from openyolo.org if possible, otherwise it will fall back to the list of known providers at
+ * compile time.
+ */
+public class KnownProviders {
+
+    private Context mApplicationContext;
+    private Set<AuthenticationDomain> mKnownProviders;
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://www.dashlane.com">Dashlane</a>.
+     */
+    public static final AuthenticationDomain DASHLANE_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
+                    + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
+                    + "@com.dashlane");
+
+    /**
+     * The known package name and certificate hash for Google's
+     * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
+     * Smart Lock for Passwords</a>.
+     */
+    public static final AuthenticationDomain GOOGLE_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
+                    + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
+                    + "@com.google.android.gms");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://keepersecurity.com/">Keeper</a>.
+     */
+    public static final AuthenticationDomain KEEPER_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
+                    + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
+                    + "@com.callpod.android_apps.keeper");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://www.lastpass.com/">LastPass</a>.
+     */
+    public static final AuthenticationDomain LASTPASS_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
+                    + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
+                    + "@com.lastpass.lpandroid");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://1password.com/">1Password</a>.
+     */
+    public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
+                    + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
+                    + "@com.agilebits.onepassword");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://www.roboform.com/">Roboform</a>.
+     */
+    public static final AuthenticationDomain ROBOFORM_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
+                    + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
+                    + "@com.siber.roboform");
+
+    /**
+     * The list of known providers at the time this library was compiled.
+     */
+    public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
+            Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
+                    DASHLANE_PROVIDER,
+                    GOOGLE_PROVIDER,
+                    KEEPER_PROVIDER,
+                    LASTPASS_PROVIDER,
+                    ONEPASSWORD_PROVIDER,
+                    ROBOFORM_PROVIDER
+            )));
+
+    private static final AtomicReference<KnownProviders> INSTANCE_REF =
+            new AtomicReference<>();
+
+    /**
+     * Retrieves the singleton instance of the known provider list.
+     */
+    public static KnownProviders getApplicationBoundInstance(Context context) {
+        KnownProviders providers = new KnownProviders(context);
+        if (!INSTANCE_REF.compareAndSet(null, providers)) {
+            providers = INSTANCE_REF.get();
+        }
+
+        return providers;
+    }
+
+    private KnownProviders(Context context) {
+        mApplicationContext = context.getApplicationContext();
+
+        // TODO: implement dynamic retrieval of known providers from
+        // https://www.openyolo.org/known-providers
+        // and fall back to the static list only if this fails
+        mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
+    }
+
+    public Set<AuthenticationDomain> getKnownProviders() {
+        return mKnownProviders;
+    }
+
+    /**
+     * Determines whether the application with the specified package name (if installed) is
+     * on the known provider list.
+     */
+    public boolean isKnown(String packageName) {
+        List<AuthenticationDomain> packageAuthDomains =
+                AuthenticationDomain.listForPackage(mApplicationContext, packageName);
+
+        for (AuthenticationDomain packageAuthDomain : packageAuthDomains) {
+            if (mKnownProviders.contains(packageAuthDomain)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Reset the list of known providers to the default provider set. If possible, this will be
+     * dynamically updated with a list retrieved from openyolo.org.
+     *
+     * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
+     * than a unit test or test app.
+     */
+    @VisibleForTesting
+    public void resetKnownProvidersToDefault() {
+        mKnownProviders = DEFAULT_KNOWN_PROVIDERS;
+    }
+
+    /**
+     * Adds a provider to the known provider list.
+     *
+     * <p><em>NOTE</em>: it is not typically necessary to ever call this method for anything other
+     * than a unit test or test app.
+     */
+    @VisibleForTesting
+    public void addKnownProvider(AuthenticationDomain provider) {
+        HashSet<AuthenticationDomain> knownProviders = new HashSet<>(mKnownProviders);
+        knownProviders.add(provider);
+        mKnownProviders = Collections.unmodifiableSet(knownProviders);
+    }
+}
diff --git a/api/java/org/openyolo/api/PasswordSpecification.java b/api/java/org/openyolo/api/PasswordSpecification.java
new file mode 100644
index 0000000..4bca5c3
--- /dev/null
+++ b/api/java/org/openyolo/api/PasswordSpecification.java
@@ -0,0 +1,830 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.api.internal.Constants.HASH_PRIME;
+import static org.valid4j.Assertive.require;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.IntDef;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * Specification of an acceptable set of passwords, expressed in terms of allowed and required
+ * sets of characters and a size range. Only ASCII printable characters are supported.
+ *
+ * <p>
+ * Example Specifications:
+ *
+ * <ul>
+ *     <li>
+ *     A 12-16 character password that must contain at least one digit and one upper-case letter:
+ *     {@code
+ *     new PasswordSpecification.Builder()
+ *             .ofLength(12, 16)
+ *             .allow(ALL_PRINTABLE)
+ *             .require(NUMERALS, 1)
+ *             .require(UPPER_ALPHA, 1)
+ *             .build();
+ *     }
+ *     </li>
+ *     <li>
+ *     A 6-digit pin number:
+ *     {@code
+ *     new PasswordSpecification.Builder()
+ *             .allow(NUMERALS)
+ *             .ofLength(6,6)
+ *             .build();
+ *     }
+ *     </li>
+ *     <li>
+ *     An 8-12 character password permitting only alphanumeric characters
+ *     {@code
+ *     new PasswordSpecification.Builder()
+ *             .ofLength(8,12)
+ *             .allow(LOWER_ALPHA)
+ *             .allow(UPPER_ALPHA)
+ *             .allow(NUMERALS)
+ *             .build();
+ *     }
+ *     </li>
+ * </ul>
+ * </p>
+ */
+public final class PasswordSpecification implements Parcelable {
+
+    /**
+     * Parcelable {@link android.os.Parcelable.Creator Creator} for PasswordSpecification instances.
+     */
+    public static final Creator<PasswordSpecification> CREATOR = new PasswordSpecificationCreator();
+
+    /**
+     * The set of lower case ASCII characters (a-z).
+     */
+    public static final String LOWER_ALPHA = "abcdefghijklmnopqrstuvwxyz";
+
+    /**
+     * The set of lower case ASCII characters, omitting those which are difficult to distinguish
+     * from other alphanumeric characters. The omitted characters are:
+     * <ul>
+     * <li>l (lima), often confused with 1 (one) and I (india, upper case)</li>
+     * <li>u (uniform), often confused with v (victor)</li>
+     * <li>v (victor), often confused with u (uniform)</li>
+     * <li>w (whiskey), often confused with vv (victor victor)</li>
+     * </ul>
+     */
+    public static final String LOWER_ALPHA_DISTINGUISHABLE = "abcdefghijkmnopqrstxyz";
+
+    /**
+     * The set of upper case ASCII characters (A-Z).
+     */
+    public static final String UPPER_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    /**
+     * The set of upper case ASCII characters, omitting those which can be difficult to distinguish
+     * from other alphanumeric characters. The omitted characters are:
+     * <ul>
+     * <li>I (india), often confused with 1 (one) and l (lima, lower case)</li>
+     * <li>O (oscar), often confused with 0 (zero)</li>
+     * <li>U (uniform), often confused with v (victor)</li>
+     * <li>V (victor), often confused with u (uniform)</li>
+     * <li>W (whiskey), often confused with vv (victor victor)</li>
+     * <li>Z (zulu), often confused with 2 (two)</li>
+     * </ul>
+     */
+    public static final String UPPER_ALPHA_DISTINGUISHABLE = "ABCDEFGHJKLMNPQRSTXY";
+
+    /**
+     * The set of ASCII numerals (0-9).
+     */
+    public static final String NUMERALS = "1234567890";
+
+    /**
+     * The set of ASCII numerals, omitting those which can be difficult to distinguish from other
+     * alphanumeric characters. The omitted characters are:
+     * <ul>
+     * <li>0 (zero), often confused with O (oscar, upper case)</li>
+     * <li>1 (one), often confused with I (india, upper case) and l (lima, lower case)</li>
+     * <li>2 (two), often confused with Z (zulu, upper case)</li>
+     * </ul>
+     */
+    public static final String NUMERALS_DISTINGUISHABLE = "3456789";
+
+    /**
+     * The set of all alpha-numeric ASCII characters (a-z, A-Z, 0-9).
+     */
+    public static final String ALPHANUMERIC = LOWER_ALPHA + UPPER_ALPHA + NUMERALS;
+
+    /**
+     * The set of all printable ASCII symbols.
+     */
+    public static final String SYMBOLS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
+
+    /**
+     * The set of all printable ASCII characters.
+     */
+    public static final String ALL_PRINTABLE =
+            LOWER_ALPHA + UPPER_ALPHA + NUMERALS + SYMBOLS;
+
+    /**
+     * The set of all alphanumeric characters (and space) which are easily
+     * distinguished. Specifically, this excludes:
+     * <ul>
+     * <li>I (india, upper case), often confused with 1 (one) and l (lima, lower case)</li>
+     * <li>l (lima, lower case), often confused with 1 (one) and I (india, upper case)</li>
+     * <li>O (oscar, upper case), often confused with 0 (zero)</li>
+     * <li>U (uniform, lower and upper case), often confused with v (victor)</li>
+     * <li>V (victor, lower and upper case), often confused with u (uniform)</li>
+     * <li>W (whiskey, lower and upper case), often confused with vv (victor victor)</li>
+     * <li>Z (zulu), often confused with 2 (two)</li>
+     * <li>0 (zero), often confused with O (oscar, upper case)</li>
+     * <li>1 (one), often confused with I (india, upper case) and l (lima, lower case)</li>
+     * <li>2 (two), often confused with Z (zulu, upper case)</li>
+     * </ul>
+     */
+    public static final String ALPHANUMERIC_DISTINGUISHABLE =
+            LOWER_ALPHA_DISTINGUISHABLE + UPPER_ALPHA_DISTINGUISHABLE + NUMERALS_DISTINGUISHABLE;
+
+    /**
+     * The minimum password length used by {@link #DEFAULT PasswordSpecification.DEFAULT}.
+     */
+    public static final int DEFAULT_MIN_PASSWORD_LENGTH = 12;
+
+    /**
+     * The maximum password length used by {@link #DEFAULT PasswordSpecification.DEFAULT}.
+     */
+    public static final int DEFAULT_MAX_PASSWORD_LENGTH = 16;
+
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({PASSWORD_CONFORMS,
+            PASSWORD_LENGTH_MISMATCH,
+            PASSWORD_REQUIRED_CHARACTER_MISSING,
+            PASSWORD_DISALLOWED_CHARACTER})
+    public @interface ConformanceMask {}
+
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({PASSWORD_LENGTH_MISMATCH,
+            PASSWORD_REQUIRED_CHARACTER_MISSING,
+            PASSWORD_DISALLOWED_CHARACTER})
+    public @interface ConformanceError {}
+
+    /**
+     * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
+     * that indicates that the supplied password conforms to the specification.
+     */
+    public static final int PASSWORD_CONFORMS = 0B0000;
+
+    /**
+     * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
+     * that indicates that the supplied password is not within the required size bounds.
+     */
+    public static final int PASSWORD_LENGTH_MISMATCH = 0B0001;
+
+    /**
+     * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
+     * that indicates that the supplied password is missing one or more required characters.
+     */
+    public static final int PASSWORD_REQUIRED_CHARACTER_MISSING = 0B0010;
+
+    /**
+     * BitMask to be used to check the result of {@link #checkConformance(String) checkConformance}
+     * that indicates that the supplied password contains a disallowed character.
+     */
+    public static final int PASSWORD_DISALLOWED_CHARACTER = 0B0100;
+
+    /**
+     * The default password specification used by the credentials API when no alternative is
+     * provided. This specification should be compatible with the majority of password based
+     * authentication systems and has sufficient entropy to be secure against offline attacks.
+     * The specification permits passwords between 12 and 16 characters in length, composed of at
+     * least one lower case letter, one upper case letter, and one numeral. All other characters
+     * must be alphanumeric.
+     *
+     * <p>Characters which are difficult to distinguish are disallowed in this specification,
+     * as it is tailored towards password generation rather than validation - see
+     * {@link #DEFAULT_FOR_VALIDATION} for a password specification suited to validating user
+     * entered passwords.
+     */
+    public static final PasswordSpecification DEFAULT = new PasswordSpecification.Builder()
+            .ofLength(DEFAULT_MIN_PASSWORD_LENGTH, DEFAULT_MAX_PASSWORD_LENGTH)
+            .allow(ALPHANUMERIC_DISTINGUISHABLE)
+            .require(LOWER_ALPHA_DISTINGUISHABLE, 1)
+            .require(UPPER_ALPHA_DISTINGUISHABLE, 1)
+            .require(NUMERALS_DISTINGUISHABLE, 1)
+            .build();
+
+    /**
+     * A default password specification, intended for use in validating user entered passwords.
+     * This differs from {@link #DEFAULT} in that characters which are difficult to distinguish
+     * are permitted.
+     */
+    public static final PasswordSpecification DEFAULT_FOR_VALIDATION =
+            new PasswordSpecification.Builder()
+                    .ofLength(DEFAULT_MIN_PASSWORD_LENGTH, DEFAULT_MAX_PASSWORD_LENGTH)
+                    .allow(ALPHANUMERIC)
+                    .require(LOWER_ALPHA, 1)
+                    .require(UPPER_ALPHA, 1)
+                    .require(NUMERALS, 1)
+                    .build();
+
+    private static final int ASCII_PRINTABLE_RANGE_LOWER = 32;
+    private static final int ASCII_PRINTABLE_RANGE_UPPER = 126;
+
+    /**
+     * Utility method to check if the password is conformant to the specification defined.
+     * @param result the result of the @link #checkConformance(String) checkConformance} method.
+     * @return true if password is conforming to specs.
+     */
+    public static boolean checkResultForError(final int result, @ConformanceError final int mask) {
+        return (result & mask) != 0;
+    }
+
+    /**
+     * The set of allowed characters, represented as a string.
+     */
+    public final String allowedChars;
+
+    /**
+     * The required character sets for this specification.
+     */
+    public final SortedSet<RequiredCharSet> requiredCharSets;
+
+    /**
+     * The maximum acceptable size of a password.
+     */
+    public final int minimumSize;
+
+    /**
+     * The minimum acceptable size of a password.
+     */
+    public final int maximumSize;
+
+    // the below fields are created on-demand, and are not serialized. They should not be
+    // directly referenced, instead, use the associated getters to ensure they are correctly
+    // instantiated.
+    private Integer mHash;
+    private Random mRandom;
+    private int[] mRequiredSpecMapping;
+    private int[] mRequiredCharCounts;
+
+    private PasswordSpecification(
+            String allowedChars,
+            SortedSet<RequiredCharSet> requiredCharSets,
+            int minimumSize,
+            int maximumSize) {
+        this.allowedChars = allowedChars;
+        this.requiredCharSets = Collections.unmodifiableSortedSet(requiredCharSets);
+        this.minimumSize = minimumSize;
+        this.maximumSize = maximumSize;
+    }
+
+    /**
+     * Determines whether the provided password conforms to the specification.
+     *
+     * @return a bit field which represents the status of the checks on this password.
+     *     values are {@link #PASSWORD_CONFORMS} - 0 if the password conforms to the specification.
+     *     Otherwise, an error code will be returned in the form of a bit field.
+     *     (one comprised of the of the bits representing issues with this password
+     *     {@link #PASSWORD_LENGTH_MISMATCH},
+     *     {@link #PASSWORD_DISALLOWED_CHARACTER} or
+     *     {@link #PASSWORD_REQUIRED_CHARACTER_MISSING}).
+     *
+     *     @see <a href="https://en.wikipedia.org/wiki/Bit_field">Bit Field</a> -
+     *     A bit field is a data structure used in computer programming, to store information in
+     *     the bits of a byte.
+     */
+    @ConformanceMask
+    public int checkConformance(String password) {
+        int result = PASSWORD_CONFORMS;
+        if (TextUtils.isEmpty(password)) {
+            result |= PASSWORD_LENGTH_MISMATCH;
+        }
+
+        if (isOutsideRange(password.length(), minimumSize, maximumSize)) {
+            result |= PASSWORD_LENGTH_MISMATCH;
+        }
+
+        // in order to check the required and allowed characters, we attempt to match
+        // each character against a required character set. If the requisite number of
+        // characters have been matched against that required set, then they are checked
+        // to see if they are allowed beyond this count (which allows for password
+        // specifications with exact required counts, by having a disjoint set of
+        // required characters from allowed characters).
+        int[] requiredSpecMapping = getRequiredSpecMapping();
+        int[] requiredSpecRemainingCounts = extractRequiredCharCounts();
+
+        for (char c : password.toCharArray()) {
+            if (!containsCharacter(allowedChars, c)) {
+                result |= PASSWORD_DISALLOWED_CHARACTER;
+            }
+
+            int requiredSpecIndex = requiredSpecMapping[getCharMappingIndex(c)];
+            if (requiredSpecIndex >= 0) {
+                requiredSpecRemainingCounts[requiredSpecIndex]--;
+            }
+        }
+
+        for (int remaining : requiredSpecRemainingCounts) {
+            if (remaining > 0) {
+                result |= PASSWORD_REQUIRED_CHARACTER_MISSING;
+                break;
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Generates a random password in conformance with the specification.
+     */
+    @NonNull
+    public String generate() {
+        int size = minimumSize + getRandom().nextInt(maximumSize - minimumSize + 1);
+        ArrayList<Character> chars = new ArrayList<>(size);
+
+        // select all the required characters
+        for (RequiredCharSet set : requiredCharSets) {
+            selectCharacters(set.chars, set.count, chars);
+        }
+
+        // select all remaining characters from the allowed characters set
+        int remaining = size - chars.size();
+        selectCharacters(allowedChars, remaining, chars);
+
+        // randomly shuffle the characters, so the required characters do not occur in a
+        // predictable position
+        Collections.shuffle(chars);
+        return charCollectionToString(chars);
+    }
+
+    /**
+     * Translates the specification into a protocol buffer, for transmission or storage.
+     */
+    @NonNull
+    public org.openyolo.proto.PasswordSpecification toProtocolBuffer() {
+        return new org.openyolo.proto.PasswordSpecification.Builder()
+                .minSize(minimumSize)
+                .maxSize(maximumSize)
+                .allowed(allowedChars)
+                .requiredSets(convertRequiredCharSetsToProto())
+                .build();
+    }
+
+    @Override
+    public void writeToParcel(Parcel out, int flags) {
+        byte[] encoded = toProtocolBuffer().encode();
+        out.writeInt(encoded.length);
+        out.writeByteArray(encoded);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj == null || !(obj instanceof PasswordSpecification)) {
+            return false;
+        }
+
+        PasswordSpecification other = (PasswordSpecification)obj;
+
+        if (this.minimumSize != other.minimumSize
+                || this.maximumSize != other.maximumSize
+                || !this.allowedChars.equals(other.allowedChars)) {
+            return false;
+        }
+
+        if (this.requiredCharSets.size() != other.requiredCharSets.size()) {
+            return false;
+        }
+
+        Iterator<RequiredCharSet> thisRequiredSetIter = this.requiredCharSets.iterator();
+        Iterator<RequiredCharSet> otherRequiredSetIter = other.requiredCharSets.iterator();
+
+        while (thisRequiredSetIter.hasNext()) {
+            if (!thisRequiredSetIter.next().equals(otherRequiredSetIter.next())) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        if (mHash != null) {
+            return mHash;
+        }
+
+        int hash = minimumSize;
+        hash = hash * HASH_PRIME + maximumSize;
+        hash = hash * HASH_PRIME + allowedChars.hashCode();
+
+        for (RequiredCharSet set : requiredCharSets) {
+            hash = hash * HASH_PRIME + set.chars.hashCode();
+            hash = hash * HASH_PRIME + set.count;
+        }
+
+        mHash = hash;
+        return mHash;
+    }
+
+    private List<org.openyolo.proto.RequiredCharSet> convertRequiredCharSetsToProto() {
+        List<org.openyolo.proto.RequiredCharSet> convertedRequiredCharSets = new ArrayList<>();
+
+        for (RequiredCharSet set : requiredCharSets) {
+            convertedRequiredCharSets.add(
+                    new org.openyolo.proto.RequiredCharSet.Builder()
+                            .chars(set.chars)
+                            .count(set.count)
+                            .build());
+        }
+
+        return convertedRequiredCharSets;
+    }
+
+    /**
+     * Extracts a mapping from an adjusted character index (where the lowest printable ascii
+     * character is given index 0) to the required character spec that it corresponds to,
+     * or -1 if the character is not part of any required set.
+     */
+    private int[] getRequiredSpecMapping() {
+        if (mRequiredSpecMapping != null) {
+            return mRequiredSpecMapping;
+        }
+
+        int[] requiredSpecMapping =
+                new int[ASCII_PRINTABLE_RANGE_UPPER - ASCII_PRINTABLE_RANGE_LOWER + 1];
+        Arrays.fill(requiredSpecMapping, -1);
+
+        int specIndex = 0;
+        for (RequiredCharSet set : requiredCharSets) {
+            for (char c : set.chars.toCharArray()) {
+                requiredSpecMapping[getCharMappingIndex(c)] = specIndex;
+            }
+            specIndex++;
+        }
+
+        mRequiredSpecMapping = requiredSpecMapping;
+        return mRequiredSpecMapping;
+    }
+
+    /**
+     * Determines the provided character's adjusted index in the required character spec mapping,
+     * where the lowest printable ascii character is given index 0.
+     */
+    private static int getCharMappingIndex(char ch) {
+        return ch - ASCII_PRINTABLE_RANGE_LOWER;
+    }
+
+    private void selectCharacters(String chars, int count, ArrayList<Character> result) {
+        Random random = getRandom();
+        for (int i = 0; i < count; i++) {
+            result.add(chars.charAt(random.nextInt(chars.length())));
+        }
+    }
+
+    private boolean containsCharacter(String chars, char ch) {
+        int pos = Arrays.binarySearch(chars.toCharArray(), ch);
+        return (pos >= 0 && pos < chars.length() && chars.charAt(pos) == ch);
+    }
+
+    private int[] extractRequiredCharCounts() {
+        if (mRequiredCharCounts == null) {
+            mRequiredCharCounts = new int[requiredCharSets.size()];
+            int index = 0;
+            for (RequiredCharSet set : requiredCharSets) {
+                mRequiredCharCounts[index] = set.count;
+                index++;
+            }
+        }
+
+        int[] requiredCharCounts = new int[mRequiredCharCounts.length];
+        System.arraycopy(
+                mRequiredCharCounts,
+                0, // source index
+                requiredCharCounts,
+                0, // destination index
+                mRequiredCharCounts.length);
+        return requiredCharCounts;
+    }
+
+    private Random getRandom() {
+        if (mRandom != null) {
+            return mRandom;
+        }
+
+        mRandom = new SecureRandom();
+        return mRandom;
+    }
+
+    private static String charCollectionToString(Collection<Character> chars) {
+        char[] charArray = new char[chars.size()];
+        int pos = 0;
+        for (char c : chars) {
+            charArray[pos++] = c;
+        }
+
+        return new String(charArray);
+    }
+
+    private static boolean isOutsideRange(int val, int lowerBound, int upperBound) {
+        return val < lowerBound || val > upperBound;
+    }
+
+    /**
+     * Produces {@link PasswordSpecification} instances. At least one call to
+     * {@link #allow(String)} or {@link #require(String,int)} must be made to specify the set of
+     * characters that the password can contain. The password size range will default to
+     * {@link #DEFAULT_MIN_PASSWORD_LENGTH} to {@link #DEFAULT_MAX_PASSWORD_LENGTH},
+     * which may be overridden.
+     */
+    public static class Builder {
+
+        private final TreeSet<Character> mAllowedCharSet = new TreeSet<>();
+        private final TreeSet<RequiredCharSet> mRequiredCharSets = new TreeSet<>();
+        private int mMinimumSize = -1;
+        private int mMaximumSize = -1;
+
+        /**
+         * Recreates a password specification from its protocol buffer form.
+         */
+        public Builder(org.openyolo.proto.PasswordSpecification proto) {
+            this.ofLength(proto.minSize, proto.maxSize);
+            this.allow(proto.allowed);
+            for (org.openyolo.proto.RequiredCharSet set : proto.requiredSets) {
+                this.require(set.chars, set.count);
+            }
+        }
+
+        /**
+         * Starts the process of defining a password specification.
+         */
+        public Builder() {}
+
+        /**
+         * Declares that the provided set of characters may occur in a password,
+         * zero or more times.
+         * @param allowedChars A set of characters which may occur in a password. Duplicate
+         *     characters in the string, or provided over multiple calls to allow,
+         *     will be ignored.
+         * @throws InvalidSpecificationError if the string is null or empty, or contains
+         *     characters which are not in the ascii printable range.
+         */
+        public Builder allow(@NonNull String allowedChars) {
+            mAllowedCharSet.addAll(checkAndSortChars(allowedChars, "allowedChars"));
+            return this;
+        }
+
+        /**
+         * Declares that at least as many characters as specified must exist in the password,
+         * drawn from the provided set. The character set must not overlap with any
+         * other required character set, and must be a subset of the allowed character set.
+         *
+         * @param requiredChars A set of characters from which the required count will be selected.
+         *     Duplicate characters will be ignored.
+         * @param count The number of characters which will be selected from the required character
+         *     set. Must be at least 1.
+         * @throws InvalidSpecificationError if the string is null or empty, contains
+         *     characters which are not in the ascii printable range, or exist within another
+         *     required set of characters.
+         */
+        public Builder require(@NonNull String requiredChars, int count) {
+            if (count < 1) {
+                throw new InvalidSpecificationError("count must be at least 1");
+            }
+
+            TreeSet<Character> requiredCharSet = checkAndSortChars(requiredChars, "requiredChars");
+            mAllowedCharSet.addAll(requiredCharSet);
+            mRequiredCharSets.add(
+                    new RequiredCharSet(
+                            charCollectionToString(requiredCharSet),
+                            count));
+            return this;
+        }
+
+        /**
+         * Declares that the password must be within a certain size range.
+         * @param minimumSize
+         *     The minimum size of the password. Must be at least 1.
+         * @param  maximumSize
+         *     The maximum size of the password. Must be at least as large as {@code minimumSize}.
+         */
+        public Builder ofLength(int minimumSize, int maximumSize) {
+            if (minimumSize < 1) {
+                throw new InvalidSpecificationError("minimumSize must be at least 1");
+            }
+
+            if (minimumSize > maximumSize) {
+                throw new InvalidSpecificationError(
+                        "maximumSize must be greater than or equal to minimumSize");
+            }
+
+            mMinimumSize = minimumSize;
+            mMaximumSize = maximumSize;
+
+            return this;
+        }
+
+        /**
+         * Produces a {@link PasswordSpecification} instance, if the configuration specified on the
+         * builder is valid.
+         *
+         * @throws InvalidSpecificationError if the specification is invalid.
+         */
+        public PasswordSpecification build() {
+            if (mAllowedCharSet.isEmpty()) {
+                throw new InvalidSpecificationError("no allowed characters specified");
+            }
+
+            if (mMinimumSize < 0) {
+                // the length of the password was never set
+                throw new InvalidSpecificationError(
+                        "minimum and maximum size of password not specified");
+            }
+
+            checkRequiredCharsTotalCount();
+            checkRequiredCharsDisjoint();
+
+            return new PasswordSpecification(
+                    charCollectionToString(mAllowedCharSet),
+                    mRequiredCharSets,
+                    mMinimumSize,
+                    mMaximumSize);
+        }
+
+        private TreeSet<Character> checkAndSortChars(String chars, String paramName) {
+            if (TextUtils.isEmpty(chars)) {
+                throw new InvalidSpecificationError(paramName + " cannot be null or empty");
+            }
+
+            TreeSet<Character> filteredChars = new TreeSet<>();
+
+            for (char c : chars.toCharArray()) {
+                if (isOutsideRange(c, ASCII_PRINTABLE_RANGE_LOWER, ASCII_PRINTABLE_RANGE_UPPER)) {
+                    throw new InvalidSpecificationError(
+                            paramName + " must only contain ASCII printable characters");
+                }
+                filteredChars.add(c);
+            }
+
+            return filteredChars;
+        }
+
+        private void checkRequiredCharsTotalCount() {
+            int count = 0;
+            for (RequiredCharSet set : mRequiredCharSets) {
+                count += set.count;
+            }
+
+            if (count > mMaximumSize) {
+                throw new InvalidSpecificationError(
+                        "required character count cannot be greater than the max password size");
+            }
+        }
+
+        private void checkRequiredCharsDisjoint() {
+            boolean[] charsUsed =
+                    new boolean[ASCII_PRINTABLE_RANGE_UPPER - ASCII_PRINTABLE_RANGE_LOWER + 1];
+
+            for (RequiredCharSet set : mRequiredCharSets) {
+                for (char c : set.chars.toCharArray()) {
+                    if (charsUsed[c - ASCII_PRINTABLE_RANGE_LOWER]) {
+                        throw new InvalidSpecificationError("character " + c
+                                + " occurs in more than one required character set");
+                    }
+                    charsUsed[c - ASCII_PRINTABLE_RANGE_LOWER] = true;
+                }
+            }
+        }
+    }
+
+    /**
+     * The error type that is thrown in an attempt is made to construct an invalid specification.
+     */
+    public static class InvalidSpecificationError extends Error {
+        /**
+         * Creates an InvalidSpecificationError with the provided reason.
+         */
+        public InvalidSpecificationError(String reason) {
+            super(reason);
+        }
+    }
+
+    /**
+     * Represents a required character set, where a password must contain at least as many
+     * characters as specified, drawn from the specified set.
+     */
+    private static final class RequiredCharSet implements Comparable<RequiredCharSet> {
+
+        /**
+         * The set of characters from which the required characters must be drawn.
+         */
+        public final String chars;
+
+        /**
+         * The minimum number of characters that must occur in the password, drawn from
+         * {@link #chars}.
+         */
+        public final int count;
+
+        private RequiredCharSet(String chars, int count) {
+            this.chars = chars;
+            this.count = count;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+
+            if (obj == null || !(obj instanceof RequiredCharSet)) {
+                return false;
+            }
+
+            RequiredCharSet other = (RequiredCharSet) obj;
+            return this.chars.equals(other.chars) && this.count == other.count;
+        }
+
+        @Override
+        public int hashCode() {
+            return count * HASH_PRIME + chars.hashCode();
+        }
+
+        @Override
+        public int compareTo(@NonNull RequiredCharSet other) {
+            require(other, notNullValue());
+
+            // sort by count then chars
+            if (this.count < other.count) {
+                return -1;
+            }
+
+            if (this.count > other.count) {
+                return 1;
+            }
+
+            return chars.compareTo(other.chars);
+        }
+    }
+
+    private static final class PasswordSpecificationCreator
+            implements Creator<PasswordSpecification> {
+
+        @Override
+        public PasswordSpecification createFromParcel(Parcel parcel) {
+            int encodedSize = parcel.readInt();
+            byte[] encoded = new byte[encodedSize];
+            parcel.readByteArray(encoded);
+
+            org.openyolo.proto.PasswordSpecification proto;
+            try {
+                proto = org.openyolo.proto.PasswordSpecification.ADAPTER.decode(encoded);
+            } catch (IOException ex) {
+                throw new IllegalStateException("Unable to read proto from parcel", ex);
+            }
+
+            return new PasswordSpecification.Builder(proto).build();
+        }
+
+        @Override
+        public PasswordSpecification[] newArray(int size) {
+            return new PasswordSpecification[size];
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/ResultCallback.java b/api/java/org/openyolo/api/ResultCallback.java
new file mode 100644
index 0000000..a5ca480
--- /dev/null
+++ b/api/java/org/openyolo/api/ResultCallback.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+/**
+ * A callback handler for asynchronous call completion.
+ * @param <ResultT> The type of value returned when the operation completes normally.
+ * @param <ErrorT> The type of value returned when the operation fails unexpectedly.
+ */
+public interface ResultCallback<ResultT, ErrorT> {
+    /**
+     * Handles the result. If {@code error} has a non-null value, the operation failed.
+     */
+    void onComplete(ResultT result, ErrorT error);
+}
diff --git a/api/java/org/openyolo/api/RetrieveCallback.java b/api/java/org/openyolo/api/RetrieveCallback.java
new file mode 100644
index 0000000..b1d5c80
--- /dev/null
+++ b/api/java/org/openyolo/api/RetrieveCallback.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+/**
+ * Asyncronous callback type for credential retrieval.
+ */
+public interface RetrieveCallback extends ResultCallback<RetrieveResult, Throwable> {}
diff --git a/api/java/org/openyolo/api/RetrieveRequest.java b/api/java/org/openyolo/api/RetrieveRequest.java
new file mode 100644
index 0000000..c29618a
--- /dev/null
+++ b/api/java/org/openyolo/api/RetrieveRequest.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static java.util.Collections.unmodifiableMap;
+import static java.util.Collections.unmodifiableSet;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.api.AuthenticationDomain.CONVERTER_DOMAIN_TO_STRING;
+import static org.openyolo.api.AuthenticationDomain.CONVERTER_STRING_TO_DOMAIN;
+import static org.openyolo.api.internal.CollectionConverter.toList;
+import static org.openyolo.api.internal.CollectionConverter.toMap;
+import static org.openyolo.api.internal.CollectionConverter.toSet;
+import static org.openyolo.api.internal.CustomMatchers.isValidAuthenticationMethod;
+import static org.openyolo.api.internal.CustomMatchers.notNullOrEmptyString;
+import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP;
+import static org.openyolo.api.internal.KeyValuePairConverters.CONVERTER_KVP_TO_PAIR;
+import static org.openyolo.api.internal.UriConverters.CONVERTER_STRING_TO_URI;
+import static org.openyolo.api.internal.UriConverters.CONVERTER_URI_TO_STRING;
+import static org.valid4j.Assertive.require;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.openyolo.api.internal.NoopValueConverter;
+import org.openyolo.proto.CredentialRetrieveRequest;
+
+/**
+ * A request for credentials, to be sent to credential providers on the device. A request specifies
+ * at least one {@link AuthenticationDomain authentication domain} for which a credential is
+ * required.
+ */
+public class RetrieveRequest implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link RetrieveRequest} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<RetrieveRequest> CREATOR = new RetrieveRequestCreator();
+
+    /**
+     * Creates a basic retrieve request for the current application.
+     */
+    public static RetrieveRequest forSelf(Context context) {
+        return new RetrieveRequest.Builder(AuthenticationDomain.getSelfAuthDomain(context))
+                .build();
+    }
+
+    @NonNull
+    private final Set<AuthenticationDomain> mAuthDomains;
+
+    @NonNull
+    private final Set<Uri> mAuthMethods;
+
+    @NonNull
+    private final Map<String, byte[]> mAdditionalParams;
+
+    private RetrieveRequest(
+            @NonNull Set<AuthenticationDomain> authDomains,
+            @NonNull Set<Uri> authMethods,
+            @NonNull Map<String, byte[]> additionalParams) {
+        mAuthDomains = authDomains;
+        mAuthMethods = authMethods;
+        mAdditionalParams = additionalParams;
+    }
+
+    /**
+     * The set of authentication domains for which a credential is desired. It is the
+     * responsibility of the credential provider to validate that the requester is permitted to
+     * retrieve credentials for this set of domains, and how to interpret requests for domains
+     * which are beyond the provably associated scope of the requester.
+     */
+    @NonNull
+    public Set<AuthenticationDomain> getAuthenticationDomains() {
+        return mAuthDomains;
+    }
+
+    /**
+     * The set of authentication methods that the requestor supports. This is used to filter the
+     * set of credentials saved by the provider. If no authentication methods are specified, then
+     * no filtering of saved credentials will occur.
+     */
+    @NonNull
+    public Set<Uri> getAuthenticationMethods() {
+        return mAuthMethods;
+    }
+
+    /**
+     * The map of additional, non-standard properties included with this request.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalParameters() {
+        return mAdditionalParams;
+    }
+
+    /**
+     * Retrieves the value of the named additional parameter, where the value is a UTF-8
+     * encoded string.
+     */
+    @Nullable
+    public String getAdditionalParameterAsString(@NonNull String key) {
+        require(key, notNullValue());
+        if (mAdditionalParams.containsKey(key)) {
+            return new String(mAdditionalParams.get(key), Charset.forName("UTF-8"));
+        }
+        return null;
+    }
+
+    /**
+     * Retrieves the raw, byte-array value of the named additional parameter.
+     */
+    @Nullable
+    public byte[] getAdditionalParameter(@NonNull String key) {
+        require(key, notNullValue());
+        return mAdditionalParams.get(key);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        byte[] protoBytes = toProtocolBuffer().encode();
+        dest.writeInt(protoBytes.length);
+        dest.writeByteArray(protoBytes);
+    }
+
+    /**
+     * Converts the request into a protocol buffer, for storage or transmission.
+     */
+    public CredentialRetrieveRequest toProtocolBuffer() {
+        return new CredentialRetrieveRequest.Builder()
+                .authDomains(toList(mAuthDomains, CONVERTER_DOMAIN_TO_STRING))
+                .authMethods(toList(mAuthMethods, CONVERTER_URI_TO_STRING))
+                .additionalParams(toList(mAdditionalParams.entrySet(), CONVERTER_ENTRY_TO_KVP))
+                .build();
+    }
+
+    /**
+     * Creates {@link RetrieveRequest} instances.
+     */
+    public static final class Builder {
+
+        private Set<AuthenticationDomain> mAuthDomains = new HashSet<>();
+        private Set<Uri> mAuthMethods = new HashSet<>();
+        private Map<String, byte[]> mAdditionalParams = new HashMap<>();
+
+        /**
+         * Starts the process of creating a retrieve request using the data contained in
+         * the provided protocol buffer representation.
+         */
+        public Builder(@NonNull CredentialRetrieveRequest requestProto) {
+            require(requestProto, notNullValue());
+            setAuthenticationDomains(toSet(requestProto.authDomains, CONVERTER_STRING_TO_DOMAIN));
+            setAuthenticationMethods(toSet(requestProto.authMethods, CONVERTER_STRING_TO_URI));
+            setAdditionalParameters(toMap(requestProto.additionalParams, CONVERTER_KVP_TO_PAIR));
+        }
+
+        /**
+         * Starts the process of describing a retrieve request, providing the set of authentication
+         * domains for which a credential is desired. At least one authentication domain is
+         * required.
+         */
+        public Builder(
+                @NonNull AuthenticationDomain authDomain,
+                @NonNull AuthenticationDomain... additionalAuthDomains) {
+            setAuthenticationDomains(authDomain, additionalAuthDomains);
+        }
+
+        /**
+         * Starts the process of describing a retrieve request, providing the set of authentication
+         * domains (in the form of URI strings) for which a credential is desired. At least one
+         * authentication domain is required.
+         */
+        public Builder(
+                @NonNull String authDomain,
+                @NonNull String... additionalAuthDomains) {
+            setAuthenticationDomains(authDomain, additionalAuthDomains);
+        }
+
+        /**
+         * Starts the process of describing a retrieve request, with the mandatory list
+         * of authentication domains specified. The list must be non-null, with non-null entries.
+         */
+        public Builder(@NonNull Set<AuthenticationDomain> authDomains) {
+            setAuthenticationDomains(authDomains);
+        }
+
+        /**
+         * Specifies the authentication domain(s) for which a credential is desired.
+         * At least one must be specified. All values specified must be non-null.
+         */
+        @NonNull
+        public Builder setAuthenticationDomains(
+                @NonNull AuthenticationDomain authDomain,
+                @NonNull AuthenticationDomain... additionalAuthDomains) {
+            setAuthenticationDomains(toSet(
+                    authDomain,
+                    additionalAuthDomains,
+                    NoopValueConverter.<AuthenticationDomain>getInstance()));
+            return this;
+        }
+
+        /**
+         * Specifies the authentication domain(s) for which a credential is desired, in the
+         * form of URI strings. At least one value must be specified. All values specified must be
+         * non-null.
+         */
+        @NonNull
+        public Builder setAuthenticationDomains(
+                @NonNull String authDomain,
+                @NonNull String... authDomainStrs) {
+            setAuthenticationDomains(toSet(
+                    authDomain,
+                    authDomainStrs,
+                    CONVERTER_STRING_TO_DOMAIN));
+            return this;
+        }
+
+        /**
+         * Specifies the authentication domains from which a credential is desired.
+         * Must not be null. Must contain at least one value.
+         */
+        @NonNull
+        public Builder setAuthenticationDomains(@NonNull Set<AuthenticationDomain> authDomains) {
+            require(authDomains, notNullValue());
+            require(!authDomains.isEmpty(), "at least one authentication domain must be specified");
+            require(authDomains, everyItem(notNullValue()));
+            mAuthDomains = authDomains;
+            return this;
+        }
+
+        /**
+         * Specifies the authentication methods supported by the requester. If no values are
+         * specified, then any stored credential matching the set of specified authentication
+         * domains may be returned. All provided values must be non-null.
+         */
+        @NonNull
+        public Builder setAuthenticationMethods(@NonNull Uri... authMethods) {
+            setAuthenticationMethods(
+                    toSet(null, authMethods, NoopValueConverter.<Uri>getInstance()));
+            return this;
+        }
+
+        /**
+         * Specifies the authentication methods supported by the requester. If no values are
+         * specified, then any stored credential matching the set of specified authentication
+         * domains may be returned. The provided set must be non-null, and contain only
+         * non-null values.
+         */
+        public Builder setAuthenticationMethods(@NonNull Set<Uri> authMethods) {
+            require(authMethods, notNullValue());
+            require(authMethods, everyItem(isValidAuthenticationMethod()));
+            mAuthMethods = authMethods;
+            return this;
+        }
+
+        /**
+         * Specifies additional, non-standard retrieve request parameters. The provided map
+         * must be non-null, and contain only non-null keys and values.
+         */
+        public Builder setAdditionalParameters(
+                @NonNull Map<String, byte[]> additionalParams) {
+            require(additionalParams, notNullValue());
+            require(additionalParams.keySet(), everyItem(notNullOrEmptyString()));
+            require(additionalParams.values(), everyItem(notNullValue()));
+            mAdditionalParams = additionalParams;
+            return this;
+        }
+
+        /**
+         * Adds an additional parameter, where the value will be encoded as a UTF-8 string.
+         * Both the parameter name and value must be non-null.
+         * @see {@link RetrieveRequest#getAdditionalParameterAsString(String)}
+         */
+        public Builder addAdditionalParameter(
+                @NonNull String name,
+                @NonNull String value) {
+            require(value, notNullValue());
+            addAdditionalParameter(name, value.getBytes(Charset.forName("UTF-8")));
+            return this;
+        }
+
+        /**
+         * Adds an additional parameter. Both the parameter name and value must be non-null.
+         */
+        public Builder addAdditionalParameter(String name, byte[] value) {
+            require(name, notNullOrEmptyString());
+            require(value, notNullValue());
+            mAdditionalParams.put(name, value);
+            return this;
+        }
+
+        /**
+         * Creates a {@link RetrieveRequest} using the properties set on the builder.
+         */
+        @NonNull
+        public RetrieveRequest build() {
+            return new RetrieveRequest(
+                    unmodifiableSet(mAuthDomains),
+                    unmodifiableSet(mAuthMethods),
+                    unmodifiableMap(mAdditionalParams));
+        }
+    }
+
+    private static final class RetrieveRequestCreator implements Creator<RetrieveRequest> {
+        @Override
+        public RetrieveRequest createFromParcel(Parcel in) {
+
+            int protoLength = in.readInt();
+            byte[] protoBytes = new byte[protoLength];
+            in.readByteArray(protoBytes);
+
+            try {
+                return new RetrieveRequest.Builder(
+                        CredentialRetrieveRequest.ADAPTER.decode(protoBytes))
+                        .build();
+            } catch (IOException ex) {
+                throw new IllegalStateException("Unable to read proto from parcel", ex);
+            }
+        }
+
+        @Override
+        public RetrieveRequest[] newArray(int size) {
+            return new RetrieveRequest[size];
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/RetrieveResult.java b/api/java/org/openyolo/api/RetrieveResult.java
new file mode 100644
index 0000000..6894108
--- /dev/null
+++ b/api/java/org/openyolo/api/RetrieveResult.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.openyolo.api.internal.CollectionConverter;
+import org.openyolo.api.internal.IntentUtil;
+import org.openyolo.api.internal.KeyValuePairConverters;
+import org.openyolo.proto.CredentialRetrieveResponse;
+
+/**
+ * A response to a {@link RetrieveRequest credential retrieve request}.
+ */
+public class RetrieveResult implements Parcelable {
+
+    /**
+     * Parcelable reader for {@link RetrieveResult} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<RetrieveResult> CREATOR = new RetrieveResultCreator();
+
+    @Nullable
+    private final Intent mRetrieveIntent;
+
+    @NonNull
+    private final Map<String, CredentialRetrieveResponse> mResponses;
+
+    private RetrieveResult(
+            @Nullable Intent retrieveIntent,
+            @NonNull Map<String, CredentialRetrieveResponse> responses) {
+        mRetrieveIntent = retrieveIntent;
+        mResponses = responses;
+    }
+
+    /**
+     * An intent that can be used to retrieve a credential for the calling app. If no credentials
+     * are available, this will be {@code null}. User input may or may not be required to retrieve
+     * the credential, at the discretion of the credential provider. The retrieve intent
+     * should be fired when the app is ready to retrieve the credential - typically immediately
+     * after the retrieve result is received.
+     */
+    @Nullable
+    public Intent getRetrieveIntent() {
+        return mRetrieveIntent;
+    }
+
+    /**
+     * The package names of responding credential providers that indicated they may have a usable
+     * credential.
+     */
+    @NonNull
+    public Set<String> getResponderPackageNames() {
+        return mResponses.keySet();
+    }
+
+    /**
+     * Retrieves the intent for the specified responder package name, if available.
+     */
+    @NonNull
+    public Intent getRetrieveIntentForResponder(@NonNull String responderPackageName) {
+        require(responderPackageName, notNullValue());
+        CredentialRetrieveResponse response = mResponses.get(responderPackageName);
+        if (response == null) {
+            throw new IllegalArgumentException(responderPackageName + " is not a responder");
+        }
+
+        return IntentUtil.fromBytes(response.retrieveIntent.toByteArray());
+    }
+
+    /**
+     * Retrieves the additional, non-standard response parameters for the specified responder
+     * package name, if available.
+     */
+    @NonNull
+    public Map<String, byte[]> getAdditionalParamsForResponder(String responderPackageName) {
+        CredentialRetrieveResponse response = mResponses.get(responderPackageName);
+        if (response == null) {
+            throw new IllegalArgumentException(responderPackageName + " is not a responder");
+        }
+
+        return CollectionConverter.toMap(
+                response.additionalParams,
+                KeyValuePairConverters.CONVERTER_KVP_TO_PAIR);
+    }
+
+    /**
+     * Creates {@link RetrieveResult} instances.
+     */
+    public static final class Builder {
+
+        @Nullable
+        private Intent mIntent;
+
+        @NonNull
+        private Map<String, CredentialRetrieveResponse> mProtoResponses;
+
+        /**
+         * Starts the process of describing a credential retrieve result.
+         */
+        public Builder() {
+            mIntent = null;
+            mProtoResponses = Collections.emptyMap();
+        }
+
+        /**
+         * Specifies the map of protocol buffer responses received for the credential request,
+         * keyed by the package name of the responder.
+         */
+        @NonNull
+        public Builder setProtoResponses(
+                @NonNull Map<String, CredentialRetrieveResponse> protoResponses) {
+            require(protoResponses, notNullValue());
+            for (CredentialRetrieveResponse value : protoResponses.values()) {
+                require(value, notNullValue());
+            }
+            mProtoResponses = protoResponses;
+            return this;
+        }
+
+        /**
+         * Specifies the retrieve intent, that can be used to retrieve existing credentials from
+         * the provider, if available.
+         */
+        @NonNull
+        public Builder setRetrieveIntent(@Nullable Intent intent) {
+            mIntent = intent;
+            return this;
+        }
+
+        /**
+         * Creates a {@link RetrieveResult} with the properties described to the builder.
+         */
+        @NonNull
+        public RetrieveResult build() {
+            return new RetrieveResult(mIntent, mProtoResponses);
+        }
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    static final class RetrieveResultCreator implements Creator<RetrieveResult> {
+        @Override
+        public RetrieveResult createFromParcel(Parcel in) {
+            return null;
+        }
+
+        @Override
+        public RetrieveResult[] newArray(int size) {
+            return new RetrieveResult[size];
+        }
+    }
+
+}
diff --git a/api/java/org/openyolo/api/internal/CollectionConverter.java b/api/java/org/openyolo/api/internal/CollectionConverter.java
new file mode 100644
index 0000000..e90411d
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/CollectionConverter.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import android.os.Build;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+import android.util.Pair;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Utility methods to convert collections to different types, while also potentially changing
+ * the types of the values themselves.
+ */
+public final class CollectionConverter {
+
+    /**
+     * Converts all the values in the provided collection, and adds them to a new set.
+     */
+    @NonNull
+    public static <T, U> Set<U> toSet(
+            @Nullable Collection<T> values,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        Set<U> result = createSet(values);
+        convert(values, result, valueConverter);
+        return result;
+    }
+
+    /**
+     * Converts all the provided values, and adds them to a new set.
+     */
+    @NonNull
+    public static <T, U> Set<U> toSet(
+            @Nullable T firstValue,
+            @Nullable T[] additionalValues,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        Set<U> result = createSet(firstValue, additionalValues);
+        convert(firstValue, additionalValues, result, valueConverter);
+        return result;
+    }
+
+    /**
+     * Converts all the values in the provided collection, and adds them to a new list.
+     */
+    @NonNull
+    public static <T, U> List<U> toList(
+            @Nullable Collection<T> values,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        List<U> result = createList(values);
+        convert(values, result, valueConverter);
+        return result;
+    }
+
+    /**
+     * Converts all the provided values, and adds them to a new set.
+     */
+    @NonNull
+    public static <T, U> List<U> toList(
+            @Nullable T firstValue,
+            @Nullable T[] values,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        List<U> result = createList(firstValue, values);
+        convert(firstValue, values, result, valueConverter);
+        return result;
+    }
+
+    /**
+     * Converts all the values in the provided collection, and adds them to a new map.
+     */
+    @NonNull
+    public static <T, U, V> Map<U, V> toMap(
+            @Nullable Collection<T> values,
+            @NonNull ValueConverter<T, Pair<U, V>> valueConverter) {
+        if (values == null) {
+            return Collections.emptyMap();
+        }
+
+        Map<U, V> result = createMap(values.size());
+        for (T value : values) {
+            Pair<U, V> converted = valueConverter.convert(value);
+            result.put(converted.first, converted.second);
+        }
+
+        return result;
+    }
+
+    private static <T, U> void convert(
+            @Nullable Collection<T> source,
+            @NonNull Collection<U> target,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        if (source == null) {
+            return;
+        }
+
+        for (T value : source) {
+            target.add(valueConverter.convert(value));
+        }
+    }
+
+    private static <T, U> void convert(
+            @Nullable T firstValue,
+            @Nullable T[] additionalValues,
+            @NonNull Collection<U> target,
+            @NonNull ValueConverter<T, U> valueConverter) {
+        if (firstValue == null && additionalValues == null) {
+            return;
+        }
+
+        if (firstValue != null) {
+            target.add(valueConverter.convert(firstValue));
+        }
+
+        if (additionalValues != null) {
+            for (T value : additionalValues) {
+                target.add(valueConverter.convert(value));
+            }
+        }
+    }
+
+    @NonNull
+    private static <T> Set<T> createSet(Collection collection) {
+        return createSet(collection != null ? collection.size() : 0);
+    }
+
+    @NonNull
+    private static <T, U> Set<T> createSet(U firstValue, U[] values) {
+        return createSet((firstValue != null ? 1 : 0)
+                + (values != null ? values.length : 0));
+    }
+
+    @NonNull
+    private static <T> Set<T> createSet(int size) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            return new ArraySet<>(size);
+        } else {
+            return new HashSet<>();
+        }
+    }
+
+    @NonNull
+    private static <T, U> List<T> createList(
+            @Nullable Collection<U> values) {
+        return createList(values != null ? values.size() : 0);
+    }
+
+    @NonNull
+    private static <T, U> List<T> createList(
+            @Nullable U firstValue,
+            @Nullable U[] additionalValues) {
+        return createList((firstValue != null ? 1 : 0)
+                + (additionalValues != null ? additionalValues.length : 0));
+    }
+
+    @NonNull
+    private static <T> List<T> createList(int size) {
+        return new ArrayList<>(size);
+    }
+
+    @NonNull
+    private static <T, U> Map<T, U> createMap(int size) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            return new ArrayMap<>(size);
+        } else {
+            return new HashMap<>();
+        }
+    }
+
+    private CollectionConverter() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/Constants.java b/api/java/org/openyolo/api/internal/Constants.java
new file mode 100644
index 0000000..22a8597
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/Constants.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+/**
+ * Internal constants used throughout the library.
+ */
+public class Constants {
+
+    /**
+     * A prime number for use in deriving hash codes.
+     */
+    public static final int HASH_PRIME = 92821;
+}
diff --git a/api/java/org/openyolo/api/internal/CustomMatchers.java b/api/java/org/openyolo/api/internal/CustomMatchers.java
new file mode 100644
index 0000000..717476c
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/CustomMatchers.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import android.net.Uri;
+import android.text.TextUtils;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.CustomTypeSafeMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+/**
+ * Convenient hamcrest-based input validators.
+ */
+public final class CustomMatchers {
+
+    /**
+     * Matcher for web URIs (http or https).
+     */
+    public static Matcher<Uri> isWebUri() {
+        return UriMatcher.WEB_MATCHER;
+    }
+
+    /**
+     * Matcher for HTTPS web URIs.
+     */
+    public static Matcher<Uri> isHttpsUri() {
+        return UriMatcher.HTTPS_ONLY_MATCHER;
+    }
+
+    /**
+     * Matcher for OpenYOLO authentication domains.
+     */
+    public static Matcher<Uri> isValidAuthenticationMethod() {
+        return UriMatcher.AUTHENTICATION_METHOD;
+    }
+
+    /**
+     * Matcher for OpenYOLO authentication domains.
+     */
+    public static Matcher<Uri> isValidAuthenticationDomain() {
+        return UriMatcher.AUTHENTICATION_DOMAIN;
+    }
+
+    public static Matcher<Uri> isValidIdentifierType() {
+        return UriMatcher.IDENTIFIER_TYPE;
+    }
+
+    /**
+     * Matcher for null values, or those which match the provided matcher.
+     */
+    public static <T> Matcher<T> nullOr(Matcher<T> matcher) {
+        return new NullOrOtherMatcher<>(matcher);
+    }
+
+    /**
+     * Matcher which only accepts non-null, non-empty strings.
+     */
+    public static Matcher<String> notNullOrEmptyString() {
+        return NotNullOrEmptyStringMatcher.INSTANCE;
+    }
+
+    private static final class NotNullOrEmptyStringMatcher extends BaseMatcher<String> {
+
+        private static final NotNullOrEmptyStringMatcher INSTANCE =
+                new NotNullOrEmptyStringMatcher();
+
+        @Override
+        public boolean matches(Object item) {
+            if (item == null) {
+                return false;
+            }
+
+            if (!(item instanceof String)) {
+                return false;
+            }
+
+            return !TextUtils.isEmpty((String)item);
+        }
+
+        @Override
+        public void describeTo(Description description) {
+            description.appendText("is not a null or empty string");
+        }
+    }
+
+    private static final class NullOrOtherMatcher<T> extends BaseMatcher<T> {
+
+        final Matcher<T> mMatcher;
+
+        NullOrOtherMatcher(Matcher<T> matcher) {
+            mMatcher = matcher;
+        }
+
+        @Override
+        public boolean matches(Object item) {
+            return item == null || mMatcher.matches(item);
+        }
+
+        @Override
+        public void describeTo(Description description) {
+            description.appendText("null or ").appendDescriptionOf(mMatcher);
+        }
+    }
+
+    private static final class UriMatcher extends CustomTypeSafeMatcher<Uri> {
+
+        static final String SCHEME_HTTP = "http";
+        static final String SCHEME_HTTPS = "https";
+
+        static final UriMatcher IDENTIFIER_TYPE = new UriMatcher(
+                Collections.<String>emptySet(),
+                false,
+                "an identifier type");
+
+        static final UriMatcher AUTHENTICATION_DOMAIN = new UriMatcher(
+                Collections.<String>emptySet(),
+                false,
+                "an authentication domain");
+
+        static final UriMatcher AUTHENTICATION_METHOD = new UriMatcher(
+                Collections.<String>emptySet(),
+                false,
+                "an authentication method");
+
+        static final UriMatcher HTTPS_ONLY_MATCHER = new UriMatcher(
+                Collections.singleton(SCHEME_HTTPS),
+                true,
+                "an https URL");
+
+        static final UriMatcher WEB_MATCHER = new UriMatcher(
+                new HashSet<>(Arrays.asList(SCHEME_HTTP, SCHEME_HTTPS)),
+                true,
+                "a web URL");
+
+        final Set<String> mPermittedSchemes;
+        final boolean mAllowPathQueryOrFragment;
+
+        UriMatcher(
+                Set<String> permittedSchemes,
+                boolean allowPathQueryOrFragment,
+                String uriDescriptor) {
+            super(uriDescriptor);
+            mPermittedSchemes = permittedSchemes;
+            mAllowPathQueryOrFragment = allowPathQueryOrFragment;
+        }
+
+        @Override
+        protected boolean matchesSafely(Uri item) {
+            if (!item.isAbsolute()
+                    || !item.isHierarchical()
+                    || TextUtils.isEmpty(item.getScheme())
+                    || TextUtils.isEmpty(item.getAuthority())) {
+                return false;
+            }
+
+            if (!mPermittedSchemes.isEmpty() && !mPermittedSchemes.contains(item.getScheme())) {
+                return false;
+            }
+
+            if (mAllowPathQueryOrFragment) {
+                return true;
+            }
+
+            return TextUtils.isEmpty(item.getPath())
+                    && item.getQuery() == null
+                    && item.getFragment() == null;
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/IntentUtil.java b/api/java/org/openyolo/api/internal/IntentUtil.java
new file mode 100644
index 0000000..d7a92ff
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/IntentUtil.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.ensure;
+import static org.valid4j.Assertive.require;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.support.annotation.NonNull;
+
+/**
+ * Utilities for manipulating intents for use in protocol buffers.
+ */
+public final class IntentUtil {
+
+    private IntentUtil() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+
+    /**
+     * Serializes the provided intent to a byte array.
+     */
+    @NonNull
+    public static byte[] toBytes(@NonNull Intent intent) {
+        require(intent, notNullValue());
+
+        Parcel parcel = Parcel.obtain();
+        parcel.writeParcelable(intent, 0);
+        byte[] intentBytes = parcel.marshall();
+        parcel.recycle();
+
+        return intentBytes;
+    }
+
+    /**
+     * Deserializes an intent from the provided bytes array.
+     */
+    @NonNull
+    public static Intent fromBytes(@NonNull byte[] intentBytes) {
+        require(intentBytes, notNullValue());
+
+        Parcel parcel = Parcel.obtain();
+        parcel.unmarshall(intentBytes, 0, intentBytes.length);
+        parcel.setDataPosition(0);
+        Intent intent = parcel.readParcelable(IntentUtil.class.getClassLoader());
+        parcel.recycle();
+
+        ensure(intent, notNullValue());
+        return intent;
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/KeyValuePairConverters.java b/api/java/org/openyolo/api/internal/KeyValuePairConverters.java
new file mode 100644
index 0000000..35e7e53
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/KeyValuePairConverters.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import android.util.Pair;
+import java.util.Collection;
+import java.util.Map;
+import okio.ByteString;
+import org.openyolo.proto.KeyValuePair;
+
+/**
+ * Utility methods for converting between the {@link KeyValuePair} type used in OpenYOLO protocol
+ * buffers and {@link Pair} as a more generic equivalent.
+ */
+public final class KeyValuePairConverters {
+
+    private KeyValuePairConverters() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+
+    /**
+     * Converts {@link KeyValuePair} instances to {@link Pair} instances, typically for use by
+     * {@link CollectionConverter#toMap(Collection, ValueConverter)}.
+     */
+    public static final ValueConverter<KeyValuePair, Pair<String, byte[]>> CONVERTER_KVP_TO_PAIR =
+            new ValueConverter<KeyValuePair, Pair<String, byte[]>>() {
+                @Override
+                public Pair<String, byte[]> convert(KeyValuePair value) {
+                    return new Pair<>(value.name, value.value.toByteArray());
+                }
+            };
+
+    /**
+     * Converts {@link java.util.Map.Entry} instances to {@link KeyValuePair} instances.
+     */
+    public static final ValueConverter<Map.Entry<String, byte[]>, KeyValuePair>
+            CONVERTER_ENTRY_TO_KVP =
+            new ValueConverter<Map.Entry<String, byte[]>, KeyValuePair>() {
+                @Override
+                public KeyValuePair convert(Map.Entry<String, byte[]> value) {
+                    return new KeyValuePair(value.getKey(), ByteString.of(value.getValue()));
+                }
+            };
+}
diff --git a/api/java/org/openyolo/api/internal/NoopValueConverter.java b/api/java/org/openyolo/api/internal/NoopValueConverter.java
new file mode 100644
index 0000000..7c56d34
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/NoopValueConverter.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+/**
+ * Returns the provided value as-is. Useful for performing collection type conversion where
+ * the values do not change.
+ */
+public final class NoopValueConverter<T> implements ValueConverter<T, T> {
+
+    private static final NoopValueConverter INSTANCE = new NoopValueConverter();
+
+    /**
+     * The singleton instance of {@link NoopValueConverter}.
+     */
+    public static <T> NoopValueConverter<T> getInstance() {
+        return INSTANCE;
+    }
+
+    @Override
+    public T convert(T value) {
+        return value;
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/UriConverters.java b/api/java/org/openyolo/api/internal/UriConverters.java
new file mode 100644
index 0000000..00ae829
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/UriConverters.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.net.Uri;
+
+/**
+ * Utility methods for parsing and validating URIs used in OpenYOLO.
+ */
+public final class UriConverters {
+
+    /**
+     * Converts strings to Uri instances.
+     */
+    public static final ValueConverter<String, Uri> CONVERTER_STRING_TO_URI =
+            new ValueConverter<String, Uri>() {
+                @Override
+                public Uri convert(String value) {
+                    require(value, notNullValue());
+                    return Uri.parse(value);
+                }
+            };
+
+    /**
+     * Converts Uri instacnes to strings.
+     */
+    public static final ValueConverter<Uri, String> CONVERTER_URI_TO_STRING =
+            new ValueConverter<Uri, String>() {
+                @Override
+                public String convert(Uri value) {
+                    require(value, notNullValue());
+                    return value.toString();
+                }
+            };
+
+    private UriConverters() {
+        throw new IllegalStateException("not intended to be constructed");
+    }
+}
diff --git a/api/java/org/openyolo/api/internal/ValueConverter.java b/api/java/org/openyolo/api/internal/ValueConverter.java
new file mode 100644
index 0000000..0579f9c
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/ValueConverter.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.internal;
+
+/**
+ * Simple abstraction that converts values of type T into values of type U.
+ */
+public interface ValueConverter<T, U> {
+    /**
+     * Converts a single value.
+     */
+    U convert(T value);
+}
diff --git a/api/java/org/openyolo/api/internal/package-info.java b/api/java/org/openyolo/api/internal/package-info.java
new file mode 100644
index 0000000..064ceef
--- /dev/null
+++ b/api/java/org/openyolo/api/internal/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * The contents of this package are not part of the official API; use at your own risk.
+ */
+package org.openyolo.api.internal;
diff --git a/api/java/org/openyolo/api/package-info.java b/api/java/org/openyolo/api/package-info.java
new file mode 100644
index 0000000..6df6da0
--- /dev/null
+++ b/api/java/org/openyolo/api/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * API for apps to interact with credential managers on the user's device.
+ */
+package org.openyolo.api;
diff --git a/api/java/org/openyolo/api/ui/ProviderPickerActivity.java b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
new file mode 100644
index 0000000..7959249
--- /dev/null
+++ b/api/java/org/openyolo/api/ui/ProviderPickerActivity.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api.ui;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.ColorRes;
+import android.support.annotation.DimenRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.StringRes;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.api.KnownProviders;
+import org.openyolo.api.R;
+
+/**
+ * Activity which presents the list of providers that claim to have a credential available.
+ * The user can select one of these options, which fires the associated intent for that provider,
+ * or cancel the whole operation.
+ */
+public class ProviderPickerActivity extends AppCompatActivity {
+
+    private static final String EXTRA_PROVIDER_INTENTS = "providerIntents";
+    private static final String EXTRA_TITLE_RES = "titleRes";
+    private static final String LOG_TAG = "ProviderPicker";
+
+    private CredentialClient mClient;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.picker_layout);
+
+        Rect rectangle = new Rect();
+        Window window = getWindow();
+        window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
+
+        Resources res = getResources();
+        @DimenRes int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
+        int statusBarHeight = 0;
+        if (resourceId > 0) {
+            statusBarHeight = res.getDimensionPixelSize(resourceId);
+        }
+
+        getWindow().setLayout(
+                rectangle.width(),
+                rectangle.height() - statusBarHeight);
+
+        TextView titleView = (TextView) findViewById(R.id.picker_title);
+        @StringRes int titleRes = getIntent().getIntExtra(EXTRA_TITLE_RES, 0);
+        if (titleRes != 0) {
+            //robotium has an issue recovering resources in the shadow classes.
+            titleView.setText(titleRes);
+        }
+
+        ListView providerView = (ListView) findViewById(R.id.provider_list);
+        List<Intent> retrieveIntents =
+                getIntent().getParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS);
+        if (retrieveIntents == null) {
+            retrieveIntents = Collections.EMPTY_LIST;
+        }
+        providerView.setAdapter(new ProviderAdapter(retrieveIntents));
+    }
+
+    /**
+     * Creates an intent for the picker activity, showing the user the list of credential providers
+     * that can be used for the operation identified by the specified title text.
+     */
+    private static Intent createIntent(
+            @NonNull Context context,
+            @NonNull ArrayList<Intent> providerIntents,
+            @StringRes int titleRes) {
+        require(context, notNullValue());
+        Intent intent = new Intent(context, ProviderPickerActivity.class);
+        intent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, providerIntents);
+        intent.putExtra(EXTRA_TITLE_RES, titleRes);
+        return intent;
+    }
+
+    /**
+     * Creates an intent for displaying a list of providers that claim to have a credential for
+     * the current app, allowing the user to choose which to use.
+     */
+    public static Intent createRetrieveIntent(
+            @NonNull Context context,
+            @NonNull ArrayList<Intent> retrieveIntents) {
+        return createIntent(context, retrieveIntents, R.string.retrieve_picker_prompt);
+    }
+
+    /**
+     * Creates an intent for displaying a list of providers that can save a credential for the
+     * user.
+     */
+    public static Intent createSaveIntent(
+            @NonNull Context context,
+            @NonNull ArrayList<Intent> retrieveIntents) {
+        return createIntent(context, retrieveIntents, R.string.save_picker_prompt);
+    }
+
+    /**
+     * Creates an intent for displaying a list of providers that can provide a login hint for
+     * the current app, allowing the user to choose which to use.
+     */
+    public static Intent createHintIntent(
+            @NonNull Context context,
+            @NonNull ArrayList<Intent> hintIntents) {
+        return createIntent(context, hintIntents, R.string.hint_picker_prompt);
+    }
+
+    private final class ProviderAdapter extends ArrayAdapter<Intent> {
+
+        private final List<Drawable> mProviderIcons;
+        private final List<String> mProviderNames;
+        private final List<Boolean> mProviderKnown;
+
+        ProviderAdapter(List<Intent> providerIntents) {
+            super(ProviderPickerActivity.this, 0, providerIntents);
+            mProviderIcons = new ArrayList<>(providerIntents.size());
+            mProviderNames = new ArrayList<>(providerIntents.size());
+            mProviderKnown = new ArrayList<>(providerIntents.size());
+
+            KnownProviders knownProviders = KnownProviders.getApplicationBoundInstance(
+                    ProviderPickerActivity.this.getApplicationContext());
+            PackageManager pm = getPackageManager();
+            for (Intent providerIntent : providerIntents) {
+                try {
+                    String packageName = providerIntent.getComponent().getPackageName();
+                    ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
+                    mProviderIcons.add(info.loadIcon(pm));
+                    mProviderNames.add(pm.getApplicationLabel(info).toString());
+                    mProviderKnown.add(knownProviders.isKnown(packageName));
+                } catch (PackageManager.NameNotFoundException e) {
+                    Log.wtf(LOG_TAG, "Failed to retrieve package info for intent");
+                }
+            }
+        }
+
+        @Override
+        public View getView(int position, View itemView, ViewGroup parent) {
+            final Intent providerIntent = getItem(position);
+            if (itemView == null) {
+                itemView = LayoutInflater.from(ProviderPickerActivity.this)
+                        .inflate(R.layout.provider_item, parent, false);
+            }
+
+            ImageView providerIconView = (ImageView) itemView.findViewById(R.id.provider_icon);
+            TextView providerNameView = (TextView) itemView.findViewById(R.id.provider_name);
+            TextView providerUnsafe =
+                    (TextView) itemView.findViewById(R.id.unsafe_provider_warning);
+
+            providerIconView.setImageDrawable(mProviderIcons.get(position));
+            providerNameView.setText(mProviderNames.get(position));
+
+            if (mProviderKnown.get(position)) {
+                providerUnsafe.setVisibility(View.GONE);
+            } else {
+                providerUnsafe.setVisibility(View.VISIBLE);
+            }
+
+            itemView.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    providerIntent.setFlags(
+                            providerIntent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+                    startActivity(providerIntent);
+                    finish();
+                }
+            });
+            return itemView;
+        }
+
+        @SuppressWarnings("deprecation")
+        private int getColor(@ColorRes int colorRes) {
+            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
+                return getResources().getColor(colorRes, null);
+            } else {
+                return getResources().getColor(colorRes);
+            }
+        }
+    }
+}
diff --git a/api/java/org/openyolo/api/ui/package-info.java b/api/java/org/openyolo/api/ui/package-info.java
new file mode 100644
index 0000000..e1e5bab
--- /dev/null
+++ b/api/java/org/openyolo/api/ui/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * UI support activities for OpenYOLO.
+ */
+package org.openyolo.api.ui;
diff --git a/api/javatests/org/openyolo/api/AuthenticationDomainTest.java b/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
new file mode 100644
index 0000000..6e8ca86
--- /dev/null
+++ b/api/javatests/org/openyolo/api/AuthenticationDomainTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openyolo.api.internal.CollectionConverter;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class AuthenticationDomainTest {
+
+    private static final String SELF_PACKAGE_NAME = "com.example.app";
+
+    private byte[] sigBytes = new byte[]
+            { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+
+    private String sigSha512HashBase64 =
+            "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8"
+                    + "7V4Lo8BdCxaA307H0HYkAw==";
+    private PackageInfo packageInfo;
+
+    @Mock
+    PackageManager mockPackageManager;
+    @Mock
+    Context mockContext;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        packageInfo = new PackageInfo();
+        packageInfo.signatures = new Signature[2];
+        packageInfo.signatures[0] = new Signature(sigBytes);
+        packageInfo.signatures[1] = new Signature(new byte[16]);
+
+        when(mockPackageManager.getPackageInfo("com.example.app", PackageManager.GET_SIGNATURES))
+                .thenReturn(packageInfo);
+
+        when(mockContext.getPackageName()).thenReturn(SELF_PACKAGE_NAME);
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+
+    }
+
+    @Test
+    public void testGetSelfAuthDomain() throws Exception {
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        assertThat(authDomain).isNotNull();
+        assertThat(authDomain.isAndroidAuthDomain()).isTrue();
+        assertThat(authDomain.toString())
+                .isEqualTo("android://" + sigSha512HashBase64 + "@com.example.app");
+    }
+
+    @Test
+    public void testListForPackage() {
+        assertThat(AuthenticationDomain.listForPackage(mockContext, "com.example.app")).contains(
+                new AuthenticationDomain("android://" + sigSha512HashBase64 + "@com.example.app"));
+    }
+
+    @Test
+    public void testListForPackage_nullPackageName() throws Exception {
+        assertThat(AuthenticationDomain.listForPackage(mockContext, null)).isEmpty();
+    }
+
+    @Test
+    public void testEquals() throws Exception {
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        AuthenticationDomain authDomain2 = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        assertTrue(authDomain.equals(authDomain2));
+    }
+
+    @Test
+    public void testEquals_differentType() throws Exception {
+        AuthenticationDomain domain = new AuthenticationDomain("https://www.example.com");
+        assertFalse(domain.equals("https://www.example.com"));
+    }
+
+    @Test
+    public void testGetUri() throws Exception{
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        String expectedUri = "android://" +
+                "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_" +
+                "Uhps_I87V4Lo8BdCxaA307H0HYkAw==@com.example.app";
+        assertEquals(expectedUri, authDomain.getUri().toString());
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testCreateAndroidAuthDomain_nullDomain() throws Exception{
+        AuthenticationDomain.createAndroidAuthDomain(null, new Signature(""));
+    }
+
+    @Test
+    public void testIsWebAuthDomain(){
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        assertFalse(authDomain.isWebAuthDomain());
+    }
+
+    @Test
+    public void testGetAndroidPackageName(){
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        assertEquals("com.example.app", authDomain.getAndroidPackageName());
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testGetAndroidPackageName_fromWebDomain() {
+        AuthenticationDomain authDomain = new AuthenticationDomain("https://www.example.com");
+        authDomain.getAndroidPackageName();
+    }
+
+    @Test
+    public void stringsToAuthDomains() throws Exception {
+        List<String> domains = new ArrayList<>();
+        domains.add("https://www.google.com");
+        domains.add("https://www.yahoo.com");
+        domains.add("https://www.facebook.com");
+        List<AuthenticationDomain> result =
+                CollectionConverter.toList(
+                        domains,
+                        AuthenticationDomain.CONVERTER_STRING_TO_DOMAIN);
+        assertEquals(3, result.size());
+        assertEquals(result.get(0).getUri().toString(), domains.get(0));
+        assertEquals(result.get(1).getUri().toString(), domains.get(1));
+        assertEquals(result.get(2).getUri().toString(), domains.get(2));
+    }
+
+    @Test
+    public void testGetHashCode(){
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        assertEquals(authDomain.getUri().hashCode(), authDomain.hashCode());
+    }
+
+    @Test
+    public void testCompareTo(){
+        AuthenticationDomain authDomain = AuthenticationDomain.getSelfAuthDomain(mockContext);
+        AuthenticationDomain authDomain1 = AuthenticationDomain.getSelfAuthDomain(mockContext);
+
+        assertEquals(0, authDomain.compareTo(authDomain1));
+    }
+}
diff --git a/api/javatests/org/openyolo/api/CredentialClientTest.java b/api/javatests/org/openyolo/api/CredentialClientTest.java
new file mode 100644
index 0000000..14426ec
--- /dev/null
+++ b/api/javatests/org/openyolo/api/CredentialClientTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.TestCase.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.openyolo.api.AuthenticationMethods.ID_AND_PASSWORD;
+import static org.openyolo.api.CredentialClient.EXTRA_CREDENTIAL;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for CredentialClient
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class CredentialClientTest {
+    @Mock
+    private Context mockContext;
+
+    private CredentialClient underTest;
+    public static final String EMAIL_ID = "alice@example.com";
+    public static final AuthenticationDomain AUTH_DOMAIN =
+            new AuthenticationDomain("https://www.example.com");
+    private Credential testCredentials;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        underTest = new CredentialClient(mockContext);
+        when(mockContext.getApplicationContext()).thenReturn(mockContext);
+        testCredentials = new Credential.Builder(
+                EMAIL_ID,
+                ID_AND_PASSWORD,
+                new AuthenticationDomain("https://www.example.com")).build();
+
+    }
+
+    @Test
+    public void testGetApplicationBoundInstance() throws Exception {
+        CredentialClient test = CredentialClient.getApplicationBoundInstance(mockContext);
+        assertNotNull(test);
+    }
+
+    @Test
+    public void getSaveIntent() throws Exception {
+        PackageManager mockPackageManager = mock(PackageManager.class);
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+        List<ResolveInfo> response = new ArrayList<>();
+        ResolveInfo info = new ResolveInfo();
+        ActivityInfo mockActivityInfo = new ActivityInfo();
+        mockActivityInfo.packageName =  "com.dashlane";
+        mockActivityInfo.name =  "Dashlane";
+        info.activityInfo = mockActivityInfo;
+        response.add(info);
+        when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(response);
+
+        Intent i = underTest.getSaveIntent(testCredentials);
+        assertNotNull(i);
+        assertTrue(i.getExtras().getParcelableArrayList("providerIntents").size()==1);
+
+    }
+
+    @Test
+    public void getCredentialFromActivityResult_noExtras() throws Exception {
+        Intent intent = new Intent();
+
+        Credential result = underTest.getCredentialFromActivityResult(intent);
+        assertNull(result);
+    }
+
+    @Test
+    public void getCredentialFromActivityResult_withExtras() throws Exception {
+        Intent intent = new Intent();
+        byte[] array = org.openyolo.proto.Credential.ADAPTER.encode(testCredentials.getProto());
+        intent.putExtra(EXTRA_CREDENTIAL, array);
+        Credential result = underTest.getCredentialFromActivityResult(intent);
+        assertEquals(result.getIdentifier(), "alice@example.com");
+        assertEquals(result.getAuthenticationMethod().toString(), "openyolo://id-and-password");
+        assertEquals(result.getAuthenticationDomain().toString(), "https://www.example.com");
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/CredentialTest.java b/api/javatests/org/openyolo/api/CredentialTest.java
new file mode 100644
index 0000000..ff99883
--- /dev/null
+++ b/api/javatests/org/openyolo/api/CredentialTest.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.openyolo.api.AuthenticationMethods.ID_AND_PASSWORD;
+
+import android.net.Uri;
+import android.os.Parcel;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Tests for {@link Credential}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class CredentialTest {
+
+    public static final String EMAIL_ID = "alice@example.com";
+    public static final AuthenticationDomain AUTH_DOMAIN =
+            new AuthenticationDomain("https://www.example.com");
+
+    @Test(expected = RequireViolation.class)
+    @SuppressWarnings("ConstantConditions")
+    public void testBuilder_nullIdentifier() {
+        new Credential.Builder(null, ID_AND_PASSWORD, AUTH_DOMAIN);
+    }
+
+    @Test(expected = RequireViolation.class)
+    @SuppressWarnings("ConstantConditions")
+    public void testBuilder_nullAuthMethod() {
+        new Credential.Builder(EMAIL_ID, null, AUTH_DOMAIN);
+    }
+
+    @Test(expected = RequireViolation.class)
+    @SuppressWarnings("ConstantConditions")
+    public void testBuilder_nullAuthDomain() {
+        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, null);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_emptyIdentifier() {
+        new Credential.Builder("", ID_AND_PASSWORD, AUTH_DOMAIN);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_authMethodWithoutScheme() {
+        new Credential.Builder(EMAIL_ID, Uri.parse("www.example.com"), AUTH_DOMAIN);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_authMethodWithPath() {
+        new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com/path"), AUTH_DOMAIN);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_authMethodWithQuery() {
+        new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com?a=b"), AUTH_DOMAIN);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_authMethodWithFragment() {
+        new Credential.Builder(EMAIL_ID, Uri.parse("https://www.example.com#a"), AUTH_DOMAIN);
+    }
+
+    @Test
+    public void testBuilder_mandatoryPropsOnly() {
+        Credential cr = new Credential.Builder(
+                EMAIL_ID,
+                ID_AND_PASSWORD,
+                new AuthenticationDomain("https://www.example.com")).build();
+        assertThat(cr).isNotNull();
+        assertThat(cr.getIdentifier()).isEqualTo(EMAIL_ID);
+        assertThat(cr.getAuthenticationMethod()).isEqualTo(ID_AND_PASSWORD);
+        assertThat(cr.getAuthenticationDomain()).isNotNull();
+        assertThat(cr.getDisplayName()).isNull();
+        assertThat(cr.getDisplayPicture()).isNull();
+        assertThat(cr.getAdditionalProperties()).isEmpty();
+    }
+
+    @Test
+    public void testBuilder_setIdentifier() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setIdentifier("bob@example.com")
+                .build();
+        assertThat(cr.getIdentifier()).isEqualTo("bob@example.com");
+    }
+
+    @Test(expected = RequireViolation.class)
+    @SuppressWarnings("all")
+    public void testBuilder_setIdentifier_toNull() {
+        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+            .setIdentifier(null)
+            .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_setIdentifier_toEmpty() {
+        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setIdentifier("")
+                .build();
+    }
+
+    @Test
+    public void testBuilder_setPassword() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setPassword("CorrectHorseBatteryStaple")
+                .build();
+        assertThat(cr.getPassword()).isEqualTo("CorrectHorseBatteryStaple");
+    }
+
+    @Test
+    public void testBuilder_setPassword_twice() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setPassword("CorrectHorseBatteryStaple")
+                .setPassword("password1")
+                .build();
+        assertThat(cr.getPassword()).isEqualTo("password1");
+    }
+
+    @Test
+    public void testBuilder_setPassword_toNull() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setPassword("CorrectHorseBatteryStaple")
+                .setPassword(null)
+                .build();
+        assertThat(cr.getPassword()).isNull();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_setPassword_toEmpty() {
+        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setPassword("")
+                .build();
+    }
+
+    @Test
+    public void testBuilder_setDisplayName() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayName("Alice")
+                .build();
+        assertThat(cr.getDisplayName()).isEqualTo("Alice");
+    }
+
+    @Test
+    public void testBuilder_setDisplayName_twice() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayName("Alice")
+                .setDisplayName("Alicia")
+                .build();
+        assertThat(cr.getDisplayName()).isEqualTo("Alicia");
+    }
+
+    @Test
+    public void testBuilder_setDisplayName_toNull() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayName("Alice")
+                .setDisplayName(null)
+                .build();
+        assertThat(cr.getDisplayName()).isNull();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuilder_setDisplayName_toEmpty() {
+        new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayName("")
+                .build();
+    }
+
+    public void testBuilder_setDisplayPicture() {
+        Uri pictureUri = Uri.parse("https://robohash.org/alice@example.com");
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayPicture(pictureUri)
+                .build();
+
+        assertThat(cr.getDisplayPicture()).isSameAs(pictureUri);
+    }
+
+    public void testBuilder_setDisplayPicture_twice() {
+        Uri first = Uri.parse("https://robohash.org/alice@example.com");
+        Uri second = Uri.parse("https://robohash.org/bob@example.com");
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayPicture(first)
+                .setDisplayPicture(second)
+                .build();
+
+        assertThat(cr.getDisplayPicture()).isSameAs(second);
+    }
+
+    public void testBuilder_setDisplayPicture_toNull() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setDisplayPicture(Uri.parse("https://robohash.org/alice@example.com"))
+                .setDisplayPicture((Uri)null)
+                .build();
+
+        assertThat(cr.getDisplayPicture()).isNull();
+    }
+
+    @Test
+    public void testBuilder_setAuthenticationMethod() {
+        Credential cr = new Credential.Builder(EMAIL_ID, ID_AND_PASSWORD, AUTH_DOMAIN)
+                .setAuthenticationMethod(AuthenticationMethods.GOOGLE)
+                .build();
+
+        assertThat(cr.getAuthenticationMethod()).isEqualTo(AuthenticationMethods.GOOGLE);
+    }
+
+    @Test
+    public void testGetProto() {
+        Credential cr = new Credential.Builder(
+                EMAIL_ID,
+                ID_AND_PASSWORD,
+                new AuthenticationDomain("https://www.example.com")).build();
+        org.openyolo.proto.Credential proto = cr.getProto();
+        assertThat(proto).isNotNull();
+    }
+
+    @Test
+    public void testWriteToParcel(){
+        Credential cr = new Credential.Builder(
+                EMAIL_ID,
+                ID_AND_PASSWORD,
+                new AuthenticationDomain("https://www.example.com")).build();
+        Parcel parcel = mock(Parcel.class);
+        cr.writeToParcel(parcel, 0);
+        verify(parcel).writeInt(anyInt());
+        verify(parcel).writeByteArray(any(byte[].class));
+    }
+    private Set<String> keys(String... keys) {
+        return new HashSet<>(Arrays.asList(keys));
+    }
+}
diff --git a/api/javatests/org/openyolo/api/HintRequestTest.java b/api/javatests/org/openyolo/api/HintRequestTest.java
new file mode 100644
index 0000000..2bf7c39
--- /dev/null
+++ b/api/javatests/org/openyolo/api/HintRequestTest.java
@@ -0,0 +1,469 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.data.MapEntry.entry;
+
+import android.net.Uri;
+import android.os.Parcel;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeMap;
+import org.assertj.core.data.MapEntry;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.proto.HintRetrieveRequest;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Tests for {@link HintRequest}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class HintRequestTest {
+
+    @Test
+    public void testBuild() {
+        PasswordSpecification originalSpec = new PasswordSpecification.Builder()
+                .ofLength(8, 10)
+                .allow(PasswordSpecification.ALPHANUMERIC)
+                .require(PasswordSpecification.NUMERALS, 1)
+                .build();
+
+        HintRequest request = new HintRequest.Builder(
+                AuthenticationMethods.ID_AND_PASSWORD,
+                AuthenticationMethods.GOOGLE)
+                .addAuthenticationMethod(AuthenticationMethods.FACEBOOK)
+                .setIdentifierTypes(IdentifierTypes.EMAIL)
+                .addIdentifierType(IdentifierTypes.PHONE)
+                .addAdditionalParameter("a", new byte[] { 1, 2, 3})
+                .addAdditionalParameter("b", "hello")
+                .setPasswordSpecification(originalSpec)
+                .build();
+
+        assertThat(request.getAuthenticationMethods())
+                .containsOnly(
+                        AuthenticationMethods.ID_AND_PASSWORD,
+                        AuthenticationMethods.GOOGLE,
+                        AuthenticationMethods.FACEBOOK);
+
+        assertThat(request.getIdentifierTypes())
+                .containsOnly(
+                        IdentifierTypes.EMAIL,
+                        IdentifierTypes.PHONE);
+
+        assertThat(request.getAdditionalParameters())
+                .containsOnly(
+                        entry("a", new byte[] {1, 2, 3}),
+                        entry("b", "hello".getBytes(Charset.forName("UTF-8"))));
+
+        assertThat(originalSpec).isEqualTo(request.getPasswordSpecification());
+
+        assertThat(request.getAdditionalParameter("a")).isEqualTo(new byte[] {1, 2, 3});
+        assertThat(request.getAdditionalParameterAsString("b")).isEqualTo("hello");
+
+        assertThat(request.getAdditionalParameter("c")).isNull();
+        assertThat(request.getAdditionalParameterAsString("d")).isNull();
+    }
+
+    @Test
+    public void testBuild_overwriteAuthenticationMethods() {
+        HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods(
+                        AuthenticationMethods.GOOGLE,
+                        AuthenticationMethods.FACEBOOK)
+                .build();
+
+        assertThat(request.getAuthenticationMethods())
+                .containsOnly(AuthenticationMethods.GOOGLE, AuthenticationMethods.FACEBOOK);
+    }
+
+    @Test
+    public void testBuild_overwriteIdentityTypes() {
+        HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes(IdentifierTypes.PHONE)
+                .setIdentifierTypes(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC)
+                .build();
+
+        assertThat(request.getIdentifierTypes())
+                .containsOnly(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC);
+    }
+
+    @Test
+    public void testForEmailAndPasswordAccount() {
+        HintRequest request = HintRequest.forEmailAndPasswordAccount();
+        assertThat(request.getAuthenticationMethods())
+                .containsOnly(AuthenticationMethods.ID_AND_PASSWORD);
+        assertThat(request.getIdentifierTypes())
+                .containsOnly(IdentifierTypes.EMAIL);
+        assertThat(request.getPasswordSpecification())
+                .isEqualTo(PasswordSpecification.DEFAULT);
+        assertThat(request.getAdditionalParameters()).isEmpty();
+    }
+
+    @Test
+    public void testSerialize() {
+        HintRequest request = new HintRequest.Builder(
+                AuthenticationMethods.ID_AND_PASSWORD,
+                AuthenticationMethods.FACEBOOK)
+                .setIdentifierTypes(IdentifierTypes.EMAIL, IdentifierTypes.ALPHANUMERIC)
+                .setPasswordSpecification(
+                        new PasswordSpecification.Builder()
+                                .ofLength(10, 100)
+                                .allow(PasswordSpecification.ALPHANUMERIC)
+                                .require(PasswordSpecification.NUMERALS, 1)
+                                .build())
+                .build();
+
+        Parcel p = Parcel.obtain();
+        try {
+            request.writeToParcel(p, 0);
+            p.setDataPosition(0);
+            HintRequest read = HintRequest.CREATOR.createFromParcel(p);
+
+            assertThat(read.getAuthenticationMethods())
+                    .containsOnlyElementsOf(request.getAuthenticationMethods());
+            assertThat(read.getIdentifierTypes())
+                    .containsOnlyElementsOf(request.getIdentifierTypes());
+            assertThat(read.getPasswordSpecification())
+                    .isEqualTo(request.getPasswordSpecification());
+        } finally {
+            p.recycle();
+        }
+    }
+
+    /* **************************** constraint violation test cases *******************************/
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_nullRequestProto() {
+        new HintRequest.Builder((HintRetrieveRequest) null).build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_nullAuthenticationMethod() {
+        new HintRequest.Builder((Uri) null).build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_nullString() {
+        new HintRequest.Builder((String) null).build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_nullUriSet() {
+        new HintRequest.Builder((Set<Uri>) null).build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_nullUriInVarargs() {
+        new HintRequest.Builder(
+                AuthenticationMethods.ID_AND_PASSWORD,
+                null,
+                AuthenticationMethods.GOOGLE).build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_nullStringInVarargs() {
+        new HintRequest.Builder(
+                "custom://auth-method",
+                null,
+                "custom://another-auth-method")
+                .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_invalidAuthMethodString() {
+        new HintRequest.Builder("notAnAuthMethod").build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_emptySet() {
+        new HintRequest.Builder(new HashSet<Uri>()).build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_constructor_setContainingNull() {
+        HashSet<Uri> authMethods = new HashSet<>();
+        authMethods.add(null);
+        new HintRequest.Builder(new HashSet<>(authMethods)).build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_nullUri() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods((Uri) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_nullUriInVarargs() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods(
+                        AuthenticationMethods.ID_AND_PASSWORD,
+                        null,
+                        AuthenticationMethods.GOOGLE)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_nullString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods((String) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_nullStringInVarargs() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods(
+                        "custom://auth-method",
+                        null,
+                        "custom://another-auth-method")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_nullSet() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods((Set<Uri>) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_emptySet() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods(new HashSet<Uri>())
+                .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAuthenticationMethods_setContainingNull() {
+        HashSet<Uri> authMethods = new HashSet<>();
+        authMethods.add(null);
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAuthenticationMethods(authMethods)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAuthenticationMethod_nullUri() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAuthenticationMethod((Uri) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAuthenticationMethod_nullString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAuthenticationMethod((String) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAuthenticationMethod_emptyString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAuthenticationMethod("")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAuthenticationMethod_invalidString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAuthenticationMethod("notAnAuthMethod")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setIdentifierTypes_nullUri() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes((Uri) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setIdentifierTypes_nullUriInVarargs() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes(
+                        IdentifierTypes.EMAIL,
+                        null,
+                        IdentifierTypes.PHONE)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setIdentifierTypes_nullString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes((String) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setIdentifierTypes_nullStringInVarargs() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes(
+                        "custom://id-type",
+                        null,
+                        "custom://another-id-type")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setIdentifierTypes_nullSet() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes((Set<Uri>) null)
+                .build();
+    }
+
+    public void testBuild_setIdentifierTypes_emptySet() {
+        HintRequest request = new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes(new HashSet<Uri>())
+                .build();
+
+        assertThat(request.getIdentifierTypes()).isEmpty();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setIdentifierTypes_setContainingNull() {
+        HashSet<Uri> idTypes = new HashSet<>();
+        idTypes.add(null);
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setIdentifierTypes(idTypes)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addIdentifierType_nullUri() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addIdentifierType((Uri) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addIdentifierType_nullString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addIdentifierType((String) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addIdentifierType_emptyString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addIdentifierType("")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addIdentifierType_invalidString() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addIdentifierType("notAnIdTpye")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAdditionalParameters_nullMap() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAdditionalParameters(null)
+                .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAdditionalParameters_nullKey() {
+        HashMap<String, byte[]> additionalParams = new HashMap<>();
+        additionalParams.put(null, new byte[0]);
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAdditionalParameters(additionalParams)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setAdditionalParameters_nullValue() {
+        HashMap<String, byte[]> additionalParams = new HashMap<>();
+        additionalParams.put("a", null);
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setAdditionalParameters(additionalParams)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAdditionalParameter_nullKey() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAdditionalParameter(null, "value")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAdditionalParameter_emptyKey() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAdditionalParameter("", "value")
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAdditionalParameter_nullByteArrayValue() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAdditionalParameter("key", (byte[]) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_addAdditionalParameter_nullStringValue() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAdditionalParameter("key", (String) null)
+                .build();
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    @Test(expected = RequireViolation.class)
+    public void testBuild_setPasswordSpecification_null() {
+        new HintRequest.Builder(AuthenticationMethods.ID_AND_PASSWORD)
+                .setPasswordSpecification(null)
+                .build();
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/KnownProvidersTest.java b/api/javatests/org/openyolo/api/KnownProvidersTest.java
new file mode 100644
index 0000000..3992645
--- /dev/null
+++ b/api/javatests/org/openyolo/api/KnownProvidersTest.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api;
+
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Battery of tests for KnownProviders.
+ * Future-proofing the predefined values for the hardcoded providers.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class KnownProvidersTest {
+
+    @Mock
+    private Context mockContext;
+    @Mock
+    private PackageManager mockPackageManager;
+
+    private KnownProviders underTest;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        when(mockContext.getApplicationContext()).thenReturn(mockContext);
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+        PackageInfo mockPackageInfo = new PackageInfo();
+        Signature[] signatures = new Signature[1];
+        signatures[0] = mock(Signature.class);
+        when(signatures[0].toByteArray()).thenReturn(new byte[10]);
+        mockPackageInfo.signatures = signatures;
+        when(mockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mockPackageInfo);
+        underTest = KnownProviders.getApplicationBoundInstance(mockContext);
+    }
+
+    /**
+     * Future-proofing the default providers.
+     * This test exist ONLY to future proof the sourcecode and make sure the above info doesn't
+     * change by chance. The signatures here should never change, so in order to make sure of that
+     * I added a second copy of them in this test.
+     * @throws Exception
+     */
+    @Test
+    public void testGetKnownProviders() throws Exception {
+        Set<AuthenticationDomain> all = underTest.getKnownProviders();
+        assertTrue(all.containsAll(DEFAULT_KNOWN_PROVIDERS));
+        assertEquals(all.size(), DEFAULT_KNOWN_PROVIDERS.size());
+    }
+
+
+    public void testIsKnown_null() throws Exception {
+        underTest.isKnown(null);
+    }
+
+    @Ignore // too dificult to unit test this, as it works with the byte[] of the actual signature
+    @Test
+    public void testIsKnown_positive() throws Exception {
+        assertFalse(underTest.isKnown("com.dashlane"));
+    }
+
+    @Test
+    public void testIsKnown_negative() throws Exception {
+        assertFalse(underTest.isKnown("bogus.tld"));
+    }
+
+    @Test
+    public void testResetKnownProvidersToDefault() throws Exception {
+        int originalSize = underTest.getKnownProviders().size();
+        AuthenticationDomain barbican = new AuthenticationDomain("https://barbican.com");
+        underTest.addKnownProvider(barbican);
+        int newsize = underTest.getKnownProviders().size();
+        assertEquals(newsize, originalSize+1);
+        underTest.resetKnownProvidersToDefault();
+        Set<AuthenticationDomain> all = underTest.getKnownProviders();
+        assertTrue(all.containsAll(DEFAULT_KNOWN_PROVIDERS));
+        assertEquals(all.size(), DEFAULT_KNOWN_PROVIDERS.size());
+    }
+
+    @Test
+    public void testAddKnownProvider() throws Exception {
+        int originalSize = underTest.getKnownProviders().size();
+        AuthenticationDomain barbican = new AuthenticationDomain("https://barbican.com");
+        underTest.addKnownProvider(barbican);
+        int newsize = underTest.getKnownProviders().size();
+        assertEquals(newsize, originalSize+1);
+    }
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://www.dashlane.com">Dashlane</a>.
+     */
+    public static final AuthenticationDomain DASHLANE_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "DcxjRReUBVOOF1ztasdT8TO_5z-2aFWBTliZC8pMuy0r"
+                    + "QomVAPv88RfGomI4dJS2CEVNJuu1jSIGBamB1Ni9iw=="
+                    + "@com.dashlane");
+
+    /**
+     * The known package name and certificate hash for Google's
+     * <a href="https://developers.google.com/identity/smartlock-passwords/android/">
+     * Smart Lock for Passwords</a>.
+     */
+    public static final AuthenticationDomain GOOGLE_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c"
+                    + "4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg=="
+                    + "@com.google.android.gms");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://keepersecurity.com/">Keeper</a>.
+     */
+    public static final AuthenticationDomain KEEPER_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "qLhgSEs508k28WNBOalEFKqiNiUsWQ81o-OKOc9i__pf"
+                    + "APc-eCrhdbQe9Gak2DopEEsI6rc12KwmPYoaNg-zEg=="
+                    + "@com.callpod.android_apps.keeper");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://www.lastpass.com/">LastPass</a>.
+     */
+    public static final AuthenticationDomain LASTPASS_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7of"
+                    + "wLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ=="
+                    + "@com.lastpass.lpandroid");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://1password.com/">1Password</a>.
+     */
+    public static final AuthenticationDomain ONEPASSWORD_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "13u4RbkHxfV1nNgX9TJADGCzjyANu3HBL6IPPj8LO82U"
+                    + "iGvPNYngjSJfIWT-FsxaaEGz0QKEqrhgtlxM-DF8ow=="
+                    + "@com.agilebits.onepassword");
+
+    /**
+     * The known package name and certificate hash for
+     * <a href="https://www.roboform.com/">Roboform</a>.
+     */
+    public static final AuthenticationDomain ROBOFORM_PROVIDER =
+            new AuthenticationDomain("android://"
+                    + "JY5BCpB1lKVw_KSpeji4Pp9znAYiho9rDyETFaAC-nCM"
+                    + "hNpekHTlp45wMt7YDwe8FcMW5wrSBYLWeKEIdes77g=="
+                    + "@com.siber.roboform");
+
+    /**
+     * The list of known providers at the time this library was compiled.
+     */
+    public static final Set<AuthenticationDomain> DEFAULT_KNOWN_PROVIDERS =
+            Collections.unmodifiableSet(new HashSet<AuthenticationDomain>(Arrays.asList(
+                    DASHLANE_PROVIDER,
+                    GOOGLE_PROVIDER,
+                    KEEPER_PROVIDER,
+                    LASTPASS_PROVIDER,
+                    ONEPASSWORD_PROVIDER,
+                    ROBOFORM_PROVIDER
+            )));
+
+
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/PasswordSpecificationTest.java b/api/javatests/org/openyolo/api/PasswordSpecificationTest.java
new file mode 100644
index 0000000..7a59532
--- /dev/null
+++ b/api/javatests/org/openyolo/api/PasswordSpecificationTest.java
@@ -0,0 +1,368 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api;
+
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyListOf;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.openyolo.api.PasswordSpecification.ALPHANUMERIC;
+import static org.openyolo.api.PasswordSpecification.ALPHANUMERIC_DISTINGUISHABLE;
+import static org.openyolo.api.PasswordSpecification.LOWER_ALPHA;
+import static org.openyolo.api.PasswordSpecification.LOWER_ALPHA_DISTINGUISHABLE;
+import static org.openyolo.api.PasswordSpecification.NUMERALS;
+import static org.openyolo.api.PasswordSpecification.PASSWORD_CONFORMS;
+import static org.openyolo.api.PasswordSpecification.PASSWORD_DISALLOWED_CHARACTER;
+import static org.openyolo.api.PasswordSpecification.PASSWORD_LENGTH_MISMATCH;
+import static org.openyolo.api.PasswordSpecification.PASSWORD_REQUIRED_CHARACTER_MISSING;
+import static org.openyolo.api.PasswordSpecification.UPPER_ALPHA;
+import static org.openyolo.api.PasswordSpecification.UPPER_ALPHA_DISTINGUISHABLE;
+
+import android.os.Parcel;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for the PasswordSpecification
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class PasswordSpecificationTest {
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_noSizeSpecified() {
+        new PasswordSpecification.Builder()
+                .allow("abc")
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_noAllowedSpecified() {
+        new PasswordSpecification.Builder()
+                .ofLength(3, 4)
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_allow_emptyString() {
+        new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("")
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_allow_nonAsciiChar() {
+        new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("aéo")
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_ofLength_minimumSizeNotPositive() {
+        new PasswordSpecification.Builder()
+                .ofLength(0, 5)
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_ofLength_invalidRange() {
+        new PasswordSpecification.Builder()
+                .ofLength(5, 4)
+                .allow("abc")
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_require_countNotPositive() {
+        new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("abc")
+                .require("a", 0)
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_require_setsNotDisjoint() {
+        new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("abc")
+                .require("ab", 1)
+                .require("bc", 1)
+                .build();
+    }
+
+    @Test(expected = PasswordSpecification.InvalidSpecificationError.class)
+    public void testBuild_require_countGreaterThanMaximum() {
+        new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("abc")
+                .require("a", 6)
+                .build();
+    }
+
+    @Test
+    public void testCheckConformance_default() throws Exception {
+        PasswordSpecification spec = PasswordSpecification.DEFAULT;
+        // conformant
+        assertEquals(PASSWORD_CONFORMS, spec.checkConformance("LetmeinPeace5"));
+
+        // one character too short
+        assertEquals(PASSWORD_LENGTH_MISMATCH, spec.checkConformance("LetmeinPce5"));
+
+        // one character too long
+        assertEquals(PASSWORD_LENGTH_MISMATCH, spec.checkConformance("LetmeinNoPeace567"));
+
+        // non-distinguishable lower case letter (l)
+        assertEquals(PASSWORD_DISALLOWED_CHARACTER, spec.checkConformance("letmeinPeace5"));
+
+        // non-distinguishable upper case letter (I)
+        assertEquals(PASSWORD_DISALLOWED_CHARACTER, spec.checkConformance("LetmeInPeace5"));
+
+        // non-distinguishable number (1)
+        assertEquals(PASSWORD_DISALLOWED_CHARACTER, spec.checkConformance("LetmeinPeace14"));
+
+        // non alpha-numeric character (!)
+        assertEquals(PASSWORD_DISALLOWED_CHARACTER, spec.checkConformance("L3tmeinPeace!"));
+
+        // empty password
+        assertEquals(PASSWORD_LENGTH_MISMATCH | PASSWORD_REQUIRED_CHARACTER_MISSING,
+                spec.checkConformance(""));
+
+        // too short, missing a number
+        assertEquals(PASSWORD_LENGTH_MISMATCH | PASSWORD_REQUIRED_CHARACTER_MISSING,
+                spec.checkConformance("LetmeinPce"));
+
+        // missing a number, contains non-alpha numeric character (!)
+        assertEquals(PASSWORD_REQUIRED_CHARACTER_MISSING | PASSWORD_DISALLOWED_CHARACTER,
+                spec.checkConformance("LetmeinPeace!"));
+    }
+
+    @Test
+    public void testCheckConformance_allAlphaNumerals() throws Exception{
+        PasswordSpecification spec = createTestSpec();
+
+        assertEquals(PASSWORD_CONFORMS, spec.checkConformance("Letmein1"));
+        assertEquals(PASSWORD_CONFORMS, spec.checkConformance("Letmein0"));
+        assertEquals(PASSWORD_REQUIRED_CHARACTER_MISSING, spec.checkConformance("letmein"));
+        assertEquals(PASSWORD_REQUIRED_CHARACTER_MISSING, spec.checkConformance("letmein1"));
+        assertEquals(PASSWORD_REQUIRED_CHARACTER_MISSING, spec.checkConformance("trustno1"));
+
+        assertEquals(PASSWORD_REQUIRED_CHARACTER_MISSING, spec.checkConformance("welcome"));
+        assertEquals(PASSWORD_CONFORMS, spec.checkConformance("weLcome1"));
+        assertEquals(PASSWORD_CONFORMS, spec.checkConformance("Welcome1"));
+        assertEquals(PASSWORD_REQUIRED_CHARACTER_MISSING, spec.checkConformance("WelcomeO"));
+        assertEquals(PASSWORD_CONFORMS, spec.checkConformance("Welcome0"));
+    }
+
+    @Test
+    public void testcheckForConformance() throws Exception{
+        
+        assertTrue(PasswordSpecification.checkResultForError(
+                0B001, PasswordSpecification.PASSWORD_LENGTH_MISMATCH));
+
+        assertTrue(PasswordSpecification.checkResultForError(
+                0B010, PasswordSpecification.PASSWORD_REQUIRED_CHARACTER_MISSING));
+
+        assertTrue(PasswordSpecification.checkResultForError(
+                0B100, PasswordSpecification.PASSWORD_DISALLOWED_CHARACTER));
+
+        assertTrue(PasswordSpecification.checkResultForError(
+                0B111, PasswordSpecification.PASSWORD_DISALLOWED_CHARACTER));
+
+        assertTrue(PasswordSpecification.checkResultForError(
+                0B111, PasswordSpecification.PASSWORD_LENGTH_MISMATCH));
+
+        assertTrue(PasswordSpecification.checkResultForError(
+                0B111, PasswordSpecification.PASSWORD_REQUIRED_CHARACTER_MISSING));
+
+        assertFalse(PasswordSpecification.checkResultForError(
+                0B101, PasswordSpecification.PASSWORD_REQUIRED_CHARACTER_MISSING));
+
+        assertFalse(PasswordSpecification.checkResultForError(
+                0B110, PasswordSpecification.PASSWORD_LENGTH_MISMATCH));
+
+        assertFalse(PasswordSpecification.checkResultForError(
+                0B010, PasswordSpecification.PASSWORD_DISALLOWED_CHARACTER));
+    }
+
+    @Test
+    public void testGenerate() throws Exception {
+        // as a basic fuzz test, generate and verify 1000 times
+        for (int i = 0; i < 1000; i++) {
+            String password = PasswordSpecification.DEFAULT.generate();
+            int conformanceCode = PasswordSpecification.DEFAULT.checkConformance(password);
+            assertThat(conformanceCode)
+                    .overridingErrorMessage(
+                            "Expected generated password %s to conform, violation code = %d",
+                            password,
+                            conformanceCode
+                            )
+                    .isEqualTo(PASSWORD_CONFORMS);
+        }
+    }
+
+    @Test
+    public void testEquals_self() throws Exception {
+        assertTrue(PasswordSpecification.DEFAULT.equals(PasswordSpecification.DEFAULT));
+    }
+
+    @Test
+    public void testEquals_null() throws Exception {
+        assertFalse(PasswordSpecification.DEFAULT.equals(null));
+    }
+
+    @Test
+    public void testEquals() throws Exception {
+        assertTrue(createTestSpec().equals(createTestSpec()));
+    }
+
+    @Test
+    public void testEquals_differentAllowSet() throws Exception {
+        PasswordSpecification a = new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("abc")
+                .build();
+        PasswordSpecification b = new PasswordSpecification.Builder()
+                .ofLength(1, 5)
+                .allow("abd")
+                .build();
+        assertFalse(a.equals(b));
+    }
+
+    @Test
+    public void testEquals_differentMinLength() throws Exception {
+        PasswordSpecification a = new PasswordSpecification.Builder()
+                .ofLength(5, 10)
+                .allow("abc")
+                .build();
+
+        PasswordSpecification b = new PasswordSpecification.Builder()
+                .ofLength(6, 10)
+                .allow("abc")
+                .build();
+        assertFalse(a.equals(b));
+    }
+
+    @Test
+    public void testEquals_differentMaxLength() throws Exception {
+        PasswordSpecification a = new PasswordSpecification.Builder()
+                .ofLength(5, 10)
+                .allow("abc")
+                .build();
+
+        PasswordSpecification b = new PasswordSpecification.Builder()
+                .ofLength(5, 11)
+                .allow("abc")
+                .build();
+        assertFalse(a.equals(b));
+    }
+
+    @Test
+    public void testEquals_differentRequireSetChars() throws Exception {
+        PasswordSpecification a = new PasswordSpecification.Builder()
+                .ofLength(1, 10)
+                .allow("abc")
+                .require("a", 1)
+                .build();
+
+        PasswordSpecification b = new PasswordSpecification.Builder()
+                .ofLength(1, 10)
+                .allow("abc")
+                .require("b", 1)
+                .build();
+        assertFalse(a.equals(b));
+    }
+
+    @Test
+    public void testEquals_differentRequireSetCharCount() throws Exception {
+        PasswordSpecification a = new PasswordSpecification.Builder()
+                .ofLength(1, 10)
+                .allow("abc")
+                .require("a", 1)
+                .build();
+
+        PasswordSpecification b = new PasswordSpecification.Builder()
+                .ofLength(1, 10)
+                .allow("abc")
+                .require("a", 2)
+                .build();
+
+        assertFalse(a.equals(b));
+    }
+
+    @Test
+    public void testEquals_differentRequireSets() throws Exception {
+        PasswordSpecification a = new PasswordSpecification.Builder()
+                .ofLength(1, 10)
+                .allow("abc")
+                .require("a", 1)
+                .build();
+
+        PasswordSpecification b = new PasswordSpecification.Builder()
+                .ofLength(1, 10)
+                .allow("abc")
+                .require("a", 1)
+                .require("b", 1)
+                .build();
+
+        assertFalse(a.equals(b));
+    }
+
+    @Test
+    public void testHashCode() {
+        assertThat(createTestSpec().hashCode()).isEqualTo(createTestSpec().hashCode());
+        assertThat(PasswordSpecification.DEFAULT.hashCode())
+                .isNotEqualTo(createTestSpec().hashCode());
+    }
+
+    @Test
+    public void testSerialization() throws Exception{
+        Parcel p = Parcel.obtain();
+        try {
+            PasswordSpecification.DEFAULT.writeToParcel(p, 0);
+            p.setDataPosition(0);
+            PasswordSpecification spec =
+                    PasswordSpecification.CREATOR.createFromParcel(p);
+            assertThat(spec).isEqualTo(PasswordSpecification.DEFAULT);
+        } finally {
+            p.recycle();
+        }
+    }
+
+    private PasswordSpecification createTestSpec() {
+        return  new PasswordSpecification.Builder()
+                .ofLength(6, 10)
+                .allow(ALPHANUMERIC)
+                .require(LOWER_ALPHA, 1)
+                .require(UPPER_ALPHA, 1)
+                .require(NUMERALS, 1)
+                .build();
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/RetrieveRequestTest.java b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
new file mode 100644
index 0000000..4a85115
--- /dev/null
+++ b/api/javatests/org/openyolo/api/RetrieveRequestTest.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.TestCase.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import android.os.Parcel;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openyolo.proto.CredentialRetrieveRequest;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for RetrieveRequest
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class RetrieveRequestTest {
+
+    private static final AuthenticationDomain DOMAIN = new AuthenticationDomain(
+            "android://2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I8" +
+            "7V4Lo8BdCxaA307H0HYkAw==@com.example.app");
+
+    private static final byte[] testBytes = new byte[]
+            {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+
+    private RetrieveRequest request;
+
+    @Before
+    public void setUp() {
+        request = new RetrieveRequest.Builder(DOMAIN)
+                .setAuthenticationMethods(AuthenticationMethods.ID_AND_PASSWORD)
+                .addAdditionalParameter("a", "b")
+                .addAdditionalParameter("c", testBytes)
+                .build();
+    }
+
+    @SuppressLint("PackageManagerGetSignatures")
+    @Test
+    public void testForSelf() throws Exception {
+        Context mockContext = mock(Context.class);
+        PackageInfo packageInfo = new PackageInfo();
+        packageInfo.signatures = new Signature[2];
+        packageInfo.signatures[0] = new Signature(testBytes);
+        packageInfo.signatures[1] = new Signature(new byte[16]);
+
+        PackageManager pm = mock(PackageManager.class);
+        when(pm.getPackageInfo("com.example.app", PackageManager.GET_SIGNATURES))
+                .thenReturn(packageInfo);
+        when(mockContext.getPackageName()).thenReturn("com.example.app");
+        when(mockContext.getPackageManager()).thenReturn(pm);
+
+        RetrieveRequest request = RetrieveRequest.forSelf(mockContext);
+
+        assertThat(request).isNotNull();
+        assertThat(request.getAuthenticationDomains().size()).isEqualTo(1);
+        assertThat(request.getAuthenticationDomains()).contains(DOMAIN);
+        assertThat(request.getAuthenticationMethods()).isEmpty();
+        assertThat(request.getAdditionalParameters()).isEmpty();
+    }
+
+    @Test
+    public void testWriteAndRead() {
+        Parcel p = Parcel.obtain();
+        try {
+            request.writeToParcel(p, 0);
+            p.setDataPosition(0);
+            RetrieveRequest deserialized = RetrieveRequest.CREATOR.createFromParcel(p);
+            assertThat(deserialized).isNotNull();
+            assertThat(deserialized.getAuthenticationDomains())
+                    .isEqualTo(request.getAuthenticationDomains());
+            assertThat(deserialized.getAuthenticationMethods())
+                    .isEqualTo(request.getAuthenticationMethods());
+            assertMapsEqual(
+                    deserialized.getAdditionalParameters(),
+                    request.getAdditionalParameters());
+        } finally {
+            p.recycle();
+        }
+    }
+
+    @Test
+    public void testGetAdditionalParameters() {
+        assertThat(request.getAdditionalParameters()).isNotNull();
+        assertThat(request.getAdditionalParameters()).hasSize(2);
+        assertThat(request.getAdditionalParameterAsString("a")).isEqualTo("b");
+        assertThat(request.getAdditionalParameter("c")).isEqualTo(testBytes);
+    }
+
+    @Test
+    public void testGetAuthDomains() {
+        assertThat(request.getAuthenticationDomains()).hasSize(1);
+        assertThat(request.getAuthenticationDomains()).contains(DOMAIN);
+    }
+
+    @Test
+    public void testGetAuthMethods() {
+        assertThat(request.getAuthenticationMethods()).hasSize(1);
+        assertThat(request.getAuthenticationMethods())
+                .contains(AuthenticationMethods.ID_AND_PASSWORD);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testAdapter_nullArray() throws IOException {
+        CredentialRetrieveRequest.ADAPTER.decode((byte[]) null);
+    }
+
+    private static <T, U> void assertMapsEqual(Map<T, U> a, Map<T, U> b) {
+        assertThat(a.keySet()).isEqualTo(b.keySet());
+        for (T key : a.keySet()) {
+            assertThat(a.get(key)).isEqualTo(b.get(key));
+        }
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/RetrieveResultTest.java b/api/javatests/org/openyolo/api/RetrieveResultTest.java
new file mode 100644
index 0000000..c0ec19d
--- /dev/null
+++ b/api/javatests/org/openyolo/api/RetrieveResultTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import android.content.Intent;
+import android.os.Parcelable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.internal.IntentUtil;
+import org.openyolo.proto.CredentialRetrieveResponse;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Battery of tests for the RetrieveIntent class
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class RetrieveResultTest {
+
+    private RetrieveResult underTest;
+
+    @Before
+    public void setUp() throws Exception {
+        Intent fromIntent = new Intent("com.openyolo.ACTION");
+        fromIntent.setPackage("com.openyolo");
+        byte[] fromBytes = IntentUtil.toBytes(fromIntent);
+        Intent retrieveIntent= IntentUtil.fromBytes(fromBytes);
+
+        Map<String, CredentialRetrieveResponse> protoResponses = new HashMap<>();
+
+        underTest = new RetrieveResult.Builder()
+                .setProtoResponses(protoResponses)
+                .setRetrieveIntent(retrieveIntent)
+                .build();
+    }
+
+    @Test
+    public void testInnerClassNewArray(){
+        int size = 10;
+        Parcelable.Creator<RetrieveResult> creator = new RetrieveResult.RetrieveResultCreator();
+        RetrieveResult[] result = creator.newArray(size);
+        assertEquals(size, result.length);
+
+    }
+
+    @Test
+    public void testGetRetrieveIntent(){
+        Intent intent = underTest.getRetrieveIntent();
+        assertNotNull(intent);
+    }
+
+    @Test
+    public void testGetResponderPackageNames(){
+        Set<String> responders = underTest.getResponderPackageNames();
+        assertNotNull(responders);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testGetRetrieveIntentForResponder_null(){
+        underTest.getRetrieveIntentForResponder(null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetRetrieveIntentForResponder_illegal(){
+        underTest.getRetrieveIntentForResponder("BLahblah");
+    }
+
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/internal/CustomMatchersTest.java b/api/javatests/org/openyolo/api/internal/CustomMatchersTest.java
new file mode 100644
index 0000000..a497e23
--- /dev/null
+++ b/api/javatests/org/openyolo/api/internal/CustomMatchersTest.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.internal;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+
+import android.net.Uri;
+import org.hamcrest.Matcher;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.AuthenticationMethods;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for the custom Matchers suite extending hamcrest
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class CustomMatchersTest {
+    @Test
+    public void isWebUri_http() throws Exception {
+        assertTrue(CustomMatchers.isWebUri().matches(Uri.parse("http://www.blah.com")));
+    }
+
+    @Test
+    public void isWebUri_https() throws Exception {
+        assertTrue(CustomMatchers.isWebUri().matches(Uri.parse("https://www.blah.com")));
+    }
+
+    @Test
+    public void isWebUri_noproto() throws Exception {
+        assertFalse(CustomMatchers.isWebUri().matches(Uri.parse("www.blah.com")));
+    }
+
+    @Test
+    public void isWebUri_ftp() throws Exception {
+        assertFalse(CustomMatchers.isWebUri().matches(Uri.parse("ftp://www.blah.com")));
+    }
+
+    @Test
+    public void isHttpsUri() throws Exception {
+        assertTrue(CustomMatchers.isHttpsUri().matches(Uri.parse("https://www.blah.com")));
+    }
+
+    @Test
+    public void isHttpsUri_withPath() {
+        assertTrue(CustomMatchers.isHttpsUri().matches(
+                Uri.parse("https://www.blah.com/resource")));
+    }
+
+    @Test
+    public void isHttpsUri_withQuery() {
+        assertTrue(CustomMatchers.isHttpsUri().matches(
+                Uri.parse("https://www.blah.com/resource?a=b")));
+    }
+
+    @Test
+    public void isHttpsUri_withFragment() {
+        assertTrue(CustomMatchers.isHttpsUri().matches(
+                Uri.parse("https://www.blah.com/resource#entry")));
+    }
+
+    @Test
+    public void isHttpsUri_http() {
+        assertFalse(CustomMatchers.isHttpsUri().matches(Uri.parse("http://www.blah.com")));
+    }
+
+    @Test
+    public void isValidAuthenticationDomain_http() throws Exception {
+        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
+                Uri.parse("http://www.blah.com")));
+    }
+
+    @Test
+    public void isValidAuthenticationDomain_https() throws Exception {
+        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
+                Uri.parse("https://www.blah.com")));
+    }
+
+    @Test
+    public void isValidAuthenticationDomain_android() throws Exception {
+        assertTrue(CustomMatchers.isValidAuthenticationDomain().matches(
+                Uri.parse("android://signature@com.blah.app")));
+    }
+
+    @Test
+    public void isValidAuthenticationDomain() throws Exception {
+        assertFalse(CustomMatchers.isValidAuthenticationDomain().matches(
+                Uri.parse("http://www.blah.com/resource")));
+    }
+
+    @Test
+    public void isValidAuthenticationMethod_builtIn() throws Exception {
+        assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(
+                AuthenticationMethods.ID_AND_PASSWORD));
+    }
+
+    @Test
+    public void isValidAuthenticationMethod_custom() {
+        assertTrue(CustomMatchers.isValidAuthenticationMethod().matches(
+                Uri.parse("https://www.blah.com")));
+    }
+
+    @Test
+    public void isValidAuthenticationMethod_path() {
+        assertFalse(CustomMatchers.isValidAuthenticationMethod().matches(
+                Uri.parse("http://www.blah.com/resource")));
+    }
+
+    @Test
+    public void nullOr_null() {
+        Matcher<Uri> matcher = CustomMatchers.nullOr(CustomMatchers.isHttpsUri());
+        assertTrue(matcher.matches(null));
+    }
+
+    @Test
+    public void nullOr_Https() {
+        Matcher<Uri> matcher = CustomMatchers.nullOr(CustomMatchers.isHttpsUri());
+        assertTrue(matcher.matches(Uri.parse("https://www.blah.com")));
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/internal/IntentUtilTest.java b/api/javatests/org/openyolo/api/internal/IntentUtilTest.java
new file mode 100644
index 0000000..3bcf812
--- /dev/null
+++ b/api/javatests/org/openyolo/api/internal/IntentUtilTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.internal;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import android.content.Intent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.internal.IntentUtil;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Battery of tests for IntentUtilTest
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class IntentUtilTest {
+
+    @Test(expected = RequireViolation.class)
+    public void testToBytes_null() throws Exception {
+        IntentUtil.toBytes(null);
+    }
+
+    @Test
+    public void toBytes() throws Exception {
+        Intent intent = new Intent("com.openyolo");
+        byte[] result = IntentUtil.toBytes(intent);
+        assertEquals(result.length, 235);
+        //comparing a few random locations
+        assertEquals(result[0], -84);
+        assertEquals(result[8], 0);
+        assertEquals(result[16], 22);
+        assertEquals(result[32], 46);
+        assertEquals(result[64], 0);
+        assertEquals(result[128], -107);
+        assertEquals(result[234], -1);
+    }
+
+    @Test
+    public void fromBytes() throws Exception {
+        Intent fromIntent = new Intent("com.openyolo.ACTION");
+        fromIntent.setPackage("com.openyolo");
+        byte[] fromBytes = IntentUtil.toBytes(fromIntent);
+
+        Intent toIntent= IntentUtil.fromBytes(fromBytes);
+        assertTrue(toIntent.getAction().equals(fromIntent.getAction()));
+        assertTrue(toIntent.getPackage().equals(fromIntent.getPackage()));
+
+    }
+
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java b/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
new file mode 100644
index 0000000..6460254
--- /dev/null
+++ b/api/javatests/org/openyolo/api/internal/KeyValuePairConvertersTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;import static org.assertj.core.api.Assertions.assertThat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import okio.ByteString;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.internal.CollectionConverter;
+import org.openyolo.api.internal.KeyValuePairConverters;
+import org.openyolo.proto.KeyValuePair;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for KeyValuePairConverters
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class KeyValuePairConvertersTest {
+    @Test
+    public void convertToMap() throws Exception {
+        List<KeyValuePair> dataPairs = new ArrayList<>();
+
+        String first = "first";
+        String second = "second";
+        String third = "third";
+
+        dataPairs.add(new KeyValuePair(first, ByteString.of(first.getBytes())));
+        dataPairs.add(new KeyValuePair(second, ByteString.of(second.getBytes())));
+        dataPairs.add(new KeyValuePair(third, ByteString.of(third.getBytes())));
+
+        Map<String, byte[]> dataMap =
+                CollectionConverter.toMap(dataPairs, KeyValuePairConverters.CONVERTER_KVP_TO_PAIR);
+
+        assertThat(dataMap).hasSize(3);
+        assertThat(dataMap).containsOnlyKeys(first, second, third);
+        assertThat(dataMap.get(first)).isEqualTo(first.getBytes());
+        assertThat(dataMap.get(second)).isEqualTo(second.getBytes());
+        assertThat(dataMap.get(third)).isEqualTo(third.getBytes());
+    }
+
+    @Test
+    public void convertToMap_nullList() throws Exception {
+        Map<String, byte[]> dataMap =
+                CollectionConverter.toMap(null, KeyValuePairConverters.CONVERTER_KVP_TO_PAIR);
+        assertThat(dataMap).isEmpty();
+        assertThat(dataMap).isEmpty();
+    }
+
+    @Test
+    public void convertToList() throws Exception {
+        String first = "first";
+        String second = "second";
+        String third = "third";
+
+        Map<String, byte[]> data = new HashMap<>();
+        data.put(first, first.getBytes());
+        data.put(second, second.getBytes());
+        data.put(third, third.getBytes());
+
+        List<KeyValuePair> pairs =
+                CollectionConverter.toList(
+                        data.entrySet(),
+                        KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP);
+
+        assertThat(pairs).hasSize(3);
+        assertThat(pairs).contains(
+                new KeyValuePair(first, ByteString.of(first.getBytes())),
+                new KeyValuePair(second, ByteString.of(second.getBytes())),
+                new KeyValuePair(third, ByteString.of(third.getBytes())));
+    }
+
+    public void convertToList_nullEntrySet() throws Exception {
+        List<Map.Entry<String, byte[]>> nullEntrySet = null;
+        List<KeyValuePair> list =
+                CollectionConverter.toList(
+                        nullEntrySet,
+                        KeyValuePairConverters.CONVERTER_ENTRY_TO_KVP);
+        assertThat(list).isEmpty();
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/package-info.java b/api/javatests/org/openyolo/api/package-info.java
new file mode 100644
index 0000000..667f7c0
--- /dev/null
+++ b/api/javatests/org/openyolo/api/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tests for OpenYOLO API.
+ */
+package org.openyolo.api;
diff --git a/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java b/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
new file mode 100644
index 0000000..072f5be
--- /dev/null
+++ b/api/javatests/org/openyolo/api/ui/ProviderPickerActivityTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.ui;
+
+import static junit.framework.TestCase.assertNotNull;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import java.util.ArrayList;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openyolo.api.R;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for the ProviderPickerActivity
+ */
+@RunWith(YoloTestRunner.class)
+@Config(manifest = "AndroidManifest.xml",
+        sdk = Build.VERSION_CODES.LOLLIPOP,
+        packageName = "org.openyolo.api")
+public class ProviderPickerActivityTest {
+
+    @Mock
+    Context mockContext;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+
+    }
+
+    @Test
+    public void createRetrieveIntent() throws Exception {
+        ArrayList<Intent> retrieveIntents = new ArrayList<>();
+        Intent item = ProviderPickerActivity.createRetrieveIntent(mockContext, retrieveIntents);
+        assertNotNull(item);
+
+    }
+
+    @Test
+    public void createSaveIntent() throws Exception {
+        ArrayList<Intent> retrieveIntents = new ArrayList<>();
+        Intent item = ProviderPickerActivity.createSaveIntent(mockContext, retrieveIntents);
+        assertNotNull(item);
+    }
+
+    @Test
+    public void testActivity_main() throws Exception {
+        Activity activity = Robolectric.buildActivity(ProviderPickerActivity.class).create().get();
+        assertNotNull(activity);
+        TextView titleView = (TextView) activity.findViewById(R.id.picker_title);
+    }
+
+    @Test
+    public void testActivity_toViewport_save() throws Exception {
+        final String SAVE_CREDENTIAL_ACTION = "org.openyolo.save";
+        final String OPENYOLO_CATEGORY = "org.openyolo";
+        final String EXTRA_PROVIDER_INTENTS = "providerIntents";
+
+            Intent saveIntent = new Intent(SAVE_CREDENTIAL_ACTION);
+            saveIntent.setClassName(
+                    "com.dashlane",
+                    "LoginActivity");
+            ArrayList<Intent> intents = new ArrayList<>();
+            saveIntent.addCategory(OPENYOLO_CATEGORY);
+            saveIntent.putParcelableArrayListExtra(EXTRA_PROVIDER_INTENTS, intents);
+            //saveIntent.setData(credentialToSave.getAuthenticationMethod());
+
+
+        Activity activity = Robolectric.buildActivity(ProviderPickerActivity.class)
+                .withIntent(saveIntent)
+                .create()
+                .start()
+                .resume()
+                .visible()
+                .get();
+        assertNotNull(activity);
+        ListAdapter adapter = ((ListView) activity.findViewById(R.id.provider_list)).getAdapter();
+        assertNotNull(adapter);
+    }
+}
\ No newline at end of file
diff --git a/api/javatests/org/openyolo/api/ui/YoloTestRunner.java b/api/javatests/org/openyolo/api/ui/YoloTestRunner.java
new file mode 100644
index 0000000..5d59a18
--- /dev/null
+++ b/api/javatests/org/openyolo/api/ui/YoloTestRunner.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.api.ui;
+
+import org.junit.runners.model.InitializationError;
+import org.openyolo.api.BuildConfig;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.manifest.AndroidManifest;
+import org.robolectric.res.Fs;
+
+public class YoloTestRunner extends RobolectricTestRunner {
+    public YoloTestRunner(Class<?> testClass) throws InitializationError {
+        super(testClass);
+        String buildVariant = (BuildConfig.FLAVOR.isEmpty()
+                ? "" : BuildConfig.FLAVOR+ "/") + BuildConfig.BUILD_TYPE;
+        String intermediatesPath = BuildConfig.class.getResource("")
+                .toString().replace("file:", "");
+        intermediatesPath = intermediatesPath
+                .substring(0, intermediatesPath.indexOf("/classes"));
+
+        System.setProperty("android.package",
+                BuildConfig.APPLICATION_ID);
+        System.setProperty("android.manifest",
+                intermediatesPath + "/manifests/aapt/"
+                        + buildVariant + "/AndroidManifest.xml");
+        System.setProperty("android.resources",
+                intermediatesPath + "/res/merged/" + buildVariant);
+        System.setProperty("android.assets",
+                intermediatesPath + "/assets/" + buildVariant);
+    }
+
+    @Override protected AndroidManifest getAppManifest(Config config) {
+
+        String manifestProperty = System.getProperty("android.manifest");
+        String resProperty = System.getProperty("android.resources");
+        String assetsProperty = System.getProperty("android.assets");
+        AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty),
+                Fs.fileFromPath(assetsProperty)){
+        };
+        manifest.setPackageName("org.openyolo.api");
+        return manifest;
+    }
+}
\ No newline at end of file
diff --git a/api/proguard-rules.txt b/api/proguard-rules.txt
new file mode 100644
index 0000000..64b8fce
--- /dev/null
+++ b/api/proguard-rules.txt
@@ -0,0 +1,8 @@
+# it is safe to ignore the resources ids from OpenYOLO api. Without this flag we have issue with picker_title, provider_list
+-dontwarn org.openyolo.api.R$id
+
+# valid4j use reflection to inject Providers and Policy
+-keep class org.valid4j.** { *; }
+
+# it is safe to ignore okio warnings
+-dontwarn okio.**
\ No newline at end of file
diff --git a/api/proto/openyolo.proto b/api/proto/openyolo.proto
new file mode 100644
index 0000000..3eda1a7
--- /dev/null
+++ b/api/proto/openyolo.proto
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package org.openyolo;
+
+option java_package = "org.openyolo.proto";
+
+message CredentialRetrieveRequest {
+    repeated string       authDomains        = 1; // at least one required
+    repeated string       authMethods        = 2; // at least one required
+    repeated KeyValuePair additionalParams   = 3;
+}
+
+message CredentialRetrieveResponse {
+    optional bytes        retrieveIntent   = 1; // required
+    repeated KeyValuePair additionalParams = 2;
+}
+
+message CredentialRetrieveResponseList {
+    repeated CredentialRetrieveResponse responses = 1;
+}
+
+message HintRetrieveRequest {
+    repeated string                authMethods      = 1; // at least one required
+    repeated string                idTypes          = 2; // at least one required
+    repeated KeyValuePair          additionalParams = 3;
+    optional PasswordSpecification passwordSpec     = 4;
+}
+
+message HintRetrieveResponse {
+    optional bytes        retrieveIntent = 1; // required
+    repeated KeyValuePair additionalParams = 2;
+}
+
+message HintRetrieveResponseList {
+    repeated HintRetrieveResponse responses = 1;
+}
+
+message Credential {
+    optional string       id                    = 1; // required
+    optional string       authDomain            = 2; // required
+    optional string       authMethod            = 3; // required
+    optional string       displayName           = 4;
+    optional string       displayPictureUri     = 5;
+    optional string       password              = 6;
+    repeated KeyValuePair additionalProps       = 7;
+}
+
+message CredentialList {
+    repeated Credential credentials = 1;
+}
+
+message KeyValuePair {
+    optional string name  = 1; // required
+    optional bytes  value = 2;
+}
+
+message PasswordSpecification {
+    optional string          allowed      = 1; // required
+    optional uint32          minSize      = 2; // required
+    optional uint32          maxSize      = 3; // required
+    repeated RequiredCharSet requiredSets = 4;
+}
+
+message RequiredCharSet {
+    optional string chars = 1; // required
+    optional uint32 count = 2; // required
+}
\ No newline at end of file
diff --git a/api/res/drawable/bottom_sheet_edge.xml b/api/res/drawable/bottom_sheet_edge.xml
new file mode 100644
index 0000000..9fbd74e
--- /dev/null
+++ b/api/res/drawable/bottom_sheet_edge.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+    <gradient
+        android:startColor="#24000000"
+        android:centerColor="#12000000"
+        android:endColor="#00000000"
+        android:angle="90" />
+</shape>
\ No newline at end of file
diff --git a/api/res/drawable/warning_icon.xml b/api/res/drawable/warning_icon.xml
new file mode 100644
index 0000000..b7f3969
--- /dev/null
+++ b/api/res/drawable/warning_icon.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="12dp"
+    android:height="12dp"
+    android:viewportWidth="12"
+    android:viewportHeight="12">
+    <path
+        android:fillColor="#FFA000"
+        android:pathData="M0.5,10.5 L11.5,10.5 L6,1 L0.5,10.5 Z M6.5,9 L5.5,9 L5.5,8 L6.5,8 L6.5,9 Z M6.5,7 L5.5,7
+L5.5,5 L6.5,5 L6.5,7 Z" />
+</vector>
\ No newline at end of file
diff --git a/api/res/drawable/warning_icon_compat_wrapper.xml b/api/res/drawable/warning_icon_compat_wrapper.xml
new file mode 100644
index 0000000..7f4b3f1
--- /dev/null
+++ b/api/res/drawable/warning_icon_compat_wrapper.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+this exists to provide a layer of indirection to the vector drawable, which
+ensures that support-vector-drawable will render the vector regardless of
+the context where it is used.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/warning_icon" />
+</selector>
\ No newline at end of file
diff --git a/api/res/layout/picker_layout.xml b/api/res/layout/picker_layout.xml
new file mode 100644
index 0000000..13be7a0
--- /dev/null
+++ b/api/res/layout/picker_layout.xml
@@ -0,0 +1,42 @@
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_gravity="bottom"
+    android:orientation="vertical"
+    tools:ignore="Overdraw">
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="3dp"
+        android:background="@drawable/bottom_sheet_edge" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/grey_100_opaque"
+        android:orientation="vertical"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:paddingBottom="8dp">
+
+        <TextView
+            android:id="@+id/picker_title"
+            android:layout_width="match_parent"
+            android:layout_height="56dp"
+            android:gravity="center_vertical"
+            android:textAppearance="@style/TextAppearance.AppCompat.Title"
+            android:textColor="@color/black_54pc" />
+
+        <ListView
+            android:id="@+id/provider_list"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_gravity="bottom"
+            android:layout_weight="1"
+            android:divider="@null"
+            android:dividerHeight="0dp" />
+
+    </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/api/res/layout/provider_item.xml b/api/res/layout/provider_item.xml
new file mode 100644
index 0000000..517a9fd
--- /dev/null
+++ b/api/res/layout/provider_item.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="48dp"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:clickable="true"
+    android:background="?attr/selectableItemBackground"
+    android:orientation="horizontal"
+    android:gravity="center_vertical">
+
+    <ImageView
+        android:id="@+id/provider_icon"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:contentDescription="@string/provider_icon_contentDescription" />
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:layout_marginLeft="32dp"
+        android:layout_marginStart="32dp"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/provider_name"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
+            tools:text="Provider Name"/>
+
+        <TextView
+            android:id="@+id/unsafe_provider_warning"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:drawableLeft="@drawable/warning_icon_compat_wrapper"
+            android:drawableStart="@drawable/warning_icon_compat_wrapper"
+            android:drawablePadding="4dp"
+            android:text="@string/possibly_unsafe"
+            android:textAppearance="@style/TextAppearance.AppCompat.Caption"
+            android:textColor="@color/amber_700_54pc"/>
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/api/res/values/colors.xml b/api/res/values/colors.xml
new file mode 100644
index 0000000..3963b40
--- /dev/null
+++ b/api/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="grey_100_opaque">#F5F5F5</color>
+    <color name="amber_700_54pc">#89FFA000</color>
+    <color name="black_54pc">#89000000</color>
+</resources>
\ No newline at end of file
diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
new file mode 100644
index 0000000..422c222
--- /dev/null
+++ b/api/res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="retrieve_picker_prompt">Use account from:</string>
+    <string name="provider_icon_contentDescription">Provider icon</string>
+    <string name="possibly_unsafe">Possibly unsafe</string>
+    <string name="save_picker_prompt">Save your account with:</string>
+    <string name="hint_picker_prompt">Use account details stored in:</string>
+</resources>
\ No newline at end of file
diff --git a/api/res/values/styles.xml b/api/res/values/styles.xml
new file mode 100644
index 0000000..e5f3023
--- /dev/null
+++ b/api/res/values/styles.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="PickerTheme" parent="Theme.AppCompat.Light">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:backgroundDimEnabled">true</item>
+    </style>
+</resources>
\ No newline at end of file
diff --git a/bbq/AndroidManifest.xml b/bbq/AndroidManifest.xml
new file mode 100644
index 0000000..8069ad0
--- /dev/null
+++ b/bbq/AndroidManifest.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.google.bbq" />
diff --git a/bbq/build.gradle b/bbq/build.gradle
new file mode 100644
index 0000000..cc6894d
--- /dev/null
+++ b/bbq/build.gradle
@@ -0,0 +1,18 @@
+apply plugin: 'com.android.library'
+
+apply from:'../config/android-common.gradle'
+apply from:'../config/wire-proto.gradle'
+apply from:'../config/third-party.gradle'
+
+android.defaultConfig.project.archivesBaseName = 'bbq'
+
+dependencies {
+    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    compile "org.hamcrest:hamcrest-core:1.3"
+    compile "org.valid4j:valid4j:0.5.0"
+    apply from:'../config/testdeps.gradle', to:it
+}
+
+apply from: '../config/style.gradle'
+apply from: '../config/coverage.gradle'
+apply from: '../config/javadoc.gradle'
diff --git a/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java b/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java
new file mode 100644
index 0000000..a158eff
--- /dev/null
+++ b/bbq/java/com/google/bbq/BaseBroadcastQueryReceiver.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.support.annotation.NonNull;
+import android.util.Log;
+import com.google.bbq.proto.BroadcastQuery;
+import java.io.IOException;
+
+/**
+ * Partial BBQ query receiver implementation, that should be extended by providers.
+ * This implementation handles some basic validation and decoding of the request before
+ * handing the request to {@link #processQuery(Context, BroadcastQuery)}.
+ */
+public abstract class BaseBroadcastQueryReceiver extends BroadcastReceiver {
+
+    protected final String mLogTag;
+
+    /**
+     * Creates a query receiver, using the specified log tag for warning messages in parsing
+     * received requests.
+     */
+    public BaseBroadcastQueryReceiver(String logTag) {
+        mLogTag = logTag;
+    }
+
+    @Override
+    public void onReceive(final Context context, final Intent intent) {
+        byte[] queryBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_QUERY_MESSAGE);
+        if (queryBytes == null) {
+            Log.w(mLogTag, "Received message without query data");
+            return;
+        }
+
+        final BroadcastQuery query;
+        try {
+            query = BroadcastQuery.ADAPTER.decode(queryBytes);
+        } catch (IOException e) {
+            Log.w(mLogTag, "Unable to decode query data");
+            return;
+        }
+
+        try {
+            context.getPackageManager().getPackageInfo(query.requestingApp, 0);
+        } catch (PackageManager.NameNotFoundException ex) {
+            Log.w(mLogTag, "Received query from non-existent app: " + query.requestingApp);
+            return;
+        }
+
+        processQuery(context, query);
+    }
+
+    protected abstract void processQuery(@NonNull Context context, @NonNull BroadcastQuery query);
+}
diff --git a/bbq/java/com/google/bbq/BroadcastQueryClient.java b/bbq/java/com/google/bbq/BroadcastQueryClient.java
new file mode 100644
index 0000000..9dd3e2a
--- /dev/null
+++ b/bbq/java/com/google/bbq/BroadcastQueryClient.java
@@ -0,0 +1,363 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.util.Log;
+import com.google.bbq.proto.BroadcastQuery;
+import com.google.bbq.proto.BroadcastQueryResponse;
+import com.squareup.wire.Message;
+import java.io.IOException;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import okio.ByteString;
+
+/**
+ * Dispatches broadcast queries to available data providers.
+ */
+public final class BroadcastQueryClient {
+
+    /**
+     * The default amount of time that this client will wait for responses from providers, before
+     * ignoring them.
+     */
+    public static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2);
+
+    private static final String LOG_TAG = "BroadcastQueryClient";
+
+    private static final AtomicReference<BroadcastQueryClient> INSTANCE =
+            new AtomicReference<>();
+
+    @NonNull
+    private final Context mContext;
+
+    @NonNull
+    private final SecureRandom mSecureRandom;
+
+    @NonNull
+    private final ConcurrentHashMap<Long, PendingQuery> mPendingQueries;
+
+    @NonNull
+    private final ScheduledExecutorService mExecutorService;
+
+    @NonNull
+    private final AtomicBoolean mDisposed;
+
+    /**
+     * Retrieves the global instance of the broadcast query client for the application
+     * associated to the provided context.
+     */
+    @NonNull
+    public static BroadcastQueryClient getApplicationBoundInstance(Context context) {
+        Context applicationContext = context.getApplicationContext();
+        BroadcastQueryClient client = new BroadcastQueryClient(applicationContext);
+        if (!INSTANCE.compareAndSet(null, client)) {
+            client.dispose();
+            client = INSTANCE.get();
+        }
+
+        return client;
+    }
+
+    BroadcastQueryClient(@NonNull Context context) {
+        mContext = context;
+        mSecureRandom = new SecureRandom();
+        mPendingQueries = new ConcurrentHashMap<>();
+        mExecutorService = Executors.newSingleThreadScheduledExecutor();
+        mDisposed = new AtomicBoolean(false);
+    }
+
+    /**
+     * Dispatches a query for the specified data type, carrying the specified protocol buffer
+     * message (if required). The response to this query will be provided to the specified callback.
+     * A {@link #DEFAULT_TIMEOUT_MS default timeout} will be used.
+     */
+    public void queryFor(
+            @NonNull String dataType,
+            @Nullable Message queryMessage,
+            @NonNull QueryCallback callback) {
+        queryFor(dataType,
+                queryMessage,
+                DEFAULT_TIMEOUT_MS,
+                callback);
+    }
+
+    /**
+     * Dispatches a query for the specified data type, carrying the specified protocol buffer
+     * message (if required). The response to this query will be provided to the specified callback.
+     */
+    public void queryFor(
+            @NonNull String dataType,
+            @Nullable Message queryMessage,
+            long timeoutInMs,
+            @NonNull QueryCallback callback) {
+        queryFor(dataType,
+                queryMessage != null ? queryMessage.encode() : null,
+                timeoutInMs,
+                callback);
+    }
+
+    /**
+     * Dispatches a query for the specified data type, carrying the specified message (if required).
+     * The response to this query will be provided to the specified callback.
+     */
+    public void queryFor(
+            @NonNull String dataType,
+            @Nullable byte[] queryMessage,
+            long timeoutInMs,
+            @NonNull QueryCallback callback) {
+        require(!TextUtils.isEmpty(dataType), "dataType must not be null or empty");
+        require(timeoutInMs > 0, "Timeout must be greater than zero");
+        require(callback, notNullValue());
+        require(!isDisposed(), "BroadcastQueryClient has been disposed");
+
+        PendingQuery pq = new PendingQuery(
+                dataType,
+                queryMessage,
+                timeoutInMs,
+                callback);
+
+        long queryId;
+        do {
+            queryId = mSecureRandom.nextLong();
+        } while (mPendingQueries.putIfAbsent(queryId, pq) != null);
+        pq.dispatch(queryId);
+    }
+
+    /**
+     * Disposes all leakable resources associated with this client.
+     */
+    private void dispose() {
+        if (!mDisposed.compareAndSet(false, true)) {
+            return;
+        }
+
+        mExecutorService.shutdownNow();
+        for (PendingQuery pq : mPendingQueries.values()) {
+            mContext.unregisterReceiver(pq.mResponseReceiver);
+        }
+    }
+
+    /**
+     * Determines whether this client has been disposed, and therefore should no longer be used.
+     */
+    private boolean isDisposed() {
+        return mDisposed.get();
+    }
+
+    private Intent createQueryIntent(
+            PendingQuery pendingQuery,
+            String responderPackage,
+            long responseId) {
+        Intent queryIntent = QueryUtil.createEmptyQueryIntent(pendingQuery.mDataType);
+        queryIntent.setPackage(responderPackage);
+        queryIntent.putExtra(QueryUtil.EXTRA_QUERY_MESSAGE,
+                new BroadcastQuery.Builder()
+                        .requestingApp(mContext.getPackageName())
+                        .dataType(pendingQuery.mDataType)
+                        .requestId(pendingQuery.mQueryId)
+                        .responseId(responseId)
+                        .queryMessage(pendingQuery.mQueryMessage != null
+                                ? ByteString.of(pendingQuery.mQueryMessage)
+                                : null)
+                        .build()
+                        .encode());
+        return queryIntent;
+    }
+
+    private final class PendingQuery {
+        final String mDataType;
+        final byte[] mQueryMessage;
+        final Map<Long, String> mRespondersById;
+        final CopyOnWriteArraySet<Long> mPendingResponses;
+        final ConcurrentHashMap<String, QueryResponse> mResponses;
+        final QueryCallback mQueryCallback;
+        final long mTimeoutInMs;
+
+        long mQueryId;
+        ScheduledFuture<Void> mTimeoutFuture;
+        BroadcastReceiver mResponseReceiver;
+
+        PendingQuery(
+                String dataType,
+                byte[] queryMessage,
+                long timeoutInMs,
+                QueryCallback queryCallback) {
+            mDataType = dataType;
+            mQueryMessage = queryMessage;
+            mTimeoutInMs = timeoutInMs;
+
+            mRespondersById = buildRespondersById();
+            mPendingResponses = new CopyOnWriteArraySet<>();
+            for (long responderId : mRespondersById.keySet()) {
+                mPendingResponses.add(responderId);
+            }
+            mResponses = new ConcurrentHashMap<>();
+            mQueryCallback = queryCallback;
+        }
+
+        Map<Long, String> buildRespondersById() {
+            Set<String> responders = QueryUtil.getRespondersForDataType(mContext, mDataType);
+            HashMap<Long, String> tempRespondersById = new HashMap<>();
+            for (String responderPackage : responders) {
+                long responderId;
+                do {
+                    responderId = mSecureRandom.nextLong();
+                } while (tempRespondersById.containsKey(responderId));
+
+                tempRespondersById.put(responderId, responderPackage);
+            }
+            return tempRespondersById;
+        }
+
+        void dispatch(long queryId) {
+            mQueryId = queryId;
+
+            if (mRespondersById.isEmpty()) {
+                complete();
+                return;
+            }
+
+            mResponseReceiver = new ResponseHandler(this);
+            mContext.registerReceiver(mResponseReceiver, getResponseFilter());
+
+            for (Map.Entry<Long, String> responderEntry : mRespondersById.entrySet()) {
+                long responseId = responderEntry.getKey();
+                String responderPackage = responderEntry.getValue();
+                mContext.sendBroadcast(createQueryIntent(this, responderPackage, responseId));
+            }
+
+            mTimeoutFuture = mExecutorService.schedule(
+                    new QueryTimeoutHandler(this),
+                    mTimeoutInMs,
+                    TimeUnit.MILLISECONDS);
+        }
+
+        void complete() {
+            if (!mPendingQueries.remove(mQueryId, this)) {
+                // response already delivered
+                return;
+            }
+
+            if (mTimeoutFuture != null) {
+                mTimeoutFuture.cancel(false);
+            }
+
+            if (mResponseReceiver != null) {
+                mContext.unregisterReceiver(mResponseReceiver);
+            }
+
+            mQueryCallback.onResponse(mQueryId, new ArrayList<>(mResponses.values()));
+        }
+
+        IntentFilter getResponseFilter() {
+            IntentFilter filter = new IntentFilter();
+            filter.addAction(QueryUtil.createResponseAction(mDataType, mQueryId));
+            filter.addCategory(QueryUtil.BBQ_CATEGORY);
+            return filter;
+        }
+    }
+
+    /**
+     * Forcibly completes a pending query when a timeout is reached.
+     */
+    private final class QueryTimeoutHandler implements Callable<Void> {
+
+        final PendingQuery mPendingQuery;
+
+        QueryTimeoutHandler(PendingQuery pendingQuery) {
+            mPendingQuery = pendingQuery;
+        }
+
+        @Override
+        public Void call() throws Exception {
+            mPendingQuery.complete();
+            return null;
+        }
+    }
+
+    /**
+     * Captures broadcast responses for queries.
+     */
+    private final class ResponseHandler extends BroadcastReceiver {
+
+        final PendingQuery mPendingQuery;
+
+        ResponseHandler(PendingQuery pendingQuery) {
+            mPendingQuery = pendingQuery;
+        }
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            byte[] responseBytes = intent.getByteArrayExtra(QueryUtil.EXTRA_RESPONSE_MESSAGE);
+            if (responseBytes == null) {
+                Log.w(LOG_TAG, "Received query response without a defined message");
+                return;
+            }
+
+            BroadcastQueryResponse response;
+            try {
+                response = BroadcastQueryResponse.ADAPTER.decode(responseBytes);
+            } catch (IOException e) {
+                Log.w(LOG_TAG, "Unable to parse query response message");
+                return;
+            }
+
+            String responder = mPendingQuery.mRespondersById.get(response.responseId);
+            if (responder == null) {
+                Log.w(LOG_TAG, "Received response from unknown responder");
+                return;
+            }
+
+            if (!mPendingQuery.mPendingResponses.remove(response.responseId)) {
+                Log.w(LOG_TAG, "Duplicate response received; ignoring");
+                return;
+            }
+
+            if (response.responseMessage != null) {
+                QueryResponse queryResponse = new QueryResponse(
+                        responder,
+                        response.responseId,
+                        response.responseMessage.toByteArray());
+                mPendingQuery.mResponses.put(responder, queryResponse);
+            }
+
+            if (mPendingQuery.mPendingResponses.isEmpty()) {
+                mPendingQuery.complete();
+            }
+        }
+    }
+}
diff --git a/bbq/java/com/google/bbq/QueryCallback.java b/bbq/java/com/google/bbq/QueryCallback.java
new file mode 100644
index 0000000..e317bce
--- /dev/null
+++ b/bbq/java/com/google/bbq/QueryCallback.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import java.util.List;
+
+/**
+ * Interface for receiving a query response.
+ */
+public interface QueryCallback {
+
+    /**
+     * Invoked when the specified query completes, with the collection of responses that were
+     * received within the allowed time.
+     *
+     * @see {@link BroadcastQueryClient#queryFor}
+     */
+    void onResponse(long queryId, List<QueryResponse> responses);
+}
diff --git a/bbq/java/com/google/bbq/QueryResponse.java b/bbq/java/com/google/bbq/QueryResponse.java
new file mode 100644
index 0000000..17d0120
--- /dev/null
+++ b/bbq/java/com/google/bbq/QueryResponse.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * A query response received from an eligible provider.
+ */
+public class QueryResponse implements Parcelable {
+
+    /**
+     * Parcelable creator for {@link QueryResponse} instances.
+     * @see android.os.Parcelable
+     */
+    public static final Creator<QueryResponse> CREATOR = new QueryResponseCreator();
+
+    /**
+     * The package name of the responder.
+     */
+    @NonNull
+    public final String responderPackage;
+
+    /**
+     * The unique response ID associated with this responder.
+     */
+    public final long responseId;
+
+    /**
+     * The data-type specific response message, if available. The semantics of the response message
+     * are query data-type specific, however a general convention is that if the response message
+     * is not specified, then the provider is unable to provide the requested data.
+     */
+    @Nullable
+    public final byte[] responseMessage;
+
+    /**
+     * Creates a query response.
+     */
+    public QueryResponse(
+            @NonNull String responderPackage,
+            long responseId,
+            @Nullable byte[] responseMessage) {
+        require(responderPackage, notNullValue());
+        this.responderPackage = responderPackage;
+        this.responseId = responseId;
+        this.responseMessage = responseMessage;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(responderPackage);
+        dest.writeLong(responseId);
+        dest.writeInt(responseMessage != null ? 1 : 0);
+
+        if (responseMessage != null) {
+            dest.writeInt(responseMessage.length);
+            dest.writeByteArray(responseMessage);
+        }
+    }
+
+    private static final class QueryResponseCreator implements Creator<QueryResponse> {
+
+        @Override
+        public QueryResponse createFromParcel(Parcel source) {
+            String responderPackage = source.readString();
+            long responseId = source.readLong();
+            byte[] responseMessage = null;
+            if (source.readInt() != 0) {
+                int responseMessageSize = source.readInt();
+                responseMessage = new byte[responseMessageSize];
+                source.readByteArray(responseMessage);
+            }
+            return new QueryResponse(responderPackage, responseId, responseMessage);
+        }
+
+        @Override
+        public QueryResponse[] newArray(int size) {
+            return new QueryResponse[size];
+        }
+    }
+}
diff --git a/bbq/java/com/google/bbq/QueryResponseSender.java b/bbq/java/com/google/bbq/QueryResponseSender.java
new file mode 100644
index 0000000..8fae24c
--- /dev/null
+++ b/bbq/java/com/google/bbq/QueryResponseSender.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import com.google.bbq.proto.BroadcastQuery;
+import com.google.bbq.proto.BroadcastQueryResponse;
+import okio.ByteString;
+
+
+/**
+ * A utility for data providers that encodes and sends query responses.
+ */
+public class QueryResponseSender {
+
+    private static final String LOG_TAG = "QueryResponseSender";
+
+    private final Context mContext;
+
+    /**
+     * Creates a response sender.
+     */
+    public QueryResponseSender(@NonNull Context context) {
+        mContext = require(context, notNullValue());
+    }
+
+    /**
+     * Dispatches a query response message for the specified query.
+     */
+    public void sendResponse(
+            @NonNull BroadcastQuery query,
+            @Nullable byte[] responseMessage) {
+        require(query, notNullValue());
+
+        BroadcastQueryResponse.Builder responseBuilder = createResponseBuilder(query);
+        if (responseMessage != null) {
+            responseBuilder.responseMessage = ByteString.of(responseMessage);
+        }
+
+        Intent responseBroadcast = getIntentForQuery(query, responseBuilder);
+
+        mContext.sendBroadcast(responseBroadcast);
+    }
+
+    @VisibleForTesting
+    @NonNull
+    Intent getIntentForQuery(@NonNull BroadcastQuery query,
+                             BroadcastQueryResponse.Builder responseBuilder) {
+        Intent responseBroadcast =
+                new Intent(QueryUtil.createResponseAction(query.dataType, query.requestId));
+        responseBroadcast.addCategory(QueryUtil.BBQ_CATEGORY);
+        responseBroadcast.setPackage(query.requestingApp);
+        responseBroadcast.putExtra(
+                QueryUtil.EXTRA_RESPONSE_MESSAGE,
+                responseBuilder.build().encode());
+        return responseBroadcast;
+    }
+
+    private BroadcastQueryResponse.Builder createResponseBuilder(BroadcastQuery query) {
+        return new BroadcastQueryResponse.Builder()
+                .requestId(query.requestId)
+                .responseId(query.responseId);
+    }
+}
diff --git a/bbq/java/com/google/bbq/QueryUtil.java b/bbq/java/com/google/bbq/QueryUtil.java
new file mode 100644
index 0000000..4bac651
--- /dev/null
+++ b/bbq/java/com/google/bbq/QueryUtil.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Utility methods related to query message construction and dispatch.
+ */
+public final class QueryUtil {
+
+    /**
+     * The category attached to all broadcast intents sent as part of the BBQ protocol.
+     */
+    public static final String BBQ_CATEGORY = "com.google.bbq.QUERY";
+
+    /**
+     * The extra field used to carry query messages in broadcast intents.
+     */
+    public static final String EXTRA_QUERY_MESSAGE = "com.google.bbq.message";
+
+    /**
+     * The extra field used to carry query response messages in broadcast intents.
+     */
+    public static final String EXTRA_RESPONSE_MESSAGE = "com.google.bbq.response";
+
+    private static final int HALF_BYTE_WIDTH = 4;
+    private static final int HALF_BYTE_MASK = 0xF;
+
+    private static final char[] HEX_DIGITS =
+            { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+
+    private QueryUtil() {}
+
+    /**
+     * Creates the basic structure of an intent used to dispatch a query.
+     */
+    public static Intent createEmptyQueryIntent(@NonNull String dataType) {
+        require(!TextUtils.isEmpty(dataType), "dataType must not be null or empty");
+        Intent queryIntent = new Intent(dataType);
+        queryIntent.addCategory(QueryUtil.BBQ_CATEGORY);
+        return queryIntent;
+    }
+
+    /**
+     * Creates the {@code ACTION} string that is used for registering query response broadcast
+     * receivers, based on the data type of the query and the unique request ID.
+     */
+    public static String createResponseAction(@NonNull String dataType, long requestId) {
+        require(dataType, notNullValue());
+        return dataType + ":" + longAsHex(requestId);
+    }
+
+    /**
+     * Determines the set of providers who may be able to provide data of the specified type,
+     * based on their declared broadcast query receivers.
+     */
+    public static Set<String> getRespondersForDataType(@NonNull Context context,
+                                                       @NonNull String dataType) {
+        require(context, notNullValue());
+        require(dataType, notNullValue());
+
+        PackageManager packageManager = context.getPackageManager();
+
+        Intent intent = new Intent(dataType);
+        intent.addCategory(QueryUtil.BBQ_CATEGORY);
+        List<ResolveInfo> responderInfos =
+                packageManager.queryBroadcastReceivers(intent, PackageManager.GET_RESOLVED_FILTER);
+
+        HashSet<String> responders = new HashSet<>();
+        for (ResolveInfo info : responderInfos) {
+            responders.add(info.activityInfo.packageName);
+        }
+
+        return responders;
+    }
+
+    @VisibleForTesting
+    static String longAsHex(long val) {
+        char[] result = new char[Long.SIZE / Byte.SIZE * 2];
+        int index = result.length - 1;
+        while (index >= 0) {
+            result[index--] = HEX_DIGITS[(int)(val & HALF_BYTE_MASK)];
+            val >>>= HALF_BYTE_WIDTH;
+            result[index--] = HEX_DIGITS[(int)(val & HALF_BYTE_MASK)];
+            val >>>= HALF_BYTE_WIDTH;
+        }
+
+        return new String(result);
+    }
+}
diff --git a/bbq/java/com/google/bbq/package-info.java b/bbq/java/com/google/bbq/package-info.java
new file mode 100644
index 0000000..6a278c1
--- /dev/null
+++ b/bbq/java/com/google/bbq/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Reference implementation of the BBQ specification.
+ */
+package com.google.bbq;
diff --git a/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java b/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java
new file mode 100644
index 0000000..5947570
--- /dev/null
+++ b/bbq/javatests/java/com/google/bbq/BaseBroadcastQueryReceiverTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.google.bbq;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import com.google.bbq.proto.BroadcastQuery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for the BaseBroadcastQueryReceiver
+ */
+@RunWith(org.robolectric.RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class BaseBroadcastQueryReceiverTest {
+    BaseBroadcastQueryReceiver underTest;
+    String logtag = "logtag";
+
+    @Mock
+    Context mockContext;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+
+        underTest = new BaseBroadcastQueryReceiver(logtag) {
+            @Override
+            protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
+
+            }
+        };
+    }
+
+    @Test
+    public void testOnReceive_null() throws Exception {
+        underTest.onReceive(mockContext, new Intent());
+        verify(mockContext, never()).getPackageManager();
+    }
+
+    @Test
+    public void testOnReceive_emptyArray() throws Exception {
+        Intent intent = new Intent();
+
+        intent.putExtra(QueryUtil.EXTRA_QUERY_MESSAGE, new byte[256]);
+        underTest.onReceive(mockContext, intent);
+        verify(mockContext, never()).getPackageManager();
+    }
+
+}
\ No newline at end of file
diff --git a/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java b/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
new file mode 100644
index 0000000..cb4e799
--- /dev/null
+++ b/bbq/javatests/java/com/google/bbq/BroadcastQueryClientTest.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.google.bbq;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Battery of tests for BroadcastQueryClient
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class BroadcastQueryClientTest {
+    @Mock
+    private Context mockContext;
+    @Mock
+    private PackageManager mockPackageManager;
+
+    private BroadcastQueryClient underTest;
+    private ArrayList<ResolveInfo> mPackageinfos;
+
+    @org.junit.Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        underTest = new BroadcastQueryClient(mockContext);
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+
+        ResolveInfo mockinfo1=new ResolveInfo();
+        mockinfo1.activityInfo = new ActivityInfo();
+        mockinfo1.activityInfo.packageName= "com.openyolo";
+
+        ResolveInfo mockinfo2=new ResolveInfo();
+        mockinfo2.activityInfo = new ActivityInfo();
+        mockinfo2.activityInfo.packageName= "com.google";
+
+        mPackageinfos = new ArrayList<>(2);
+        mPackageinfos.add(mockinfo1);
+        mPackageinfos.add(mockinfo2);
+
+        when(mockPackageManager.queryBroadcastReceivers(any(Intent.class),
+                anyInt())).thenReturn(mPackageinfos);
+    }
+
+    @Test
+    public void queryFor() throws Exception {
+        String dataType = "datatype";
+        byte[] queryMessage = new byte[64];
+        SecureRandom sr = new SecureRandom();
+        sr.nextBytes(queryMessage);
+        long timeoutInMs = 500L;
+        QueryCallback callback = new QueryCallback() {
+            @Override
+            public void onResponse(long queryId, List<QueryResponse> responses) {
+                //not expecting the callback as this is happening through broadcasts.
+                //if we get here, fail so it raises some eyebrows...
+                fail();
+            }
+        };
+
+        underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
+        verify(mockContext, times(1)).registerReceiver(any(BroadcastReceiver.class),
+                any(IntentFilter.class));
+        verify(mockContext, times(mPackageinfos.size())).sendBroadcast(any(Intent.class));
+
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void queryFor_negative_timestamp() throws Exception {
+        String dataType = "datatype";
+        byte[] queryMessage = new byte[64];
+        SecureRandom sr = new SecureRandom();
+        sr.nextBytes(queryMessage);
+        long timeoutInMs = -500L;
+        QueryCallback callback = new QueryCallback() {
+            @Override
+            public void onResponse(long queryId, List<QueryResponse> responses) {
+                //not expecting the callback as this is happening through broadcasts.
+                //if we get here, fail so it raises some eyebrows...
+                fail();
+            }
+        };
+
+        underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void queryFor_pushNullDatatype() throws Exception {
+        String dataType = null;
+        byte[] queryMessage = new byte[64];
+        SecureRandom sr = new SecureRandom();
+        sr.nextBytes(queryMessage);
+        long timeoutInMs = 500L;
+        QueryCallback callback = new QueryCallback() {
+            @Override
+            public void onResponse(long queryId, List<QueryResponse> responses) {
+            }
+        };
+
+        underTest.queryFor(dataType, queryMessage, timeoutInMs, callback);
+
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void queryFor_pushNullCallback() throws Exception {
+        String dataType = "datatype";
+        byte[] queryMessage = new byte[64];
+        SecureRandom sr = new SecureRandom();
+        sr.nextBytes(queryMessage);
+        long timeoutInMs = 500L;
+        underTest.queryFor(dataType, queryMessage, timeoutInMs, null);
+
+    }
+
+}
\ No newline at end of file
diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
new file mode 100644
index 0000000..c9ef20c
--- /dev/null
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseSenderTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.internal.verification.VerificationModeFactory.times;
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import com.google.bbq.proto.BroadcastQuery;
+import com.google.bbq.proto.BroadcastQueryResponse;
+import com.google.bbq.proto.Parameter;
+import java.util.LinkedList;
+import java.util.List;
+import okio.ByteString;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.valid4j.errors.RequireViolation;
+
+
+/**
+ * This class contains a set of tests for QueryResponseSenderTest.
+ */
+public class QueryResponseSenderTest {
+    @Mock
+    Context mockContext;
+    @Mock
+    Intent mockIntent;
+
+    BroadcastQuery mockQuery;
+
+    private QueryResponseSender underTest;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+
+        //set mock values.
+        List<Parameter> additionalArgs = new LinkedList<>();
+        mockQuery = new BroadcastQuery("dataType", "requestingApp", 128L, 256L, ByteString.EMPTY, additionalArgs);
+
+        //Create a test object for the QueryResponseSender using the mock
+        underTest = new QueryResponseSender(mockContext) {
+            @NonNull
+            @Override
+            Intent getIntentForQuery(@NonNull BroadcastQuery query, BroadcastQueryResponse.Builder responseBuilder) {
+                return mockIntent;
+            }
+        };
+    }
+
+    @Test
+    public void sendResponse_nonNullQuery_nullReponse() throws Exception {
+        underTest.sendResponse(mockQuery, null);
+        verify(mockContext, times(1)).sendBroadcast(mockIntent);
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void sendResponse_nullQuery_nullReponse() throws Exception {
+        underTest.sendResponse(null, null);
+    }
+}
\ No newline at end of file
diff --git a/bbq/javatests/java/com/google/bbq/QueryResponseTest.java b/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
new file mode 100644
index 0000000..091add1
--- /dev/null
+++ b/bbq/javatests/java/com/google/bbq/QueryResponseTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bbq;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.internal.verification.VerificationModeFactory.times;
+import android.os.Parcel;
+import java.security.SecureRandom;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Battery of tests for the QueryResponse
+ */
+public class QueryResponseTest {
+    @Mock
+    private Parcel mockParcel;
+
+    private QueryResponse underTest;
+    private String mResponderPackage = "mResponderPackage";
+    private long mResponseId = 128L;
+    private byte[] mResponseMessage = new byte[64];
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        SecureRandom sr = new SecureRandom();
+        sr.nextBytes(mResponseMessage);
+
+        underTest = new QueryResponse(mResponderPackage, mResponseId, mResponseMessage);
+    }
+
+    @Test
+    public void testDescribeContents() throws Exception {
+        assertEquals(0, underTest.describeContents());
+    }
+
+    @Test
+    public void testWriteToParcel_WithResponseMessage() throws Exception {
+        underTest.writeToParcel(mockParcel, anyInt());
+        verify(mockParcel, times(1)).writeString(mResponderPackage);
+        verify(mockParcel, times(1)).writeLong(mResponseId);
+        verify(mockParcel, times(1)).writeInt(1);
+        verify(mockParcel, times(1)).writeInt(64);
+        verify(mockParcel, times(1)).writeByteArray(mResponseMessage);
+    }
+
+    @Test
+    public void testWriteToParcel_WithOutResponseMessage() throws Exception {
+        underTest = new QueryResponse(mResponderPackage, mResponseId, null);
+        underTest.writeToParcel(mockParcel, anyInt());
+        verify(mockParcel, times(1)).writeString(mResponderPackage);
+        verify(mockParcel, times(1)).writeLong(mResponseId);
+        verify(mockParcel, times(1)).writeInt(0);
+        verify(mockParcel, never()).writeByteArray(mResponseMessage);
+    }
+
+}
\ No newline at end of file
diff --git a/bbq/javatests/java/com/google/bbq/QueryUtilTest.java b/bbq/javatests/java/com/google/bbq/QueryUtilTest.java
new file mode 100644
index 0000000..f57ff7c
--- /dev/null
+++ b/bbq/javatests/java/com/google/bbq/QueryUtilTest.java
@@ -0,0 +1,118 @@
+/*
+ *
+ *  Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+package com.google.bbq;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import java.util.ArrayList;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Battery of tests for The intent handling utility within BBQ
+ */
+@RunWith(org.robolectric.RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class QueryUtilTest {
+
+    @Mock
+    private Context mockContext;
+    @Mock
+    private PackageManager mockPackageManager;
+
+    private ArrayList<ResolveInfo> mPackageinfos;
+    private ResolveInfo mockinfo2;
+    private ResolveInfo mockinfo1;
+
+    @org.junit.Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        mockinfo1=new ResolveInfo();
+        mockinfo1.activityInfo = new android.content.pm.ActivityInfo();
+        mockinfo1.activityInfo.packageName= "com.openyolo";
+
+        mockinfo2=new ResolveInfo();
+        mockinfo2.activityInfo = new android.content.pm.ActivityInfo();
+        mockinfo2.activityInfo.packageName= "com.google";
+
+        mPackageinfos = new java.util.ArrayList<>(2);
+        mPackageinfos.add(mockinfo1);
+        mPackageinfos.add(mockinfo2);
+
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+        when(mockPackageManager.queryBroadcastReceivers(any(Intent.class),
+                anyInt())).thenReturn(mPackageinfos);
+
+
+    }
+
+    @Test
+    public void testCreateEmptyQueryIntent_ValidData() throws Exception {
+        String mockCategory = "MockCategory";
+        Intent result = QueryUtil.createEmptyQueryIntent(mockCategory);
+        Set<String> categories = result.getCategories();
+        assertEquals(1, categories.size());
+        assertTrue(categories.contains(QueryUtil.BBQ_CATEGORY));
+        result.getAction().equals(mockCategory);
+    }
+    @Test(expected = RequireViolation.class)
+    public void testCreateEmptyQueryIntent_InvalidData() throws Exception {
+        QueryUtil.createEmptyQueryIntent(null);
+    }
+
+    @Test
+    public void testCreateResponseAction_ValidData() throws Exception {
+        String dataType = "datatype";
+        long requestId = 128L;
+        String action = QueryUtil.createResponseAction(dataType, requestId);
+        assertTrue((dataType + ":" + QueryUtil.longAsHex(requestId)).equals(action));
+    }
+
+    @Test
+    public void testCreateResponseAction_InvalidData() throws Exception {
+        String dataType = "datatype";
+        long requestId = 128L;
+        String action = QueryUtil.createResponseAction(dataType, requestId);
+        assertTrue((dataType + ":" + QueryUtil.longAsHex(requestId)).equals(action));
+    }
+
+    @Test
+    public void getRespondersForDataType() throws Exception {
+        String dataType = "dataType";
+        Set<String> result = QueryUtil.getRespondersForDataType(mockContext, dataType);
+        assertEquals(2, result.size());
+        assertTrue(result.contains(mockinfo1.activityInfo.packageName));
+        assertTrue(result.contains(mockinfo2.activityInfo.packageName));
+    }
+
+}
\ No newline at end of file
diff --git a/bbq/proto/bbq.proto b/bbq/proto/bbq.proto
new file mode 100644
index 0000000..b8b55ec
--- /dev/null
+++ b/bbq/proto/bbq.proto
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package com.google.bbq;
+
+option java_package = "com.google.bbq.proto";
+
+message BroadcastQuery {
+	optional string       dataType         = 1; // required
+	optional string       requestingApp    = 2; // required
+	optional sfixed64     requestId        = 3; // required
+	optional sfixed64     responseId       = 4; // required
+	optional bytes        queryMessage     = 5;
+	repeated Parameter    additionalParams = 6;
+}
+
+message BroadcastQueryResponse {
+	optional sfixed64  requestId             = 1; // required
+	optional sfixed64  responseId            = 2; // required
+	optional bytes     responseMessage       = 3;
+	repeated Parameter additionalParams      = 4;
+}
+
+message Parameter {
+	optional string name  = 1; // required
+	optional bytes  value = 2;
+}
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..fb0cdbe
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,62 @@
+apply from: 'config/localprops.gradle'
+apply from: 'config/keystore.gradle'
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+
+    dependencies {
+        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
+        classpath 'org.ajoberstar:gradle-git:1.6.0'
+        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
+    }
+}
+
+try {
+    def grgit = org.ajoberstar.grgit.Grgit.open(dir: '.')
+    def lastCommit = grgit.head()
+
+    project.ext.versionNum = grgit.log(includes:['HEAD']).size()
+    project.ext.versionDate = lastCommit.getDate()
+    project.ext.versionName = grgit.describe()
+    if (project.ext.versionName == null) {
+        project.ext.versionName = "DEV"
+    }
+} catch (Exception ex) {
+    logger.lifecycle(
+        "unable to infer version information from git - using defaults")
+    project.ext.versionNum = 0
+    project.ext.versionDate = new Date()
+    project.ext.versionName = 'DEV'
+}
+
+task showVersion << {
+    logger.lifecycle("Version ID: " + project.versionNum)
+    logger.lifecycle("Version Date: " + project.versionDate)
+    logger.lifecycle("Version Name: " + project.versionName)
+}
+
+project.ext.minSdkVersion = 15
+project.ext.compileSdkVersion = 25
+project.ext.buildToolsVersion = '25.0.2'
+project.ext.supportLibVersion = '25.1.1'
+
+subprojects {
+    repositories {
+        jcenter()
+
+        maven {
+          url "${rootProject.androidSdkDir}/extras/android/m2repository"
+        }
+    }
+
+    group = "org.openyolo"
+    version = versionName
+}
+
+task wrapper(type: Wrapper) {
+    gradleVersion = '3.3'
+}
diff --git a/config/android-common.gradle b/config/android-common.gradle
new file mode 100644
index 0000000..4a3fe96
--- /dev/null
+++ b/config/android-common.gradle
@@ -0,0 +1,33 @@
+android {
+    compileSdkVersion rootProject.compileSdkVersion
+    buildToolsVersion rootProject.buildToolsVersion
+
+    defaultConfig {
+        minSdkVersion rootProject.minSdkVersion
+        targetSdkVersion rootProject.compileSdkVersion
+        versionCode rootProject.versionNum
+        versionName rootProject.versionName
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['java']
+        main.aidl.srcDirs = ['java']
+        main.res.srcDir 'res'
+        main.assets.srcDir 'assets'
+        main.resources.srcDir 'java'
+
+        test.setRoot('javatests');
+        test.java.srcDir('javatests');
+    }
+
+    lintOptions {
+        warningsAsErrors true
+        disable 'InvalidPackage', 'TrulyRandom', 'GradleDependency'
+    }
+
+    packagingOptions {
+        exclude 'META-INF/LICENSE.txt'
+        exclude 'META-INF/NOTICE.txt'
+    }
+}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000..f88cb96
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,480 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+
+<!--
+Checkstyle-Configuration: Android Style
+Description: https://source.android.com/source/code-style.html
+-->
+<module name="Checker">
+  <property name="fileExtensions" value="java, properties, xml"/>
+
+  <!-- Require UTF-8 encoding for all files -->
+  <property name="charset" value="UTF-8"/>
+
+  <!-- Default severity is error -->
+  <property name="severity" value="warning"/>
+
+  <!-- Warnings can be suppressed by adding them to this file -->
+  <module name="SuppressionFilter">
+    <property name="file" value="${checkstyle.suppressions}"/>
+  </module>
+
+  <module name="TreeWalker">
+
+    <!--#################################################################-->
+    <!--################ NAMING CHECKS ##################################-->
+    <!--#################################################################-->
+
+    <!-- Require package names to be all lower-case -->
+    <module name="PackageName">
+        <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
+        <message key="name.invalidPattern"
+                 value="Package name ''{0}'' must be lower-case."/>
+    </module>
+
+    <!-- Require standard type names -->
+    <module name="TypeName">
+        <message key="name.invalidPattern"
+         value="Type name ''{0}'' must begin with a capital letter."/>
+    </module>
+
+    <!--
+    Type parameters must either be a single upper-case character, or must begin
+    with an upper-case character and end with "T" (e.g. DataT).
+    -->
+    <module name="ClassTypeParameterName">
+      <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
+      <message key="name.invalidPattern"
+               value="Class type parameter ''{0}'' must either be a single upper-case character, or begin with an upper-case character and end with 'T'."/>
+    </module>
+
+    <!-- Non-public, non-static members must start with "m" -->
+    <module name="MemberName">
+      <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
+      <property name="applyToPublic" value="false"/>
+      <message key="name.invalidPattern"
+               value="Member name ''{0}'' must be prefixed with m and be at least two characters long."/>
+    </module>
+
+    <!--
+    Require method names to be at least two characters long, and start with a
+    lower case letter.
+    -->
+    <module name="MethodName">
+      <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
+      <message key="name.invalidPattern"
+               value="Method name ''{0}'' must be at least two characters long."/>
+    </module>
+
+    <!--
+    Type parameters must either be a single upper-case character, or must begin
+    with an upper-case character and end with "T" (e.g. DataT).
+    -->
+    <module name="MethodTypeParameterName">
+      <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]+[T]$)"/>
+      <message key="name.invalidPattern"
+               value="Method type parameter ''{0}'' must either be a single upper-case character or begin with an upper-case character and end with 'T'."/>
+    </module>
+
+    <!-- Require parameter names to be at least two characters long -->
+    <module name="ParameterName">
+        <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
+        <message key="name.invalidPattern"
+                 value="Parameter name ''{0}'' must be at least two characters long."/>
+    </module>
+
+    <!--
+    Require local variables to be at least two characters long,
+    unless they are counters on a for loop.
+    -->
+    <module name="LocalVariableName">
+        <property name="tokens" value="VARIABLE_DEF"/>
+        <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
+        <property name="allowOneCharVarInForLoop" value="true"/>
+        <message key="name.invalidPattern"
+                 value="Local variable name ''{0}'' must be at least two characters long."/>
+    </module>
+
+    <!-- Require that constants be capitalized. -->
+    <module name="ConstantName"/>
+
+    <module name="LocalFinalVariableName"/>
+
+    <!--
+    Require that static, non-public, non-final variable names be prefixed
+    with "s".
+    -->
+    <module name="StaticVariableName">
+      <property name="format" value="^s[A-Z][a-zA-Z0-9]*$"/>
+      <message key="name.invalidPattern"
+               value="Static variable name ''{0}'' must be prefixed with s and be at least two characters long."/>
+    </module>
+
+    <!-- Capitalized abbreviations are forbidden (e.g. URL, XML, HTTP) -->
+    <module name="AbbreviationAsWordInName">
+        <property name="ignoreFinal" value="false"/>
+        <property name="allowedAbbreviationLength" value="1"/>
+    </module>
+
+    <!-- Forbid unnecessary escaping. -->
+    <module name="IllegalTokenText">
+      <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
+      <property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
+      <property name="message" value="Avoid using corresponding octal or Unicode escape."/>
+    </module>
+
+    <!-- Forbid unnecessary unicode escapes -->
+    <module name="AvoidEscapedUnicodeCharacters">
+        <property name="allowEscapesForControlCharacters" value="true"/>
+        <property name="allowByTailComment" value="true"/>
+        <property name="allowNonPrintableEscapes" value="true"/>
+    </module>
+
+    <!-- Require array notation on type (e.g. int[] x, not int x[]) -->
+    <module name="ArrayTypeStyle"/>
+
+    <!--###################################################-->
+    <!--################ IMPORTS ##########################-->
+    <!--###################################################-->
+
+    <!-- Star imports are forbidden. -->
+    <module name="AvoidStarImport"/>
+
+    <!--
+    Imports should be ordered such that static imports come before normal
+    imports. Within these groups (separated by an empty line), imports should
+    be lexicographially sorted with no further subcategorization required.
+     -->
+    <module name="CustomImportOrder">
+        <property name="sortImportsInGroupAlphabetically" value="true"/>
+        <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
+    </module>
+
+    <!-- Forbid imports from sun.* -->
+    <module name="IllegalImport"/>
+
+    <!-- Forbid redudant imports (e.g. import java.lang.String;) -->
+    <module name="RedundantImport"/>
+
+    <!-- Forbid unused imports -->
+    <module name="UnusedImports"/>
+
+    <!-- Forbid redundant modifiers -->
+    <module name="RedundantModifier"/>
+
+    <!--##############################################################-->
+    <!--################ STRUCTURAL / WRAPPING CHECKS ################-->
+    <!--##############################################################-->
+
+    <!-- Require One top-level class per file -->
+    <module name="OneTopLevelClass"/>
+
+    <!-- Line-wrapping in import statements is forbidden. -->
+    <module name="NoLineWrap"/>
+
+    <!-- Empty catch blocks are forbidden. -->
+    <module name="EmptyCatchBlock">
+      <property name="exceptionVariableName" value="expected|ignore"/>
+    </module>
+
+    <!-- Require braces for all code blocks -->
+    <module name="NeedBraces"/>
+
+    <!-- Require One statement per line (e.g. no "a = b; c = d;") -->
+    <module name="OneStatementPerLine"/>
+
+    <!-- Multiple variable declarations on one line is forbidden. -->
+    <module name="MultipleVariableDeclarations"/>
+
+    <!-- Require switch statements to have default clause -->
+    <module name="MissingSwitchDefault"/>
+
+    <!--
+    Case fall-through in switch statements is forbidden, except where an
+    explicit "// fall-through" comment exists.
+    -->
+    <module name="FallThrough">
+      <property name="reliefPattern" value="fall-through"/>
+    </module>
+
+    <!-- Require empty lines between definitions -->
+    <module name="EmptyLineSeparator">
+        <property name="allowNoEmptyLineBetweenFields" value="true"/>
+    </module>
+
+    <!-- Wrap only permitted before dot, e.g.
+    fluentInterface.doX()
+        .doY()
+        .doZ();
+    -->
+    <module name="SeparatorWrap">
+      <property name="tokens" value="DOT"/>
+      <property name="option" value="nl"/>
+    </module>
+
+    <!-- Wrap only permitted after comma, e.g.
+    doThings(withA,
+        withB,
+        withC);
+    -->
+    <module name="SeparatorWrap">
+        <property name="tokens" value="COMMA"/>
+        <property name="option" value="EOL"/>
+    </module>
+
+    <!-- require line breaks before common binary operators -->
+    <module name="OperatorWrap">
+        <property name="option" value="NL"/>
+        <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
+    </module>
+
+    <!--
+    Require that annotations on type, method and constructor definitions be on
+    a separate line.
+    -->
+    <module name="AnnotationLocation">
+      <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
+    </module>
+
+    <!--
+    Variable declarations may have annotations on the same line.
+    -->
+    <module name="AnnotationLocation">
+        <property name="tokens" value="VARIABLE_DEF"/>
+        <property name="allowSamelineMultipleAnnotations" value="true"/>
+    </module>
+
+    <!-- Forbid empty statements -->
+    <module name="EmptyStatement"/>
+
+    <!--#################################################################-->
+    <!--################ WHITESPACE / LINE LENGTH CHECKS ################-->
+    <!--#################################################################-->
+
+    <!-- Forbid whitespace after prefix unary operators and accessors -->
+    <module name="NoWhitespaceAfter">
+      <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
+    </module>
+
+    <!--
+    Forbid whitespace before comma, semi-colon, and postfix unary operators
+    -->
+    <module name="NoWhitespaceBefore"/>
+
+    <!-- Require whitespace around common tokens (=, if, etc.) -->
+    <module name="WhitespaceAround">
+      <property name="allowEmptyConstructors" value="true"/>
+      <property name="allowEmptyMethods" value="true"/>
+      <property name="allowEmptyTypes" value="true"/>
+      <property name="allowEmptyLoops" value="true"/>
+      <message key="ws.notFollowed"
+       value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
+       <message key="ws.notPreceded"
+       value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
+    </module>
+
+    <!-- Require standard whitespace around type parameters -->
+    <module name="GenericWhitespace">
+      <message key="ws.followed"
+               value="GenericWhitespace ''{0}'' is followed by whitespace."/>
+       <message key="ws.preceded"
+                value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
+       <message key="ws.illegalFollow"
+                value="GenericWhitespace ''{0}'' should followed by whitespace."/>
+       <message key="ws.notPreceded"
+                value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
+    </module>
+
+    <!-- Require Android standard indentation. -->
+    <module name="Indentation">
+        <property name="basicOffset" value="4"/>
+        <property name="braceAdjustment" value="0"/>
+        <property name="caseIndent" value="4"/>
+        <property name="throwsIndent" value="8"/>
+        <property name="lineWrappingIndentation" value="8"/>
+        <property name="arrayInitIndent" value="4"/>
+    </module>
+
+    <!--
+    Require that comments be placed at the same level of indentation as
+    surrounding code.
+    -->
+    <module name="CommentsIndentation"/>
+
+    <!-- 100 char per line max, unless unavoidable -->
+    <module name="LineLength">
+      <property name="max" value="100"/>
+      <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
+    </module>
+
+    <!--################################################-->
+    <!--################ JAVADOC CHECKS ################-->
+    <!--################################################-->
+
+    <!--
+    Require Javadoc for public methods:
+    https://source.android.com/source/code-style.html#use-javadoc-standard-comments
+    -->
+    <module name="JavadocMethod">
+      <property name="scope" value="public"/>
+      <!-- exception: property methods (getX, setX, isX) -->
+      <property name="allowMissingPropertyJavadoc" value="true"/>
+      <!-- exception: method overrides, test methods -->
+      <property name="allowedAnnotations" value="Override, Test, Before, After"/>
+
+      <!--
+      Every parameter need not be documented. This is to avoid the need for
+      redundant descriptions between the main description and the parameter
+      descriptions.
+      -->
+      <property name="allowMissingParamTags" value="true"/>
+      <!--
+      The return value need not be documented. This is to avoid the need for
+      redundant descriptions between the main description and the return value
+      descriptions.
+      -->
+      <property name="allowMissingReturnTag" value="true"/>
+      <property name="allowThrowsTagsForSubclasses" value="true"/>
+      <property name="suppressLoadErrors" value="true"/>
+    </module>
+
+    <!-- Javadoc required for public fields (part of API) -->
+    <module name="JavadocVariable">
+      <property name="scope" value="public"/>
+    </module>
+
+    <!-- Javadoc must be well-formed -->
+    <module name="JavadocStyle"/>
+
+    <!--
+    Require descriptions for all included @param / @return / @throws /
+    @deprecated tags in Javadoc comments.
+    -->
+    <module name="NonEmptyAtclauseDescription"/>
+
+    <!--
+    Require 4-character indentation of @param / @return / @throws / @deprecated
+    descriptions which span more than one line.
+    -->
+    <module name="JavadocTagContinuationIndentation"/>
+
+    <!--
+    Forbid pointless Javadoc summary sentences.
+    -->
+    <module name="SummaryJavadocCheck">
+      <property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
+    </module>
+
+    <!-- Require correct use of whitespace and <p> tags for Javadoc comments -->
+    <module name="JavadocParagraph"/>
+
+    <!-- Require correct order of Javadoc comment tags -->
+    <module name="AtclauseOrder">
+        <property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
+        <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
+    </module>
+
+    <!-- Single line Javadoc comments with a tag are forbidden. -->
+    <module name="SingleLineJavadoc">
+      <property name="ignoreInlineTags" value="false"/>
+    </module>
+
+    <!--
+    Require @deprecated Javadoc tag and @Deprecated annotation to be used
+    together.
+    -->
+    <module name="MissingDeprecated"/>
+
+    <!--#################################################################-->
+    <!--################ MISC. LANGUAGE CHECKS ##########################-->
+    <!--#################################################################-->
+
+    <!-- File name must correspond to contained class -->
+    <module name="OuterTypeFilename"/>
+
+    <!--
+    Long constants must be suffixed with L:
+    "The suffix L is preferred, because the letter l (ell) is often hard to
+    distinguish from the digit 1 (one)."
+    http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.1
+    -->
+    <module name="UpperEll"/>
+
+    <!--
+    Require modifier order consistent with recommends in JLS:
+    http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html
+    -->
+    <module name="ModifierOrder"/>
+
+    <!-- Finalizers are forbidden. -->
+    <module name="NoFinalizer"/>
+
+    <!-- overloaded methods must be grouped together -->
+    <module name="OverloadMethodsDeclarationOrder"/>
+
+    <!-- Require variables to be declared close to where they are used -->
+    <module name="VariableDeclarationUsageDistance"/>
+
+    <!-- Require that equals() and hashCode() are overridden together -->
+    <module name="EqualsHashCode"/>
+
+    <!-- Forbid shadowing fields or variables -->
+    <module name="HiddenField">
+      <!-- exception: constructor parameters -->
+      <property name="ignoreConstructorParameter" value="true"/>
+      <!-- exception: setter method parameters -->
+      <property name="ignoreSetter" value="true"/>
+    </module>
+
+    <!--
+    Forbid assignments in expressions, with the exception of loop conditions
+    -->
+    <module name="InnerAssignment"/>
+
+    <!-- Require @Override on overridden methods -->
+    <module name="MissingOverride"/>
+
+    <!-- Forbid arbitrarily nested blocks -->
+    <module name="AvoidNestedBlocks"/>
+
+    <!-- Forbid the use of arbitrary numeric literals -->
+    <module name="MagicNumber"/>
+
+    <!-- Require boolean expressions to be simplifed -->
+    <module name="SimplifyBooleanExpression"/>
+
+    <!-- Require boolean returns to be simplified -->
+    <module name="SimplifyBooleanReturn"/>
+
+    <!-- Forbid interfaces with no methods -->
+    <module name="InterfaceIsType"/>
+
+  </module>
+
+  <!--################################################-->
+  <!--################ Non-AST checks ################-->
+  <!--################################################-->
+
+  <!-- Ensure the copyright header appears in every java source file -->
+  <module name="RegexpHeader">
+    <property name="headerFile" value="${checkstyle.java.header}"/>
+    <property name="fileExtensions" value="java"/>
+  </module>
+
+  <!-- Report every line containing a tab character" -->
+  <module name="FileTabCharacter">
+    <property name="eachLine" value="true"/>
+  </module>
+
+  <!-- Forbid trailing whitespace -->
+  <module name="RegexpSingleline">
+    <property name="format" value="\s+$"/>
+    <property name="message" value="Line has trailing whitespace."/>
+  </module>
+
+  <!-- require Javadoc for all packages -->
+  <module name="JavadocPackage"/>
+
+  <!-- Require a new line at the end of all files -->
+  <module name="NewlineAtEndOfFile"/>
+</module>
diff --git a/config/checkstyle/java.header b/config/checkstyle/java.header
new file mode 100644
index 0000000..56689b5
--- /dev/null
+++ b/config/checkstyle/java.header
@@ -0,0 +1,13 @@
+^/\*$
+^ \* Copyright 20[0-9]{2} The OpenYOLO Authors\. All Rights Reserved\.$
+^ \*$
+^ \* Licensed under the Apache License, Version 2\.0 \(the "License"\); you may not use this file except$
+^ \* in compliance with the License\. You may obtain a copy of the License at$
+^ \*$
+^ \* http://www\.apache\.org/licenses/LICENSE-2\.0$
+^ \*$
+^ \* Unless required by applicable law or agreed to in writing, software distributed under the$
+^ \* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either$
+^ \* express or implied\. See the License for the specific language governing permissions and$
+^ \* limitations under the License\.$
+^ \*/$
\ No newline at end of file
diff --git a/config/checkstyle/java.header.noregex b/config/checkstyle/java.header.noregex
new file mode 100644
index 0000000..61f6831
--- /dev/null
+++ b/config/checkstyle/java.header.noregex
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
new file mode 100644
index 0000000..1ba0203
--- /dev/null
+++ b/config/checkstyle/suppressions.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+    "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+    "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+<suppressions>
+    <!-- ignore autogenerated source code found in a java_gen folder -->
+    <suppress files=".*java_gen/.*" checks=".*"/>
+</suppressions>
\ No newline at end of file
diff --git a/config/coverage.gradle b/config/coverage.gradle
new file mode 100644
index 0000000..9315cce
--- /dev/null
+++ b/config/coverage.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'jacoco'
+
+jacoco {
+    toolVersion = "0.7.1.201405082137"
+}
+
+task jacocoTestReport(type: JacocoReport, dependsOn: "testDebugUnitTest") {
+    group = "Reporting"
+    description = "Generate Jacoco coverage reports after running tests."
+    reports {
+        xml.enabled = true
+        html.enabled = true
+    }
+
+    def ignoredFilter = ['**/R.class',
+                         '**/R$*.class',
+                         '**/BuildConfig.*',
+                         '**/Manifest*.*',
+                         'android/**/*.*',
+                         '**/Curve*.*',
+                         '**/proto/*']
+
+    // Class R is used, but usage will not be covered, so ignore this class from report
+    classDirectories = fileTree(
+        dir: 'build/intermediates/classes/debug',
+        excludes: ignoredFilter
+    )
+    sourceDirectories = files('java')
+    executionData = files('build/jacoco/testDebugUnitTest.exec')
+}
diff --git a/config/javadoc.gradle b/config/javadoc.gradle
new file mode 100644
index 0000000..1136381
--- /dev/null
+++ b/config/javadoc.gradle
@@ -0,0 +1,18 @@
+task androidJavadocs(type: Javadoc) {
+    source = android.sourceSets.main.java.srcDirs
+    title = "OpenYOLO"
+    classpath = files(project.android.getBootClasspath())
+    options {
+        links "http://docs.oracle.com/javase/7/docs/api/"
+        linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
+    }
+    exclude '**/BuildConfig.java'
+    exclude '**/R.java'
+}
+
+afterEvaluate {
+    // fixes issue where javadoc can't find android symbols ref: http://stackoverflow.com/a/34572606
+    androidJavadocs.classpath += files(android.libraryVariants.collect { variant ->
+        variant.javaCompile.classpath.files
+    })
+}
diff --git a/config/keystore.gradle b/config/keystore.gradle
new file mode 100644
index 0000000..82ea6b3
--- /dev/null
+++ b/config/keystore.gradle
@@ -0,0 +1,28 @@
+// creates a keystore with a random private key suitable for building dev
+// and release builds during active development.
+def generateKeystore = { keystoreFile ->
+    exec {
+        executable "keytool"
+        args [
+            "-genkey",
+            "-keystore", "openyolo.keystore",
+            "-alias", "openyolo",
+            "-keyalg", "RSA",
+            "-keysize", "2048",
+            "-validity", "10000",
+            "-keypass", "openyolo",
+            "-storepass", "openyolo",
+            "-dname", "CN=openyolo"
+        ]
+    }
+}
+
+// checks that a keystore exists in the expected location, and generates one
+// if it does not.
+ext.verifyKeystore = {
+    def keystoreFile = file(new File(projectDir, "openyolo.keystore"))
+    if (!keystoreFile.exists()) {
+        logger.lifecycle("openyolo.keystore missing - creating one")
+        generateKeystore(keystoreFile)
+    }
+}
diff --git a/config/localprops.gradle b/config/localprops.gradle
new file mode 100644
index 0000000..92bdbd6
--- /dev/null
+++ b/config/localprops.gradle
@@ -0,0 +1,52 @@
+// infers the location of the Android SDK from the two most common environment
+// variables, ANDROID_SDK_HOME and ANDROID_HOME (in that order).
+def guessAndroidSdkLocation = {
+    def androidDir = null
+    if (System.env.ANDROID_SDK_HOME != null) {
+        logger.lifecycle("using android location from ANDROID_SDK_HOME")
+        return System.env.ANDROID_SDK_HOME
+    } else if (System.env.ANDROID_HOME != null) {
+        logger.info("using android location from ANDROID_HOME")
+        return System.env.ANDROID_HOME
+    }
+
+    return null
+}
+
+// creates a default local.properties file from inferred values and generated
+// resources
+def createLocalProperties = { localPropertiesFile ->
+    def androidDir = guessAndroidSdkLocation()
+    if (androidDir == null) {
+        logger.lifecycle([
+            "Unable to find android SDK location - please ",
+            "create a local.properties file with property sdk.dir set to ",
+            "the location of your android SDK. For example: \n",
+            "sdk.dir=/usr/local/me/android-sdk"].join())
+        throw new GradleException("Android SDK location could not be inferred")
+    }
+
+    def props = new Properties()
+    props.setProperty("sdk.dir", androidDir);
+
+    localPropertiesFile.withWriter('UTF-8') { props.store(it, null) }
+}
+
+
+def localPropertiesFile = file(new File(projectDir, "local.properties"))
+if (!localPropertiesFile.exists()) {
+    logger.lifecycle("local.properties file missing - attempting to " +
+            "create one")
+    createLocalProperties(localPropertiesFile)
+}
+
+def props = new Properties()
+localPropertiesFile.withInputStream {
+    props.load(it)
+}
+
+if (!props.stringPropertyNames().contains('sdk.dir')) {
+    throw new GradleException('sdk.dir not defined in local.properties')
+}
+
+ext.androidSdkDir = props.get("sdk.dir")
diff --git a/config/style.gradle b/config/style.gradle
new file mode 100644
index 0000000..78a7f0e
--- /dev/null
+++ b/config/style.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'checkstyle'
+
+checkstyle {
+    configFile file("${rootDir}/config/checkstyle/checkstyle.xml")
+    configProperties = [
+        'checkstyle.java.header': file("${rootDir}/config/checkstyle/java.header").getAbsolutePath(),
+        'checkstyle.suppressions': file("${rootDir}/config/checkstyle/suppressions.xml").getAbsolutePath(),
+    ]
+    toolVersion = "7.4"
+}
+
+task checkAllSource(type: Checkstyle) {
+    source 'java'
+    include '**/*.java'
+    classpath = project.configurations.compile
+}
+
+task failOnCheckstyleWarning {
+    def checkstyleWarningsFile = 'build/reports/checkstyle/checkAllSource.xml'
+    doLast {
+        File warningsFile = file(checkstyleWarningsFile)
+        if (warningsFile.exists() && warningsFile.text.contains("<error ")) {
+            throw new GradleException(
+                    "There were checkstyle warnings. For more details check: " \
+                     + file(checkstyleWarningsFile))
+        }
+    }
+}
+
+// ensure that there are no style warnings
+failOnCheckstyleWarning.dependsOn checkAllSource
+
+// run checkstyle as part of the standard set of checks
+check.dependsOn failOnCheckstyleWarning
diff --git a/config/testdeps.gradle b/config/testdeps.gradle
new file mode 100644
index 0000000..ec6a194
--- /dev/null
+++ b/config/testdeps.gradle
@@ -0,0 +1,4 @@
+testCompile 'junit:junit:4.12'
+testCompile 'org.mockito:mockito-core:2.7.0'
+testCompile 'org.robolectric:robolectric:3.2.2'
+testCompile 'com.squareup.assertj:assertj-android:1.1.1'
\ No newline at end of file
diff --git a/config/third-party.gradle b/config/third-party.gradle
new file mode 100644
index 0000000..7186d19
--- /dev/null
+++ b/config/third-party.gradle
@@ -0,0 +1 @@
+android.sourceSets.main.java.srcDirs += 'third_party'
diff --git a/config/wire-proto.gradle b/config/wire-proto.gradle
new file mode 100644
index 0000000..5aaf81f
--- /dev/null
+++ b/config/wire-proto.gradle
@@ -0,0 +1,26 @@
+android.sourceSets.main.java.srcDirs += 'java_gen'
+
+configurations {
+    protoCompileDeps
+}
+
+dependencies {
+    compile 'com.squareup.wire:wire-runtime:2.1.2'
+    protoCompileDeps 'com.squareup.wire:wire-compiler:2.1.2'
+}
+
+task protoCompile(type: JavaExec) {
+    main = 'com.squareup.wire.WireCompiler'
+    classpath configurations.protoCompileDeps
+    args = [
+            '--proto_path=' + file('proto').getAbsolutePath(),
+            '--java_out=' + file('java_gen').getAbsolutePath(),
+            '--excludes=google.protobuf.*'
+    ]
+}
+
+preBuild.dependsOn protoCompile
+
+clean {
+    delete 'java_gen'
+}
diff --git a/demoapp/AndroidManifest.xml b/demoapp/AndroidManifest.xml
new file mode 100644
index 0000000..8de414e
--- /dev/null
+++ b/demoapp/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="org.openyolo.demoapp" >
+
+    <uses-permission android:name="android.permission.INTERNET" />
+
+    <application
+            android:allowBackup="false"
+            android:fullBackupContent="false"
+            android:icon="@mipmap/ic_launcher"
+            android:label="@string/app_name_short"
+            android:theme="@style/AppTheme"
+            android:supportsRtl="false" >
+
+        <activity
+                android:name=".OpenYoloDemoActivity"
+                android:label="@string/app_name_short"
+                android:theme="@style/AppTheme.NoActionBar"
+                android:windowSoftInputMode="stateHidden"
+                android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <intent-filter>
+               <action android:name="android.intent.action.VIEW" />
+               <category android:name="android.intent.category.DEFAULT" />
+               <category android:name="android.intent.category.BROWSABLE" />
+               <data
+                   android:host="openyolo.demo-app.io"
+                   android:scheme="https" />
+            </intent-filter>
+        </activity>
+
+    </application>
+</manifest>
diff --git a/demoapp/build.gradle b/demoapp/build.gradle
new file mode 100644
index 0000000..79cab5d
--- /dev/null
+++ b/demoapp/build.gradle
@@ -0,0 +1,33 @@
+apply plugin: 'com.android.application'
+apply plugin: 'checkstyle'
+apply plugin: 'com.neenbedankt.android-apt'
+
+apply from:'../config/android-common.gradle'
+
+android {
+    defaultConfig {
+        applicationId "org.openyolo.demoapp"
+        project.archivesBaseName = "openyolo-demoapp"
+        vectorDrawables.useSupportLibrary = true
+    }
+    buildTypes {
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt')
+        }
+    }
+}
+
+dependencies {
+    compile project(':api')
+    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    compile "com.android.support:design:${rootProject.supportLibVersion}"
+    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+
+    compile 'com.jakewharton:butterknife:8.5.1'
+    compile 'com.github.bumptech.glide:glide:3.7.0'
+    apt 'com.jakewharton:butterknife-compiler:8.5.1'
+}
+
+apply from:'../config/style.gradle'
diff --git a/demoapp/java/org/openyolo/demoapp/OpenYoloDemoActivity.java b/demoapp/java/org/openyolo/demoapp/OpenYoloDemoActivity.java
new file mode 100644
index 0000000..6c61504
--- /dev/null
+++ b/demoapp/java/org/openyolo/demoapp/OpenYoloDemoActivity.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.OnTextChanged;
+import com.bumptech.glide.Glide;
+import java.util.concurrent.atomic.AtomicReference;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.api.Credential;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.api.HintRequest;
+import org.openyolo.api.PasswordSpecification;
+import org.openyolo.api.RetrieveCallback;
+import org.openyolo.api.RetrieveRequest;
+import org.openyolo.api.RetrieveResult;
+
+/**
+ * Interacts with the OpenYOLO API to retrieve and save credentials.
+ */
+public class OpenYoloDemoActivity extends AppCompatActivity {
+
+    private static final String LOG_TAG = "OpenYoloDemoActivity";
+    private static final int RC_RETRIEVE = 100;
+    private static final int RC_SAVE = 200;
+    private static final int RC_HINT = 300;
+
+    private CredentialClient mApi;
+    private RandomData mRandomData;
+
+    @BindView(android.R.id.content)
+    View mRootView;
+
+    @BindView(R.id.id_field)
+    EditText mIdField;
+
+    @BindView(R.id.password_field)
+    EditText mPasswordField;
+
+    @BindView(R.id.display_name_field)
+    EditText mDisplayNameField;
+
+    @BindView(R.id.federation_provider_field)
+    EditText mFederationProviderField;
+
+    @BindView(R.id.profile_picture_field)
+    EditText mProfilePictureField;
+
+    @BindView(R.id.profile_picture_view)
+    ImageView mProfilePictureView;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mApi = CredentialClient.getApplicationBoundInstance(this);
+        mRandomData = new RandomData();
+        setContentView(R.layout.main_layout);
+        ButterKnife.bind(this);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        switch (requestCode) {
+            case RC_RETRIEVE:
+                handleRetrieveResult(resultCode, data);
+                break;
+            case RC_SAVE:
+                handleSaveResult(resultCode);
+                break;
+            case RC_HINT:
+                handleHintResult(resultCode, data);
+                break;
+            default:
+                showSnackbar(R.string.unknown_response);
+        }
+    }
+
+    private void handleRetrieveResult(int resultCode, Intent data) {
+        if (resultCode == RESULT_OK) {
+            Credential credential = mApi.getCredentialFromActivityResult(data);
+            if (credential == null) {
+                showSnackbar(R.string.no_credential_returned);
+            } else {
+                copyCredentialFields(credential);
+            }
+        } else if (resultCode == RESULT_CANCELED) {
+            showSnackbar(R.string.retrieve_cancelled);
+        }
+    }
+
+    private void handleSaveResult(int resultCode) {
+        if (resultCode == RESULT_OK) {
+            showSnackbar(R.string.credential_saved);
+        } else {
+            showSnackbar(R.string.credential_save_canceled);
+        }
+    }
+
+    private void handleHintResult(int resultCode, Intent data) {
+        if (resultCode == RESULT_OK) {
+            Credential credential = mApi.getCredentialFromActivityResult(data);
+            if (credential == null) {
+                showSnackbar(R.string.no_credential_returned);
+            } else {
+                copyCredentialFields(credential);
+            }
+        } else if (resultCode == RESULT_CANCELED) {
+            showSnackbar(R.string.hint_cancelled);
+        }
+    }
+
+    private void copyCredentialFields(Credential credential) {
+        copyIfNotNull(credential.getIdentifier(), mIdField);
+        copyIfNotNull(credential.getPassword(), mPasswordField);
+        copyIfNotNull(credential.getDisplayName(), mDisplayNameField);
+        copyIfNotNull(credential.getDisplayPicture(), mProfilePictureField);
+        copyIfNotNull(credential.getAuthenticationMethod(), mFederationProviderField);
+    }
+
+    @OnClick(R.id.retrieve_button)
+    void onRetrieve() {
+        clearData();
+        mApi.retrieve(RetrieveRequest.forSelf(this), new HandleRetrieveResult());
+    }
+
+    @OnClick(R.id.save_button)
+    void onSave() {
+        String authMethod = mFederationProviderField.getText().toString().trim();
+        Uri authMethodUri = authMethod.isEmpty()
+                ? AuthenticationMethods.ID_AND_PASSWORD
+                : Uri.parse(authMethod);
+
+        Credential.Builder credentialBuilder = new Credential.Builder(
+                mIdField.getText().toString(),
+                authMethodUri,
+                AuthenticationDomain.getSelfAuthDomain(this))
+                .setDisplayName(convertEmptyToNull(mDisplayNameField.getText().toString()))
+                .setDisplayPicture(convertEmptyToNull(mProfilePictureField.getText().toString()));
+
+        if (authMethodUri.equals(AuthenticationMethods.ID_AND_PASSWORD)) {
+            credentialBuilder.setPassword(mPasswordField.getText().toString());
+        }
+
+        Credential credential = credentialBuilder.build();
+
+        Intent saveIntent = mApi.getSaveIntent(credential);
+        if (saveIntent == null) {
+            showSnackbar(R.string.no_available_save_providers);
+            return;
+        }
+
+        startActivityForResult(saveIntent, RC_SAVE);
+    }
+
+    @OnClick(R.id.hint_button)
+    void onHint() {
+        Intent hintIntent = mApi.getHintRetrieveIntent(new HintRequest.Builder(
+                AuthenticationMethods.ID_AND_PASSWORD,
+                AuthenticationMethods.GOOGLE,
+                AuthenticationMethods.FACEBOOK)
+                .build());
+
+        if (hintIntent == null) {
+            showSnackbar(R.string.no_available_hint_providers);
+            return;
+        }
+
+        startActivityForResult(hintIntent, RC_HINT);
+    }
+
+    @OnClick(R.id.clear_button)
+    void clearDataClicked() {
+        clearData();
+        showSnackbar(R.string.cleared_fields);
+    }
+
+    private void clearData() {
+        mIdField.setText("");
+        mPasswordField.setText("");
+        mDisplayNameField.setText("");
+        mFederationProviderField.setText("");
+        mProfilePictureField.setText("");
+        mIdField.requestFocus();
+    }
+
+    @OnClick(R.id.generate_id_button)
+    void generateId() {
+        mIdField.setText(mRandomData.generateEmailAddress());
+    }
+
+    @OnClick(R.id.generate_password_button)
+    void generatePassword() {
+        mPasswordField.setText(PasswordSpecification.DEFAULT.generate());
+    }
+
+    @OnClick(R.id.google_provider_button)
+    void setGoogleProvider() {
+        mFederationProviderField.setText(AuthenticationMethods.GOOGLE.toString());
+    }
+
+    @OnClick(R.id.facebook_provider_button)
+    void setFacebookProvider() {
+        mFederationProviderField.setText(AuthenticationMethods.FACEBOOK.toString());
+    }
+
+    @OnClick(R.id.generate_display_name_button)
+    void generateDisplayName() {
+        mDisplayNameField.setText(mRandomData.generateDisplayName());
+    }
+
+    @OnClick(R.id.generate_profile_picture_button)
+    void generateProfilePicture() {
+        mProfilePictureField.setText(mRandomData.generateProfilePictureUri());
+    }
+
+    @OnTextChanged(R.id.profile_picture_field)
+    void loadProfilePicture() {
+        Glide.with(this)
+                .load(Uri.parse(mProfilePictureField.getText().toString()))
+                .fitCenter()
+                .into(mProfilePictureView);
+    }
+
+    private void showSnackbar(@StringRes int messageId) {
+        Snackbar.make(mRootView, messageId, Snackbar.LENGTH_SHORT).show();
+    }
+
+    private void copyIfNotNull(@Nullable Object value, @NonNull EditText field) {
+        if (value != null) {
+            field.setText(value.toString());
+        }
+    }
+
+    private String convertEmptyToNull(@NonNull String str) {
+        if (str.isEmpty()) {
+            return null;
+        }
+
+        return str;
+    }
+
+    private class HandleRetrieveResult implements RetrieveCallback, Runnable {
+
+        private final AtomicReference<RetrieveResult> mResult = new AtomicReference<>();
+        private final AtomicReference<Throwable> mError = new AtomicReference<>();
+
+        @Override
+        public void onComplete(RetrieveResult result, Throwable error) {
+            mResult.set(result);
+            mError.set(error);
+            runOnUiThread(this);
+        }
+
+        @Override
+        public void run() {
+            if (mError.get() != null) {
+                showSnackbar(R.string.request_failed);
+                Log.w(LOG_TAG, "OpenYOLO request failed", mError.get());
+                return;
+            }
+
+            RetrieveResult result = mResult.get();
+            if (result.getRetrieveIntent() == null) {
+                showSnackbar(R.string.no_credentials);
+                Log.i(LOG_TAG, "OpenYOLO retrieve result: No credentials available");
+                return;
+            }
+
+            Log.i(LOG_TAG, "OpenYOLO retrieve result: Credentials available");
+            startActivityForResult(result.getRetrieveIntent(), RC_RETRIEVE);
+        }
+    }
+}
diff --git a/demoapp/java/org/openyolo/demoapp/RandomData.java b/demoapp/java/org/openyolo/demoapp/RandomData.java
new file mode 100644
index 0000000..81daf36
--- /dev/null
+++ b/demoapp/java/org/openyolo/demoapp/RandomData.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoapp;
+
+import android.support.annotation.NonNull;
+import java.util.Locale;
+import java.util.Random;
+import okio.ByteString;
+
+/**
+ * Generates random data useful for populating credentials.
+ */
+public class RandomData {
+
+    /**
+     * The top-100 given (aka "first") names, from US Census Bureau data.
+     */
+    public static final String[] GIVEN_NAMES = {
+            "Amanda",
+            "Amy",
+            "Andrew",
+            "Angela",
+            "Ann",
+            "Anna",
+            "Anthony",
+            "Arthur",
+            "Barbara",
+            "Betty",
+            "Brenda",
+            "Brian",
+            "Carl",
+            "Carol",
+            "Carolyn",
+            "Catherine",
+            "Charles",
+            "Christine",
+            "Christopher",
+            "Cynthia",
+            "Daniel",
+            "David",
+            "Deborah",
+            "Debra",
+            "Dennis",
+            "Diane",
+            "Donald",
+            "Donna",
+            "Dorothy",
+            "Douglas",
+            "Edward",
+            "Elizabeth",
+            "Eric",
+            "Frances",
+            "Frank",
+            "Gary",
+            "George",
+            "Gregory",
+            "Harold",
+            "Helen",
+            "Henry",
+            "James",
+            "Janet",
+            "Jason",
+            "Jeffrey",
+            "Jennifer",
+            "Jerry",
+            "Jessica",
+            "John",
+            "Jose",
+            "Joseph",
+            "Joshua",
+            "Joyce",
+            "Karen",
+            "Kathleen",
+            "Kenneth",
+            "Kevin",
+            "Kimberly",
+            "Larry",
+            "Laura",
+            "Linda",
+            "Lisa",
+            "Margaret",
+            "Maria",
+            "Marie",
+            "Mark",
+            "Martha",
+            "Mary",
+            "Matthew",
+            "Melissa",
+            "Michael",
+            "Michelle",
+            "Nancy",
+            "Pamela",
+            "Patricia",
+            "Patrick",
+            "Paul",
+            "Peter",
+            "Raymond",
+            "Rebecca",
+            "Richard",
+            "Robert",
+            "Roger",
+            "Ronald",
+            "Ruth",
+            "Ryan",
+            "Sandra",
+            "Sarah",
+            "Scott",
+            "Sharon",
+            "Shirley",
+            "Stephanie",
+            "Stephen",
+            "Steven",
+            "Susan",
+            "Thomas",
+            "Timothy",
+            "Virginia",
+            "Walter",
+            "William",
+    };
+
+    /**
+     * The top-100 family names, from US Census Bureau data.
+     */
+    public static final String[] FAMILY_NAMES = {
+            "Adams",
+            "Alexander",
+            "Allen",
+            "Anderson",
+            "Bailey",
+            "Baker",
+            "Barnes",
+            "Bell",
+            "Bennett",
+            "Brooks",
+            "Brown",
+            "Bryant",
+            "Butler",
+            "Campbell",
+            "Carter",
+            "Clark",
+            "Coleman",
+            "Collins",
+            "Cook",
+            "Cooper",
+            "Cox",
+            "Davis",
+            "Diaz",
+            "Edwards",
+            "Evans",
+            "Flores",
+            "Foster",
+            "Garcia",
+            "Gonzales",
+            "Gonzalez",
+            "Gray",
+            "Green",
+            "Griffin",
+            "Hall",
+            "Harris",
+            "Hayes",
+            "Henderson",
+            "Hernandez",
+            "Hill",
+            "Howard",
+            "Hughes",
+            "Jackson",
+            "James",
+            "Jenkins",
+            "Johnson",
+            "Jones",
+            "Kelly",
+            "King",
+            "Lee",
+            "Lewis",
+            "Long",
+            "Lopez",
+            "Martin",
+            "Martinez",
+            "Miller",
+            "Mitchell",
+            "Moore",
+            "Morgan",
+            "Morris",
+            "Murphy",
+            "Nelson",
+            "Parker",
+            "Patterson",
+            "Perez",
+            "Perry",
+            "Peterson",
+            "Phillips",
+            "Powell",
+            "Price",
+            "Ramirez",
+            "Reed",
+            "Richardson",
+            "Rivera",
+            "Roberts",
+            "Robinson",
+            "Rodriguez",
+            "Rogers",
+            "Ross",
+            "Russell",
+            "Sanchez",
+            "Sanders",
+            "Scott",
+            "Simmons",
+            "Smith",
+            "Stewart",
+            "Taylor",
+            "Thomas",
+            "Thompson",
+            "Torres",
+            "Turner",
+            "Walker",
+            "Ward",
+            "Washington",
+            "Watson",
+            "White",
+            "Williams",
+            "Wilson",
+            "Wood",
+            "Wright",
+            "Young"
+    };
+
+    private static final int ROBOHASH_LENGTH = 32;
+
+    private final Random mRandom;
+
+    /**
+     * Instantiates a random user data source.
+     */
+    public RandomData() {
+        mRandom = new Random();
+    }
+
+    /**
+     * Generates a given (aka "first") name.
+     */
+    @NonNull
+    public String generateGivenName() {
+        return GIVEN_NAMES[mRandom.nextInt(GIVEN_NAMES.length)];
+    }
+
+    /**
+     * Generates a family name.
+     */
+    @NonNull
+    public String generateFamilyName() {
+        return FAMILY_NAMES[mRandom.nextInt(FAMILY_NAMES.length)];
+    }
+
+    /**
+     * Generates a full display name composed of a given name and family name.
+     */
+    public String generateDisplayName() {
+        return getDisplayName(generateGivenName(), generateFamilyName());
+    }
+
+    /**
+     * Generates a display name from the provided given and family names.
+     */
+    public String getDisplayName(String givenName, String familyName) {
+        return givenName + " " + familyName;
+    }
+
+    /**
+     * Generates an email address.
+     */
+    public String generateEmailAddress() {
+        return getEmailAddress(generateGivenName(), generateFamilyName());
+    }
+
+    /**
+     * Generates an email address using the provided given and family names for the user.
+     */
+    public String getEmailAddress(String givenName, String surname) {
+        return givenName.toLowerCase(Locale.US).trim()
+                + "." + surname.toLowerCase(Locale.US).trim()
+                + "@openyolo.org";
+    }
+
+    /**
+     * Generates a hexadecimal string from a random byte array of the provided length.
+     */
+    public String generateHexString(int numBytes) {
+        byte[] bytes = new byte[numBytes];
+        mRandom.nextBytes(bytes);
+        return ByteString.of(bytes).hex();
+    }
+
+    /**
+     * Generates a profile picture URI.
+     */
+    public String generateProfilePictureUri() {
+        return "https://robohash.org/" + generateHexString(ROBOHASH_LENGTH) + "?set=set3";
+    }
+}
diff --git a/demoapp/java/org/openyolo/demoapp/package-info.java b/demoapp/java/org/openyolo/demoapp/package-info.java
new file mode 100644
index 0000000..8bc6a81
--- /dev/null
+++ b/demoapp/java/org/openyolo/demoapp/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Example usage of the OpenYOLO API to retrieve and save credentials.
+ */
+package org.openyolo.demoapp;
diff --git a/demoapp/res/drawable/dice_24dp.xml b/demoapp/res/drawable/dice_24dp.xml
new file mode 100644
index 0000000..a13cbf6
--- /dev/null
+++ b/demoapp/res/drawable/dice_24dp.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#FAFAFA"
+        android:pathData="M 4 2 L 20 2 Q 22 2 22 4 L 22 20 Q 22 22 20 22 L 4 22 Q 2 22 2 20 L 2 4 Q 2 2 4 2 Z" />
+    <path
+        android:fillColor="#424242"
+        android:pathData="M 6 4 C 7.10456949966 4 8 4.89543050034 8 6 C 8 7.10456949966 7.10456949966 8 6 8 C 4.89543050034 8 4 7.10456949966 4 6 C 4 4.89543050034 4.89543050034 4 6 4 Z" />
+    <path
+        android:fillColor="#424242"
+        android:pathData="M 12 10 C 13.1045694997 10 14 10.8954305003 14 12 C 14 13.1045694997 13.1045694997 14 12 14 C 10.8954305003 14 10 13.1045694997 10 12 C 10 10.8954305003 10.8954305003 10 12 10 Z" />
+    <path
+        android:fillColor="#424242"
+        android:pathData="M 18 16 C 19.1045694997 16 20 16.8954305003 20 18 C 20 19.1045694997 19.1045694997 20 18 20 C 16.8954305003 20 16 19.1045694997 16 18 C 16 16.8954305003 16.8954305003 16 18 16 Z" />
+</vector>
\ No newline at end of file
diff --git a/demoapp/res/drawable/facebook_24dp.xml b/demoapp/res/drawable/facebook_24dp.xml
new file mode 100644
index 0000000..2414208
--- /dev/null
+++ b/demoapp/res/drawable/facebook_24dp.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#3d539e"
+        android:pathData="M21.786 23c.67 0 1.214-.544 1.214-1.214V2.214C23 1.544 22.456 1 21.786
+1H2.214C1.544 1 1 1.543 1 2.214v19.572C1 22.456 1.543 23 2.214 23h19.572" />
+    <path
+        android:fillColor="#fff"
+        android:pathData="M16.18 23v-8.52h2.86l.427-3.32H16.18V9.04c0-.96 .267 -1.616
+1.645-1.616h1.758v-2.97c-.304-.04-1.347-.131-2.562-.131-2.535 0-4.27 1.547-4.27
+4.389v2.448H9.884v3.32h2.867V23h3.429" />
+</vector>
\ No newline at end of file
diff --git a/demoapp/res/drawable/google_24dp.xml b/demoapp/res/drawable/google_24dp.xml
new file mode 100644
index 0000000..803d028
--- /dev/null
+++ b/demoapp/res/drawable/google_24dp.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#4285F4"
+        android:pathData="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21
+3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" />
+    <path
+        android:fillColor="#34A853"
+        android:pathData="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98 .66 -2.23 1.06-3.71 1.06-2.86
+0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" />
+    <path
+        android:fillColor="#FBBC05"
+        android:pathData="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43 .35 -2.09V7.07H2.18C1.43 8.55 1
+10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22 .81 -.62z" />
+    <path
+        android:fillColor="#EA4335"
+        android:pathData="M12 5.38c1.62 0 3.06 .56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99
+3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" />
+    <path
+        android:pathData="M1 1h22v22H1z" />
+</vector>
\ No newline at end of file
diff --git a/demoapp/res/layout/main_layout.xml b/demoapp/res/layout/main_layout.xml
new file mode 100644
index 0000000..58e0c68
--- /dev/null
+++ b/demoapp/res/layout/main_layout.xml
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <android.support.v4.widget.NestedScrollView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="16dp"
+            android:orientation="vertical">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/main_header"
+                android:layout_gravity="center_horizontal"
+                style="@style/Base.TextAppearance.AppCompat.Headline" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
+                android:orientation="horizontal">
+
+                <Button
+                    android:id="@+id/retrieve_button"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:text="@string/retrieve_button_label"
+                    android:contentDescription="@string/retrieve_button_content_description"
+                    android:theme="@style/BlueButtonThemeOverlay"
+                    style="@style/Widget.AppCompat.Button.Colored" />
+
+                <Button
+                    android:id="@+id/save_button"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:text="@string/save_button_label"
+                    android:contentDescription="@string/save_button_content_description"
+                    style="@style/Widget.AppCompat.Button.Colored"
+                    android:theme="@style/GreenButtonThemeOverlay"/>
+
+                <Button
+                    android:id="@+id/hint_button"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:text="@string/hint_button_label"
+                    android:contentDescription="@string/hint_button_content_description"
+                    style="@style/Widget.AppCompat.Button.Colored"
+                    android:theme="@style/RedButtonThemeOverlay" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
+                android:orientation="horizontal">
+
+                <android.support.design.widget.TextInputLayout
+                    android:id="@+id/id_layout"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1">
+
+                    <android.support.design.widget.TextInputEditText
+                        android:id="@+id/id_field"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:inputType="textNoSuggestions|textVisiblePassword"
+                        android:hint="@string/id_field_hint"
+                        />
+
+                </android.support.design.widget.TextInputLayout>
+
+                <ImageButton
+                    android:id="@+id/generate_id_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:contentDescription="@string/generate_id_button_content_description"
+                    app:srcCompat="@drawable/dice_24dp"
+                    style="@style/SideButton" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <android.support.design.widget.TextInputLayout
+                    android:id="@+id/password_layout"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1">
+
+                    <android.support.design.widget.TextInputEditText
+                        android:id="@+id/password_field"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:inputType="textVisiblePassword"
+                        android:hint="@string/password_field_hint"
+                        android:typeface="monospace"/>
+
+                </android.support.design.widget.TextInputLayout>
+
+                <ImageButton
+                    android:id="@+id/generate_password_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:contentDescription="@string/generate_password_button_content_description"
+                    app:srcCompat="@drawable/dice_24dp"
+                    style="@style/SideButton" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <android.support.design.widget.TextInputLayout
+                    android:id="@+id/display_name_layout"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1">
+
+                    <android.support.design.widget.TextInputEditText
+                        android:id="@+id/display_name_field"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:inputType="textPersonName"
+                        android:hint="@string/display_name_field_hint"
+                        />
+
+                </android.support.design.widget.TextInputLayout>
+
+                <ImageButton
+                    android:id="@+id/generate_display_name_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:contentDescription="@string/generate_display_name_button_content_description"
+                    app:srcCompat="@drawable/dice_24dp"
+                    style="@style/SideButton" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <android.support.design.widget.TextInputLayout
+                    android:id="@+id/federation_provider_layout"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1">
+
+                    <android.support.design.widget.TextInputEditText
+                        android:id="@+id/federation_provider_field"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:inputType="textUri"
+                        android:hint="@string/federation_provider_field_hint"
+                        />
+
+                </android.support.design.widget.TextInputLayout>
+
+                <ImageButton
+                    android:id="@+id/google_provider_button"
+                    android:contentDescription="@string/google_provider_button_content_description"
+                    app:srcCompat="@drawable/google_24dp"
+                    style="@style/SideButton"/>
+
+                <ImageButton
+                    android:id="@+id/facebook_provider_button"
+                    android:contentDescription="@string/facebook_provider_button_content_description"
+                    app:srcCompat="@drawable/facebook_24dp"
+                    style="@style/SideButton"/>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <android.support.design.widget.TextInputLayout
+                    android:id="@+id/profile_picture_layout"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1">
+
+                    <android.support.design.widget.TextInputEditText
+                        android:id="@+id/profile_picture_field"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:inputType="textUri"
+                        android:hint="@string/profile_picture_field_hint"
+                        />
+
+                </android.support.design.widget.TextInputLayout>
+
+                <ImageView
+                    android:id="@+id/profile_picture_view"
+                    android:layout_width="48dp"
+                    android:layout_height="48dp"
+                    android:layout_gravity="center"
+                    android:contentDescription="@string/profile_picture_view_content_description"/>
+
+                <ImageButton
+                    android:id="@+id/generate_profile_picture_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:contentDescription="@string/generate_profile_picture_button_content_description"
+                    app:srcCompat="@drawable/dice_24dp"
+                    style="@style/SideButton" />
+
+            </LinearLayout>
+
+            <Button
+                android:id="@+id/clear_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
+                android:layout_marginLeft="8dp"
+                android:layout_marginRight="8dp"
+                android:layout_gravity="center_horizontal"
+                android:text="@string/clear_button_label"
+                android:contentDescription="@string/clear_button_content_description"
+                android:theme="@style/RedButtonThemeOverlay"
+                style="@style/Widget.AppCompat.Button.Colored"/>
+
+        </LinearLayout>
+
+    </android.support.v4.widget.NestedScrollView>
+
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/demoapp/res/mipmap-hdpi/ic_launcher.png b/demoapp/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..1a7b7d0
Binary files /dev/null and b/demoapp/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/demoapp/res/mipmap-mdpi/ic_launcher.png b/demoapp/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..33f6e12
Binary files /dev/null and b/demoapp/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/demoapp/res/mipmap-xhdpi/ic_launcher.png b/demoapp/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d8e55a8
Binary files /dev/null and b/demoapp/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/demoapp/res/mipmap-xxhdpi/ic_launcher.png b/demoapp/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..9762cff
Binary files /dev/null and b/demoapp/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/demoapp/res/mipmap-xxxhdpi/ic_launcher.png b/demoapp/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..18c4e87
Binary files /dev/null and b/demoapp/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/demoapp/res/values/colors.xml b/demoapp/res/values/colors.xml
new file mode 100644
index 0000000..1e59826
--- /dev/null
+++ b/demoapp/res/values/colors.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#1E88E5</color>
+    <color name="colorPrimaryDark">#0288D1</color>
+    <color name="colorAccent">#43A047</color>
+
+    <color name="material_color_green_600">#43A047</color>
+    <color name="material_color_red_600">#e53935</color>
+</resources>
diff --git a/demoapp/res/values/strings.xml b/demoapp/res/values/strings.xml
new file mode 100644
index 0000000..fe2d988
--- /dev/null
+++ b/demoapp/res/values/strings.xml
@@ -0,0 +1,35 @@
+<resources>
+    <string name="app_name_short">OpenYOLO</string>
+    <string name="retrieve_button_label">Get</string>
+    <string name="save_button_label">Save</string>
+    <string name="clear_button_label">Clear fields</string>
+    <string name="retrieve_button_content_description">Retrieve a credential</string>
+    <string name="save_button_content_description">Save a credential</string>
+    <string name="clear_button_content_description">Clear data entry fields</string>
+    <string name="id_field_hint">Identifier</string>
+    <string name="generate_id_button_content_description">Generate a random identifier</string>
+    <string name="password_field_hint">Password</string>
+    <string name="generate_password_button_content_description">Generate a random password</string>
+    <string name="generate_display_name_button_content_description">Generate random display name</string>
+    <string name="federation_provider_field_hint">Federation provider</string>
+    <string name="profile_picture_field_hint">Profile Picture URI</string>
+    <string name="google_provider_button_content_description">Set federation provider to Google</string>
+    <string name="facebook_provider_button_content_description">Set federation provider to Facebook</string>
+    <string name="generate_profile_picture_button_content_description">Generate a random profile picture URI</string>
+    <string name="profile_picture_view_content_description">Profile picture display</string>
+    <string name="main_header">OpenYOLO demo</string>
+    <string name="display_name_field_hint">Display name</string>
+    <string name="request_failed">OpenYOLO request failed</string>
+    <string name="no_credentials">No credentials available</string>
+    <string name="retrieve_cancelled">Credential retrieve cancelled</string>
+    <string name="hint_cancelled">Hint retrieve cancelled</string>
+    <string name="cleared_fields">Cleared fields</string>
+    <string name="no_credential_returned">No credential returned</string>
+    <string name="hint_button_label">Hint</string>
+    <string name="hint_button_content_description">Hint for new account creation</string>
+    <string name="no_available_save_providers">"No available providers can save this credential</string>
+    <string name="no_available_hint_providers">"No available hint providers</string>
+    <string name="credential_saved">Credential saved</string>
+    <string name="credential_save_canceled">Credential save canceled</string>
+    <string name="unknown_response">Unknown response</string>
+</resources>
diff --git a/demoapp/res/values/styles.xml b/demoapp/res/values/styles.xml
new file mode 100644
index 0000000..e397cb3
--- /dev/null
+++ b/demoapp/res/values/styles.xml
@@ -0,0 +1,30 @@
+<resources>
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
+    </style>
+    <style name="AppTheme.NoActionBar">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="SideButton" parent="Widget.AppCompat.Button.Small">
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center</item>
+    </style>
+
+    <style name="BlueButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
+        <item name="colorAccent">@color/colorPrimary</item>
+    </style>
+
+    <style name="GreenButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
+        <item name="colorAccent">@color/material_color_green_600</item>
+    </style>
+
+    <style name="RedButtonThemeOverlay" parent="ThemeOverlay.AppCompat">
+        <item name="colorAccent">@color/material_color_red_600</item>
+    </style>
+
+</resources>
diff --git a/demoproviders/barbican/AndroidManifest.xml b/demoproviders/barbican/AndroidManifest.xml
new file mode 100644
index 0000000..fd2acc7
--- /dev/null
+++ b/demoproviders/barbican/AndroidManifest.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="org.openyolo.demoprovider.barbican">
+
+    <permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="org.openyolo.demoprovider.barbican.STORAGE" />
+
+    <application
+        android:allowBackup="false"
+        android:fullBackupContent="false"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name_short"
+        android:supportsRtl="false"
+        android:theme="@style/AppTheme"
+        android:name=".Application">
+
+        <activity
+            android:name=".LaunchActivity"
+            android:label="@string/app_name_short"
+            android:theme="@style/SplashTheme"
+            android:windowSoftInputMode="stateHidden"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <data
+                    android:host="barbican.openyolo.org"
+                    android:scheme="https" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name=".WelcomeActivity"
+            android:theme="@style/AppTheme.NoActionBar"
+            android:windowSoftInputMode="adjustResize|stateVisible"
+            android:exported="false" />
+
+        <activity
+            android:name=".UnlockActivity"
+            android:theme="@style/AppTheme.NoUi"
+            android:windowSoftInputMode="adjustResize|stateVisible"
+            android:exported="false" />
+
+        <activity
+            android:name=".LockActivity"
+            android:theme="@style/AppTheme.NoUi"
+            android:exported="false" />
+
+        <activity
+            android:name=".CredentialListActivity"
+            android:label="Stored Credentials"
+            android:theme="@style/AppTheme"
+            android:windowSoftInputMode="adjustResize|stateHidden"
+            android:exported="false" />
+
+        <activity
+            android:name=".CreateCredentialActivity"
+            android:theme="@style/AppTheme"
+            android:label="@string/create_credential_activity_label"
+            android:windowSoftInputMode="adjustResize|stateHidden"
+            android:exported="false" />
+
+        <activity android:name=".provider.RetrieveCredentialActivity"
+            android:theme="@style/AppTheme.NoUi"
+            android:exported="true"
+            android:excludeFromRecents="true" />
+
+        <activity android:name=".provider.SaveCredentialActivity"
+            android:theme="@style/AppTheme.NoUi"
+            android:exported="true"
+            android:excludeFromRecents="true">
+            <intent-filter>
+                <action android:name="org.openyolo.save"/>
+                <category android:name="org.openyolo" />
+                <!--
+                as this app only supports saving ID and password based credentials, this is
+                declared using a data filter.
+                -->
+                <data
+                    android:scheme="openyolo"
+                    android:host="id-and-password" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name=".provider.HintActivity"
+            android:theme="@style/AppTheme.NoUi"
+            android:exported="true"
+            android:excludeFromRecents="true">
+            <intent-filter>
+                <action android:name="org.openyolo.hint"/>
+                <category android:name="org.openyolo" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".provider.SaveCredentialConfirmationActivity"
+                  android:theme="@style/AppTheme.Dialog"
+                  android:excludeFromRecents="true" />
+
+        <activity android:name=".provider.SaveAfterUnlockActivity"
+                  android:theme="@style/AppTheme.NoUi"
+                  android:excludeFromRecents="true" />
+
+        <activity
+            android:name=".provider.AutoSignInActivity"
+            android:theme="@style/AutoSignInTheme"
+            android:excludeFromRecents="true"
+            android:exported="false" />
+
+        <activity
+            android:name=".provider.CredentialPickerActivity"
+            android:theme="@style/AppTheme.Dialog"
+            android:excludeFromRecents="true"
+            android:exported="false" />
+
+        <activity
+            android:name=".NeverSaveListActivity"
+            android:theme="@style/AppTheme"/>
+            android:exported="false" />
+
+        <service
+            android:name=".storage.CredentialStorageService"
+            android:label="@string/credential_storage_service_label"
+            android:enabled="true"
+            android:exported="false"
+            android:permission="org.openyolo.demoprovider.STORAGE"/>
+
+        <receiver
+            android:name=".provider.CredentialQueryReceiver"
+            android:exported="true"
+            android:enabled="true"
+            tools:ignore="ExportedReceiver">
+            <intent-filter>
+                <action android:name="org.openyolo.credential" />
+                <category android:name="com.google.bbq.QUERY" />
+            </intent-filter>
+        </receiver>
+    </application>
+</manifest>
diff --git a/demoproviders/barbican/build.gradle b/demoproviders/barbican/build.gradle
new file mode 100644
index 0000000..59270b5
--- /dev/null
+++ b/demoproviders/barbican/build.gradle
@@ -0,0 +1,39 @@
+apply plugin: 'com.android.application'
+apply plugin: 'checkstyle'
+apply plugin: 'com.neenbedankt.android-apt'
+
+apply from: "${rootDir}/config/android-common.gradle"
+apply from: "${rootDir}/config/wire-proto.gradle"
+
+android {
+    defaultConfig {
+        applicationId 'org.openyolo.demoprovider.barbican'
+        project.archivesBaseName = 'openyolo-demoprovider-barbican'
+        vectorDrawables.useSupportLibrary = true
+    }
+    buildTypes {
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt')
+        }
+    }
+}
+
+dependencies {
+    compile project(':spi')
+    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    compile "com.android.support:design:${rootProject.supportLibVersion}"
+    compile "com.android.support:recyclerview-v7:${rootProject.supportLibVersion}"
+    compile 'com.madgag.spongycastle:core:1.54.0.0'
+
+    compile 'com.jakewharton:butterknife:8.5.1'
+    compile 'com.github.bumptech.glide:glide:3.7.0'
+    apt 'com.jakewharton:butterknife-compiler:8.5.1'
+
+    apply from: "${rootDir}/config/testdeps.gradle", to:it
+    testCompile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+}
+
+apply from: "${rootDir}/config/style.gradle"
diff --git a/demoproviders/barbican/java/okio/BlockCipherSink.java b/demoproviders/barbican/java/okio/BlockCipherSink.java
new file mode 100644
index 0000000..d977c27
--- /dev/null
+++ b/demoproviders/barbican/java/okio/BlockCipherSink.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package okio;
+
+import java.io.IOException;
+import org.spongycastle.crypto.BlockCipher;
+import org.spongycastle.crypto.paddings.BlockCipherPadding;
+
+/**
+ * A {@link Sink} which encrypts data using a block cipher.
+ */
+public class BlockCipherSink extends ForwardingSink {
+
+    private final BlockCipher mCipher;
+    private final BlockCipherPadding mPadding;
+    private final int mBlockSize;
+    private byte[] mInBlock;
+    private byte[] mLastBlock;
+    private Buffer mOutBuffer;
+    private int mInBlockOffset;
+
+    /**
+     * Creates a sink which will encrypt written data using the provided block cipher to
+     * the provided output sink, and will pad the end of the data using the provided padding mode.
+     */
+    public BlockCipherSink(BlockCipher cipher, BlockCipherPadding padding, Sink out) {
+        super(out);
+        mCipher = cipher;
+        mPadding = padding;
+        mBlockSize = mCipher.getBlockSize();
+        mInBlock = new byte[mBlockSize];
+        mLastBlock = new byte[mBlockSize];
+        mOutBuffer = new Buffer();
+        mInBlockOffset = 0;
+    }
+
+    @Override
+    public void write(Buffer source, long byteCount) throws IOException {
+        Util.checkOffsetAndCount(source.size, 0, byteCount);
+        while (byteCount > 0) {
+            int readCount = (int)Math.min(byteCount, mInBlock.length - mInBlockOffset);
+            byteCount -= readCount;
+            source.read(mInBlock, mInBlockOffset, readCount);
+            mInBlockOffset += readCount;
+
+            if (mInBlockOffset == mInBlock.length) {
+                processBlock();
+            }
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        mPadding.addPadding(mInBlock, mInBlockOffset);
+        processBlock();
+        delegate().close();
+    }
+
+    private void processBlock() throws IOException {
+        mCipher.processBlock(mInBlock, 0, mLastBlock, 0);
+        mOutBuffer.write(mLastBlock);
+        delegate().write(mOutBuffer, mBlockSize);
+        mInBlockOffset = 0;
+    }
+}
diff --git a/demoproviders/barbican/java/okio/BlockCipherSource.java b/demoproviders/barbican/java/okio/BlockCipherSource.java
new file mode 100644
index 0000000..daaae18
--- /dev/null
+++ b/demoproviders/barbican/java/okio/BlockCipherSource.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package okio;
+
+import java.io.IOException;
+import org.spongycastle.crypto.BlockCipher;
+import org.spongycastle.crypto.InvalidCipherTextException;
+import org.spongycastle.crypto.paddings.BlockCipherPadding;
+
+/**
+ * A {@link Source} which decrypts data using a block cipher.
+ */
+public class BlockCipherSource extends ForwardingSource {
+
+    private final BlockCipher mCipher;
+    private final BlockCipherPadding mPadding;
+    private final int mBlockSize;
+
+    private final Buffer mInBuffer;
+    private final byte[] mInBlock;
+    private final byte[] mOutBlock;
+    private int mOutBlockOffset;
+    private int mOutBlockEnd;
+
+    /**
+     * Creates a source which will decrypt data from the provided input source, using the
+     * provided block cipher and padding mode.
+     */
+    public BlockCipherSource(BlockCipher cipher, BlockCipherPadding padding, Source in) {
+        super(in);
+        mCipher = cipher;
+        mPadding = padding;
+        mBlockSize = cipher.getBlockSize();
+        mInBuffer = new Buffer();
+        mInBlock = new byte[mBlockSize];
+        mOutBlock = new byte[mBlockSize];
+        mOutBlockOffset = mOutBlock.length;
+        mOutBlockEnd = mOutBlock.length;
+    }
+
+    @Override
+    public long read(Buffer sink, long byteCount) throws IOException {
+        int totalReadCount = 0;
+        while (byteCount > 0) {
+            int available = mOutBlockEnd - mOutBlockOffset;
+            if (available > 0) {
+                int readCount = (int)Math.min(byteCount, available);
+                sink.write(mOutBlock, mOutBlockOffset, readCount);
+                mOutBlockOffset += readCount;
+                available -= readCount;
+                byteCount -= readCount;
+                totalReadCount += readCount;
+            }
+
+            if (available == 0 && byteCount > 0) {
+                if (!decryptBlock()) {
+                    if (totalReadCount == 0) {
+                        return -1;
+                    }
+                    return totalReadCount;
+                }
+            }
+        }
+
+        return totalReadCount;
+    }
+
+    private boolean decryptBlock() throws IOException {
+        if (mInBuffer.exhausted()) {
+            if (!readNextBlock()) {
+                return false;
+            }
+        }
+
+        mInBuffer.read(mInBlock);
+        mCipher.processBlock(mInBlock, 0, mOutBlock, 0);
+
+        mOutBlockOffset = 0;
+        if (!readNextBlock()) {
+            // reached the last block, check for padding
+            try {
+                mOutBlockEnd = mOutBlock.length - mPadding.padCount(mOutBlock);
+            } catch (InvalidCipherTextException ex) {
+                throw new IOException("Corrupted data stream", ex);
+            }
+        } else {
+            mOutBlockEnd = mOutBlock.length;
+        }
+
+        return true;
+    }
+
+    private boolean readNextBlock() throws IOException {
+        long readCount = delegate().read(mInBuffer, mBlockSize);
+        if (readCount == -1) {
+            return false;
+        }
+
+        if (readCount < mBlockSize) {
+            throw new IOException("Corrupted data stream: depleted inside block boundary");
+        }
+
+        return true;
+    }
+}
diff --git a/demoproviders/barbican/java/okio/package-info.java b/demoproviders/barbican/java/okio/package-info.java
new file mode 100644
index 0000000..531e681
--- /dev/null
+++ b/demoproviders/barbican/java/okio/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * OKIO extensions for cryptographic streams.
+ */
+package okio;
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/Application.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/Application.java
new file mode 100644
index 0000000..8462d57
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/Application.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.support.v7.app.AppCompatDelegate;
+
+/**
+ * Application object; ensures that the support library is correctly configured for use of
+ * vector drawables.
+ */
+public class Application extends android.app.Application {
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
new file mode 100644
index 0000000..0c0c61a
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CreateCredentialActivity.java
@@ -0,0 +1,303 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.design.widget.AppBarLayout;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnItemSelected;
+import butterknife.OnTextChanged;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.proto.Credential;
+
+/**
+ * Creates credentials from manual user input for storage.
+ */
+public class CreateCredentialActivity
+        extends AppCompatActivity
+        implements CredentialStorageClient.ConnectedCallback {
+
+    private static final String LOG_TAG = "CreateCredential";
+
+    private static final int MIN_ID_LENGTH = 1;
+    private static final int MIN_PASS_LENGTH = 1;
+
+    @BindView(android.R.id.content)
+    View mRootView;
+
+    @BindView(R.id.headerToolbar)
+    Toolbar mToolbar;
+
+    @BindView(R.id.appBar)
+    AppBarLayout mAppBar;
+
+    @BindView(R.id.credential_authority)
+    Spinner mCredentialAuthority;
+
+    @BindView(R.id.credential_id)
+    EditText mCredentialId;
+
+    @BindView(R.id.credential_password)
+    EditText mCredentialPassword;
+
+    private MenuItem mDoneButton;
+
+    private CredentialStorageClient mStorageClient;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.create_credential_layout);
+        ButterKnife.bind(this);
+        getSupportActionBar();
+        setSupportActionBar(mToolbar);
+        mToolbar.setNavigationIcon(R.drawable.back);
+        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                finish();
+            }
+        });
+        mCredentialAuthority.setAdapter(new AppAdapter(getInstalledApps()));
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mStorageClient = client;
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mStorageClient.disconnect(this);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.menu_create, menu);
+        mDoneButton = menu.findItem(R.id.action_done);
+        onFieldsChanged();
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (super.onOptionsItemSelected(item)) {
+            return true;
+        }
+
+        if (R.id.action_done == item.getItemId()) {
+            App app = (App) mCredentialAuthority.getSelectedItem();
+            String username = mCredentialId.getText().toString();
+            String password = mCredentialPassword.getText().toString();
+            new StoreCredentialTask(app.mPackageName, username, password).execute();
+        }
+
+        return false;
+    }
+
+    @OnItemSelected(R.id.credential_authority)
+    @OnTextChanged({R.id.credential_id, R.id.credential_password})
+    void onFieldsChanged() {
+        boolean validCredential =
+                mCredentialAuthority.getSelectedItemPosition() != Spinner.INVALID_POSITION
+                && mCredentialId.length() >= MIN_ID_LENGTH
+                && mCredentialPassword.length() >= MIN_PASS_LENGTH;
+
+        if (mDoneButton != null) {
+            mDoneButton.setEnabled(validCredential);
+        }
+    }
+
+    private List<App> getInstalledApps() {
+        List<String> appPackageNames = InstalledAppsUtil.getInstalledAppsList(this);
+        ArrayList<App> apps = new ArrayList<>();
+        PackageManager pm = getPackageManager();
+        for (String packageName : appPackageNames) {
+            try {
+                ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
+                String appName = pm.getApplicationLabel(info).toString();
+                Drawable appIcon = pm.getApplicationIcon(info);
+                apps.add(new App(packageName, appName, appIcon));
+            } catch (PackageManager.NameNotFoundException e) {
+                // skip this app
+            }
+        }
+
+        return apps;
+    }
+
+    private class StoreCredentialTask extends AsyncTask<Void, Void, Boolean> {
+
+        final String mPackageName;
+        final String mUsername;
+        final String mPassword;
+
+        StoreCredentialTask(String packageName, String username, String password) {
+            mPackageName = packageName;
+            mUsername = username;
+            mPassword = password;
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... params) {
+            AuthenticationDomain domain = AuthenticationDomain.listForPackage(
+                    CreateCredentialActivity.this,
+                    mPackageName)
+                    .get(0);
+
+            Credential credential = new Credential.Builder()
+                    .id(mUsername)
+                    .authDomain(domain.toString())
+                    .authMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
+                    .password(mPassword)
+                    .build();
+            try {
+                mStorageClient.upsertCredential(credential);
+                return true;
+            } catch (IOException e) {
+                Log.w(LOG_TAG, "Failed to upsert credential to database");
+            }
+            return null;
+        }
+
+        @Override
+        protected void onPostExecute(Boolean success) {
+            if (success) {
+                finish();
+            } else {
+                Snackbar.make(
+                        mRootView,
+                        R.string.save_failed,
+                        Snackbar.LENGTH_SHORT).show();
+            }
+        }
+    }
+
+    private class App implements Comparable<App> {
+        @NonNull String mName;
+        @NonNull String mPackageName;
+        @Nullable Drawable mIcon;
+
+        App(@NonNull String packageName, @NonNull String name, @Nullable Drawable icon) {
+            mPackageName = packageName;
+            mName = name;
+            mIcon = icon;
+        }
+
+        @Override
+        public int compareTo(@NonNull App app) {
+            return mName.compareTo(app.mName);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+
+            if (!(obj instanceof App)) {
+                return false;
+            }
+
+            App other = (App) obj;
+            return mPackageName.equals(other.mPackageName);
+        }
+
+        @Override
+        public int hashCode() {
+            return mPackageName.hashCode();
+        }
+    }
+
+    private class AppAdapter extends BaseAdapter {
+
+        private final List<App> mApps;
+        private final LayoutInflater mInflater;
+
+        AppAdapter(@NonNull List<App> apps) {
+            mApps = apps;
+            mInflater = LayoutInflater.from(CreateCredentialActivity.this);
+        }
+
+        @Override
+        public int getCount() {
+            return mApps.size();
+        }
+
+        @Override
+        public Object getItem(int index) {
+            return mApps.get(index);
+        }
+
+        @Override
+        public long getItemId(int index) {
+            return mApps.get(index).hashCode();
+        }
+
+        @Override
+        public View getView(int index, View view, ViewGroup viewGroup) {
+            App app = mApps.get(index);
+            if (view == null) {
+                view = mInflater.inflate(R.layout.app_item, viewGroup, false);
+            }
+
+            ImageView iconView = (ImageView) view.findViewById(R.id.app_icon);
+            if (app.mIcon != null) {
+                iconView.setImageDrawable(app.mIcon);
+                iconView.setVisibility(View.VISIBLE);
+            } else {
+                iconView.setVisibility(View.INVISIBLE);
+            }
+
+            TextView nameView = (TextView) view.findViewById(R.id.app_name);
+            nameView.setText(app.mName);
+
+            return view;
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
new file mode 100644
index 0000000..964d670
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialAdapter.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.DialogInterface;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.proto.Credential;
+
+/**
+ * RecyclerView adapter for displaying stored credentials.
+ */
+class CredentialAdapter
+        extends RecyclerView.Adapter<CredentialAdapter.ViewHolder> {
+
+    private List<Credential> mCredentials;
+    private CredentialStorageClient mClient;
+
+    CredentialAdapter() {
+        mCredentials = Collections.emptyList();
+    }
+
+    void setCredentials(List<Credential> credentials) {
+        mCredentials = credentials;
+        notifyDataSetChanged();
+    }
+
+    @Override
+    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        View credentialView = LayoutInflater.from(parent.getContext())
+                .inflate(R.layout.credential_view, parent, false);
+
+        return new ViewHolder(credentialView);
+    }
+
+    @Override
+    public void onBindViewHolder(ViewHolder holder, int position) {
+        holder.bind(mCredentials.get(position));
+    }
+
+    @Override
+    public int getItemCount() {
+        return mCredentials.size();
+    }
+
+    void setCredentialStorageClient(CredentialStorageClient credentialStorageClient) {
+        mClient = credentialStorageClient;
+    }
+
+    final class ViewHolder extends RecyclerView.ViewHolder {
+
+        private TextView mAuthorityView;
+        private ImageView mAuthorityIconView;
+        private TextView mIdView;
+
+        ViewHolder(View itemView) {
+            super(itemView);
+
+            mAuthorityView = (TextView) itemView.findViewById(R.id.credential_authority);
+            mAuthorityIconView = (ImageView) itemView.findViewById(R.id.credential_authority_icon);
+            mIdView = (TextView) itemView.findViewById(R.id.credential_id);
+        }
+
+        void bind(final Credential credential) {
+            String appLabel = credential.authDomain;
+            Drawable appIcon = null;
+
+            AuthenticationDomain domain = new AuthenticationDomain(credential.authDomain);
+            if (domain.isAndroidAuthDomain()) {
+                String packageName = domain.getAndroidPackageName();
+                PackageManager pm = itemView.getContext().getPackageManager();
+                try {
+                    ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
+                    appLabel = pm.getApplicationLabel(info).toString();
+                    appIcon = pm.getApplicationIcon(info);
+                } catch (PackageManager.NameNotFoundException e) {
+                    // will just show the raw info
+                }
+            }
+
+            mAuthorityView.setText(appLabel);
+            mIdView.setText(credential.id);
+
+            if (appIcon != null) {
+                mAuthorityIconView.setImageDrawable(appIcon);
+                mAuthorityIconView.setVisibility(View.VISIBLE);
+            } else {
+                mAuthorityIconView.setVisibility(View.INVISIBLE);
+            }
+
+            itemView.setOnLongClickListener(new View.OnLongClickListener() {
+                @Override
+                public boolean onLongClick(View view) {
+                    AlertDialog dialog = new AlertDialog.Builder(itemView.getContext())
+                            .setTitle(R.string.ask_delete_credential)
+                            .setPositiveButton(R.string.openyolo_simple_yes,
+                                    new DialogInterface.OnClickListener() {
+                                        @Override
+                                        public void onClick(DialogInterface dialogInterface,
+                                                            int which) {
+                                            try {
+                                                mClient.deleteCredential(credential);
+                                                mCredentials.remove(credential);
+                                                notifyDataSetChanged();
+                                            } catch (IOException e) {
+                                                e.printStackTrace();
+                                            }
+                                        }
+                                    })
+                            .setNegativeButton(R.string.openyolo_simple_no, null)
+                            .create();
+
+                    dialog.show();
+                    return true;
+                }
+            });
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
new file mode 100644
index 0000000..b105746
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialClassifier.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.net.Uri;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.NonNull;
+import android.util.Patterns;
+import java.util.Collection;
+import java.util.regex.Pattern;
+import org.openyolo.api.IdentifierTypes;
+import org.openyolo.proto.Credential;
+
+/**
+ * Heuristically identifies the "type" of a password credential based on the ID value.
+ */
+public final class CredentialClassifier {
+
+    private static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9]+");
+
+    /**
+     * Determines whether the credential identifier is an email address.
+     */
+    public static boolean isEmailCredential(Credential credential) {
+        return isEmailIdentifier(credential.id);
+    }
+
+    /**
+     * Determines whether the provided identifier is an email address.
+     */
+    public static boolean isEmailIdentifier(String identifier) {
+        return Patterns.EMAIL_ADDRESS.matcher(identifier).matches();
+    }
+
+    /**
+     * Determines whether the credential identifier is a phone number.
+     */
+    public static boolean isPhoneCredential(Credential credential) {
+        return isPhoneIdentifier(credential.id);
+    }
+
+    /**
+     * Determines whether the provided identifier is a phone number.
+     */
+    public static boolean isPhoneIdentifier(String identifier) {
+        return Patterns.PHONE.matcher(identifier).matches();
+    }
+
+    /**
+     * Determines whether the provided identifier contains alphanumeric characters only.
+     */
+    public static boolean isAlphanumericIdentifier(String identifier) {
+        return ALPHANUMERIC_PATTERN.matcher(identifier).matches();
+    }
+
+    /**
+     * Determines whether the provided identifier matches any of the provided types.
+     *
+     * @see {@link IdentifierTypes}
+     */
+    public static boolean identifierMatchesOneOf(
+            @NonNull String identifier,
+            @NonNull Collection<Uri> identifierTypes) {
+        for (Uri identifierType : identifierTypes) {
+            if (IdentifierTypes.EMAIL.equals(identifierType) && isEmailIdentifier(identifier)) {
+                return true;
+            }
+
+            if (IdentifierTypes.PHONE.equals(identifierType) && isPhoneIdentifier(identifier)) {
+                return true;
+            }
+
+            if (IdentifierTypes.ALPHANUMERIC.equals(identifierType)
+                    && isAlphanumericIdentifier(identifier)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns a drawable resource which can be used as a default profile picture for a
+     * credential.
+     */
+    @DrawableRes
+    public static int getDefaultIconForCredential(Credential credential) {
+        if (isEmailCredential(credential)) {
+            return R.drawable.email;
+        } else if (isPhoneCredential(credential)) {
+            return R.drawable.phone;
+        }
+
+        return R.drawable.person;
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
new file mode 100644
index 0000000..da57775
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialListActivity.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import java.io.IOException;
+import java.util.List;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient.ConnectedCallback;
+import org.openyolo.proto.Credential;
+
+/**
+ * Displays the user's stored credentials.
+ */
+public class CredentialListActivity
+        extends AppCompatActivity
+        implements ConnectedCallback {
+
+    private static final String LOG_TAG = "CLActivity";
+
+    private CredentialStorageClient mStorageClient;
+
+    @BindView(R.id.headerToolbar)
+    Toolbar mToolbar;
+
+    @BindView(R.id.credential_list)
+    RecyclerView mCredentialsView;
+
+    private CredentialAdapter mCredentialAdapter;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.credential_list_layout);
+        ButterKnife.bind(this);
+        setSupportActionBar(mToolbar);
+        mCredentialAdapter = new CredentialAdapter();
+        mCredentialsView.setAdapter(mCredentialAdapter);
+        mCredentialsView.setLayoutManager(
+                new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mStorageClient = client;
+        mCredentialAdapter.setCredentialStorageClient(client);
+        if (checkUnlocked()) {
+            new LoadCredentialsTask().execute();
+        }
+    }
+
+    private boolean checkUnlocked() {
+        if (!mStorageClient.isUnlocked()) {
+            startActivity(new Intent(this, UnlockActivity.class));
+            finish();
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mStorageClient.disconnect(this);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.menu_main, menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (super.onOptionsItemSelected(item)) {
+            return true;
+        }
+
+        if (R.id.action_lock == item.getItemId()) {
+            mStorageClient.lock();
+            startActivity(new Intent(this, UnlockActivity.class));
+            finish();
+            return true;
+        }
+
+        if (R.id.action_wipe == item.getItemId()) {
+            startActivity(new Intent(this, NeverSaveListActivity.class));
+            return true;
+        }
+        return false;
+    }
+
+    @OnClick(R.id.create_credential)
+    void onCreateCredential() {
+        startActivity(new Intent(this, CreateCredentialActivity.class));
+    }
+
+    private class LoadCredentialsTask extends AsyncTask<Void, Void, List<Credential>> {
+
+        @Override
+        protected List<Credential> doInBackground(Void... params) {
+            try {
+                return mStorageClient.listAllCredentials();
+            } catch (IOException ex) {
+                Log.e(LOG_TAG, "Failed to list credentials", ex);
+                return null;
+            }
+        }
+
+        @Override
+        protected void onPostExecute(List<Credential> credentials) {
+            if (credentials != null) {
+                ((CredentialAdapter) mCredentialsView.getAdapter()).setCredentials(credentials);
+            }
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
new file mode 100644
index 0000000..1c74ad3
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/CredentialQualityScore.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import java.util.Comparator;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.proto.Credential;
+
+/**
+ * Derives quality scores for credentials and hints that can help to order lists of them based on
+ * how useful they are to an application.
+ */
+public class CredentialQualityScore {
+
+    /**
+     * A comparator which orders credentials in descending order of quality score, i.e. those with
+     * the highest quality score first.
+     */
+    public static final Comparator<Credential> QUALITY_SORT = new CredentialQualityComparator();
+
+    /**
+     * Generates the score for the user data in an account hint.
+     */
+    public static int getScore(AccountHint hint) {
+        return getQualityScore(hint.identifier, hint.authMethod, hint.name, hint.pictureUri);
+    }
+
+    /**
+     * Generates the score for the user data in a credential.
+     */
+    public static int getScore(Credential credential) {
+        return getQualityScore(
+                credential.id,
+                credential.authMethod,
+                credential.displayName,
+                credential.displayPictureUri);
+    }
+
+    private static int getQualityScore(
+            @Nullable String id,
+            @Nullable String authMethod,
+            @Nullable String name,
+            @Nullable String pictureUri) {
+
+        int score = 1;
+
+        // email identifiers are recognisable and useful for ID token acquisition
+        if (CredentialClassifier.isEmailIdentifier(id)) {
+            score <<= 1;
+        }
+
+        // prefer credentials that don't use passwords
+        if (!AuthenticationMethods.ID_AND_PASSWORD.equals(authMethod)) {
+            score <<= 1;
+        }
+
+        // prefer credentials that have a human readable name
+        if (!TextUtils.isEmpty(name)) {
+            score <<= 1;
+        }
+
+        // prefer credentials that have a profile picture
+        if (!TextUtils.isEmpty(pictureUri)) {
+            score <<= 1;
+        }
+
+        return score;
+    }
+
+    private static final class CredentialQualityComparator implements Comparator<Credential> {
+
+        @Override
+        public int compare(Credential c1, Credential c2) {
+            int c1Score = getScore(c1);
+            int c2Score = getScore(c2);
+
+            // higher scores (more information) come first
+            if (c1Score > c2Score) {
+                return -1;
+            } else if (c1Score == c2Score) {
+                return 0;
+            }
+
+            return 1;
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/InstalledAppsUtil.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/InstalledAppsUtil.java
new file mode 100644
index 0000000..2069754
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/InstalledAppsUtil.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Interrogates the system for installed, non-system applications.
+ */
+public class InstalledAppsUtil {
+
+    /**
+     * Retrieves a set of the package names of all non-system applications.
+     */
+    public static Set<String> getInstalledApps(Context context) {
+        PackageManager pm = context.getPackageManager();
+        List<ApplicationInfo> installedAppInfos =
+                pm.getInstalledApplications(PackageManager.GET_META_DATA);
+
+        TreeSet<String> apps = new TreeSet<>();
+        for (ApplicationInfo info : installedAppInfos) {
+            // ignore self
+            if (context.getPackageName().equals(info.packageName)) {
+                continue;
+            }
+
+            // skip system apps
+            if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+                continue;
+            }
+
+            apps.add(info.packageName);
+        }
+
+        return apps;
+    }
+
+    /**
+     * Retrieves a list of the package names of all non-system applications.
+     */
+    public static List<String> getInstalledAppsList(Context context) {
+        return new ArrayList<>(getInstalledApps(context));
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/LaunchActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/LaunchActivity.java
new file mode 100644
index 0000000..69d3fac
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/LaunchActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient.ConnectedCallback;
+
+public class LaunchActivity
+        extends AppCompatActivity
+        implements ConnectedCallback {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        final Intent nextActivity;
+        if (client.isCreated()) {
+            if (client.isUnlocked()) {
+                nextActivity = new Intent(this, CredentialListActivity.class);
+            } else {
+                nextActivity = new Intent(this, UnlockActivity.class);
+            }
+        } else {
+            nextActivity = new Intent(this, WelcomeActivity.class);
+        }
+
+        client.disconnect(this);
+
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                startActivity(nextActivity);
+                finish();
+            }
+        });
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/LockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/LockActivity.java
new file mode 100644
index 0000000..7122d04
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/LockActivity.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.app.Activity;
+import android.os.Bundle;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+/**
+ * Locks the credential store in response to an action from the persistent "unlocked" notification.
+ */
+public class LockActivity extends Activity implements CredentialStorageClient.ConnectedCallback {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        client.lock();
+        finish();
+        client.disconnect(this);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java
new file mode 100644
index 0000000..88adefc
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveAppAdapter.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import static android.content.DialogInterface.OnClickListener;
+
+import android.content.DialogInterface;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+
+/**
+ * RecyclerView adapter for displaying the API implementers for which Barbican picked "never save"
+ * when attempting to store a credential.
+ */
+class NeverSaveAppAdapter extends RecyclerView.Adapter<NeverSaveAppAdapter.ViewHolder> {
+
+    private static final String LOGTAG = "NeverSaveAppAdapter";
+    private List<String> mPairedItems;
+    private CredentialStorageClient mCredentialStorageClient;
+
+    NeverSaveAppAdapter() {
+        mPairedItems = Collections.emptyList();
+    }
+
+    /**
+     * Adds a link to the storage client used by Barbican, the example password manager.
+     *
+     * @param credentialStorageClient - the client linking to app data
+     */
+    void setCredentialStorageClient(CredentialStorageClient credentialStorageClient) {
+        mCredentialStorageClient = credentialStorageClient;
+        registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
+            @Override
+            public void onChanged() {
+                super.onChanged();
+                refreshList();
+            }
+        });
+        notifyDataSetChanged();
+    }
+
+    @Override
+    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        View credentialView = LayoutInflater.from(
+                parent.getContext()).inflate(R.layout.paired_api_item, parent, false);
+        return new ViewHolder(credentialView);
+    }
+
+    @Override
+    public void onBindViewHolder(ViewHolder holder, int position) {
+        holder.bind(mPairedItems.get(position));
+    }
+
+    @Override
+    public int getItemCount() {
+        return mPairedItems.size();
+    }
+
+    /**
+     * Re-queries the list from storage.
+     */
+    private void refreshList() {
+        try {
+            mPairedItems = mCredentialStorageClient.getNeverSaveList();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    final class ViewHolder extends RecyclerView.ViewHolder {
+
+        private TextView mAuthorityView;
+        private ImageView mAuthorityIconView;
+        private TextView mIdView;
+        private ImageButton mDeleteBtn;
+
+        ViewHolder(View itemView) {
+            super(itemView);
+
+            mAuthorityView = (TextView) itemView.findViewById(R.id.paired_api_title);
+            mAuthorityIconView = (ImageView) itemView.findViewById(R.id.api_icon);
+            mIdView = (TextView) itemView.findViewById(R.id.paired_api_desc);
+            mDeleteBtn = (ImageButton) itemView.findViewById(R.id.btn_delete);
+        }
+
+        void bind(final String apibind) {
+            String appLabel = apibind;
+            Drawable appIcon = null;
+            String packageName = null;
+            final AuthenticationDomain domain = new AuthenticationDomain(apibind);
+            if (domain.isAndroidAuthDomain()) {
+                packageName = domain.getAndroidPackageName();
+                PackageManager pm = itemView.getContext().getPackageManager();
+                try {
+                    ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
+                    appLabel = pm.getApplicationLabel(info).toString();
+                    appIcon = pm.getApplicationIcon(info);
+                } catch (PackageManager.NameNotFoundException e) {
+                    // will just show the raw info
+                }
+            }
+
+            mAuthorityView.setText(appLabel);
+            mIdView.setText(domain.getAndroidPackageName());
+
+            if (appIcon != null) {
+                mAuthorityIconView.setImageDrawable(appIcon);
+                mAuthorityIconView.setVisibility(View.VISIBLE);
+            } else {
+                mAuthorityIconView.setVisibility(View.INVISIBLE);
+            }
+            mDeleteBtn.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    showDeletePopup(domain);
+                }
+            });
+            itemView.setOnLongClickListener(new View.OnLongClickListener() {
+                @Override
+                public boolean onLongClick(View view) {
+                    showDeletePopup(domain);
+                    return true;
+                }
+            });
+        }
+
+        private void showDeletePopup(final AuthenticationDomain domain) {
+            AlertDialog dialog = new AlertDialog.Builder(itemView.getContext())
+                    .setTitle(R.string.remove_unpaired_api_dialog_title)
+                    .setPositiveButton(R.string.openyolo_simple_yes, new OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialogInterface, int which) {
+                            List<AuthenticationDomain> list = new ArrayList<>();
+                            list.add(domain);
+                            try {
+                                mCredentialStorageClient.removeFromNeverSaveList(list);
+                            } catch (IOException e) {
+                                Log.d(LOGTAG, "Failed to clear item from Storage, error :", e);
+                            }
+                            notifyDataSetChanged();
+                        }
+                    })
+                    .setNegativeButton(R.string.openyolo_simple_no, null)
+                    .create();
+
+            dialog.show();
+
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveListActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveListActivity.java
new file mode 100644
index 0000000..f10d695
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/NeverSaveListActivity.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import static org.openyolo.demoprovider.barbican.storage.CredentialStorageClient.ConnectedCallback;
+import static org.openyolo.demoprovider.barbican.storage.CredentialStorageClient.connect;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Toast;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import java.io.IOException;
+import java.util.List;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+/**
+ * Displays the list of API implementors for which we have picked the "never save" option
+ * user could review, select and undo one, a segment or all items.
+ */
+public class NeverSaveListActivity
+        extends AppCompatActivity
+        implements ConnectedCallback {
+
+    private CredentialStorageClient mStorageClient;
+
+    @BindView(R.id.headerToolbar)
+    Toolbar mToolbar;
+
+    @BindView(R.id.paired_list)
+    RecyclerView mNeverSaveList;
+    private NeverSaveAppAdapter mAppAdapter;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.apipairing_list_layout);
+        ButterKnife.bind(this);
+        setSupportActionBar(mToolbar);
+        mAppAdapter = new NeverSaveAppAdapter();
+        mNeverSaveList.setAdapter(mAppAdapter);
+        mNeverSaveList.setLayoutManager(
+                new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mStorageClient = client;
+        mAppAdapter.setCredentialStorageClient(client);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mStorageClient.disconnect(this);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.menu_main, menu);
+        //hide the lock icon in this case
+        menu.getItem(1).setVisible(false);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (super.onOptionsItemSelected(item)) {
+            return true;
+        }
+
+        if (R.id.action_wipe == item.getItemId()) {
+            try {
+                List<String> list = mStorageClient.getNeverSaveList();
+                Toast.makeText(this, list.toString(), Toast.LENGTH_LONG).show();
+                mStorageClient.clearNeverSaveList();
+                mAppAdapter.notifyDataSetChanged();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            return true;
+        }
+        return false;
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java
new file mode 100644
index 0000000..a16c04a
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/UnlockActivity.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnEditorAction;
+import java.io.IOException;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+public class UnlockActivity
+        extends AppCompatActivity
+        implements CredentialStorageClient.ConnectedCallback {
+
+    private static final String EXTRA_AS_DIALOG = "asDialog";
+    private static final String EXTRA_AFTER_UNLOCK = "afterUnlock";
+    private static final String LOG_TAG = "UnlockActivity";
+
+    private CredentialStorageClient mStorageClient;
+
+    @BindView(android.R.id.content)
+    View mRootView;
+
+    @BindView(R.id.password_entry)
+    View mPasswordEntryForm;
+
+    @BindView(R.id.invalid_password)
+    View mInvalidPasswordError;
+
+    @BindView(R.id.password)
+    EditText mPasswordField;
+
+    @BindView(R.id.loading)
+    View mLoadingView;
+
+    /**
+     * Creates an intent to display the unlock screen, triggering the provided intent after
+     * unlock.
+     */
+    public static Intent createIntent(Context context, boolean asDialog, Intent afterUnlock) {
+        Intent intent = new Intent(context, UnlockActivity.class);
+        intent.putExtra(EXTRA_AS_DIALOG, asDialog);
+        intent.putExtra(EXTRA_AFTER_UNLOCK, afterUnlock);
+        return intent;
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (showAsDialog()) {
+            setTheme(R.style.AppTheme_Dialog);
+        } else {
+            setTheme(R.style.AppTheme_NoActionBar);
+        }
+
+        setContentView(R.layout.unlock_layout);
+        ButterKnife.bind(this);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mStorageClient = client;
+
+        if (client.isUnlocked()) {
+            startActivity(getAfterUnlock());
+            finish();
+        }
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mStorageClient.disconnect(this);
+    }
+
+    @OnEditorAction(R.id.password)
+    boolean onPasswordConfirmedViaIme() {
+        new UnlockTask(mPasswordField.getText().toString()).execute();
+        return true;
+    }
+
+    private boolean showAsDialog() {
+        return getIntent().getBooleanExtra(EXTRA_AS_DIALOG, false);
+    }
+
+    private Intent getAfterUnlock() {
+        if (getIntent().hasExtra(EXTRA_AFTER_UNLOCK)) {
+            return getIntent().getParcelableExtra(EXTRA_AFTER_UNLOCK);
+        } else {
+            return new Intent(this, CredentialListActivity.class);
+        }
+    }
+
+    private class UnlockTask extends AsyncTask<Void, Void, Boolean> {
+
+        private final String mPassword;
+
+        UnlockTask(String password) {
+            mPassword = password;
+        }
+
+        @Override
+        protected void onPreExecute() {
+            mPasswordEntryForm.setVisibility(View.GONE);
+            mLoadingView.setVisibility(View.VISIBLE);
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... params) {
+            try {
+                return mStorageClient.unlock(mPassword);
+            } catch (IOException ex) {
+                Log.e(LOG_TAG, "Failed to unlock credential store", ex);
+                return false;
+            }
+        }
+
+        @Override
+        protected void onPostExecute(Boolean result) {
+            if (result) {
+                startActivity(getAfterUnlock());
+                finish();
+            } else {
+                mPasswordEntryForm.setVisibility(View.VISIBLE);
+                mInvalidPasswordError.setVisibility(View.VISIBLE);
+                mLoadingView.setVisibility(View.GONE);
+            }
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java
new file mode 100644
index 0000000..9cbd307
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/WelcomeActivity.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican;
+
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnEditorAction;
+import java.io.IOException;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+public class WelcomeActivity
+        extends AppCompatActivity
+        implements CredentialStorageClient.ConnectedCallback {
+
+    private static final String LOG_TAG = "WelcomeActivity";
+    private static final int MIN_PASSWORD_SIZE = 6;
+
+    private CredentialStorageClient mStorageClient;
+
+    @BindView(android.R.id.content)
+    View mRootView;
+
+    @BindView(R.id.password)
+    EditText mPasswordField;
+
+    @BindView(R.id.loading)
+    View mLoadingView;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.welcome_layout);
+        ButterKnife.bind(this);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mStorageClient = client;
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mStorageClient.disconnect(this);
+    }
+
+    @OnEditorAction(R.id.password)
+    boolean onPasswordConfirmedViaIme() {
+        if (!isPasswordValid(mPasswordField.getText().toString())) {
+            return false;
+        }
+
+        initializeStorage();
+        return true;
+    }
+
+    private boolean isPasswordValid(String password) {
+        return password.length() >= MIN_PASSWORD_SIZE;
+    }
+
+    private void initializeStorage() {
+        new InitializeStorageTask(mPasswordField.getText().toString()).execute();
+    }
+
+    private class InitializeStorageTask extends AsyncTask<Void, Void, Boolean> {
+
+        private String mPassword;
+
+        InitializeStorageTask(String password) {
+            mPassword = password;
+        }
+
+        @Override
+        protected void onPreExecute() {
+            mPasswordField.setVisibility(View.GONE);
+            mLoadingView.setVisibility(View.VISIBLE);
+        }
+
+        protected Boolean doInBackground(Void... params) {
+            try {
+                mStorageClient.create(mPassword);
+                return true;
+            } catch (IOException ex) {
+                Log.e(LOG_TAG, "Failed to create credential storage", ex);
+                return false;
+            }
+        }
+
+        @Override
+        protected void onPostExecute(Boolean success) {
+            if (success) {
+                startActivity(new Intent(WelcomeActivity.this, CredentialListActivity.class));
+                finish();
+            } else {
+                mPasswordField.setVisibility(View.VISIBLE);
+                mLoadingView.setVisibility(View.GONE);
+                Snackbar.make(mRootView,
+                        R.string.create_failure,
+                        Snackbar.LENGTH_LONG).show();
+            }
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/package-info.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/package-info.java
new file mode 100644
index 0000000..68b2d79
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Example implementation of the OpenYOLO SPI.
+ */
+package org.openyolo.demoprovider.barbican;
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
new file mode 100644
index 0000000..99e7503
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/AutoSignInActivity.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.view.Window;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import java.io.IOException;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.proto.Credential;
+import org.openyolo.spi.RetrieveIntentResultUtil;
+
+/**
+ * Displays a brief, "snackbar"-like notification to the user indicating that a credential
+ * is being returned to a requesting app.
+ */
+public class AutoSignInActivity extends AppCompatActivity {
+
+    private static final long DISPLAY_TIME_MS = 2000;
+
+    private static final String EXTRA_CREDENTIAL = "credential";
+
+    @BindView(android.R.id.content)
+    View mRootView;
+
+    @BindView(R.id.credential_primary)
+    TextView mCredentialPrimary;
+
+    @BindView(R.id.credential_secondary)
+    TextView mCredentialSecondary;
+
+    /**
+     * Creates an intent to display this activity with the specified credential.
+     */
+    public static Intent createIntent(Context context, Credential credential) {
+        Intent intent = new Intent(context, AutoSignInActivity.class);
+        intent.putExtra(EXTRA_CREDENTIAL, credential.encode());
+        return intent;
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.auto_sign_in_layout);
+        positionWindow();
+        ButterKnife.bind(this);
+
+        Credential credential = getCredential();
+        if (credential.displayName != null) {
+            mCredentialPrimary.setText(credential.displayName);
+            mCredentialSecondary.setText(credential.id);
+        } else {
+            mCredentialPrimary.setText(credential.id);
+            mCredentialSecondary.setVisibility(View.GONE);
+        }
+
+        mRootView.postDelayed(new ReturnCredentialTask(), DISPLAY_TIME_MS);
+    }
+
+    /**
+     * Ensures the activity's window fills the full "visible" section of the screen, excluding
+     * the status bar. This is a workaround for a size bug when using
+     * {@code windowMinWidthMajor / windowMinWidthMinor} that can leave the windows a few pixels
+     * off the correct size.
+     */
+    private void positionWindow() {
+        Rect rectangle = new Rect();
+        Window window = getWindow();
+        window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
+
+        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
+        int statusBarHeight = 0;
+        if (resourceId > 0) {
+            statusBarHeight = getResources().getDimensionPixelSize(resourceId);
+        }
+
+        getWindow().setLayout(
+                rectangle.width(),
+                rectangle.height() - statusBarHeight);
+    }
+
+
+    private Credential getCredential() {
+        byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
+        try {
+            return Credential.ADAPTER.decode(credentialBytes);
+        } catch (IOException e) {
+            throw new IllegalStateException("Unable to decode credential");
+        }
+    }
+
+    private class ReturnCredentialTask implements Runnable {
+        @Override
+        public void run() {
+            Intent responseData = RetrieveIntentResultUtil.createResponseData(getCredential());
+            setResult(RESULT_OK, responseData);
+            finish();
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
new file mode 100644
index 0000000..3f46233
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialPickerActivity.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import com.bumptech.glide.Glide;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.openyolo.demoprovider.barbican.CredentialClassifier;
+import org.openyolo.demoprovider.barbican.CredentialQualityScore;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.proto.Credential;
+import org.openyolo.proto.CredentialList;
+import org.openyolo.spi.RetrieveIntentResultUtil;
+
+/**
+ * Displays a dialog to pick a credential from a list.
+ */
+public class CredentialPickerActivity extends AppCompatActivity {
+
+    private static final String LOG_TAG = "CredentialPicker";
+
+    private static final String EXTRA_CREDENTIALS = "credentials";
+
+    @BindView(R.id.available_credentials)
+    RecyclerView mCredentialView;
+
+    /**
+     * Creates an intent to display the credential picker with the provided set of credentials.
+     */
+    public static Intent createIntent(Context context, List<Credential> credentials) {
+        Intent intent = new Intent(context, CredentialPickerActivity.class);
+        intent.putExtra(EXTRA_CREDENTIALS, new CredentialList(credentials).encode());
+        return intent;
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        Log.i(LOG_TAG, "Picker invoked by " + getCallingPackage());
+
+        setContentView(R.layout.picker_layout);
+        ButterKnife.bind(this);
+
+        mCredentialView.setAdapter(new CredentialPickerAdapter(getCredentials()));
+        mCredentialView.setLayoutManager(new LinearLayoutManager(this));
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
+            setResult(RESULT_CANCELED);
+            finish();
+            return true;
+        }
+
+        return super.onTouchEvent(event);
+    }
+
+    private List<Credential> getCredentials() {
+        byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIALS);
+        try {
+            List<Credential> credentials =
+                    new ArrayList<>(CredentialList.ADAPTER.decode(credentialBytes).credentials);
+            Collections.sort(credentials, CredentialQualityScore.QUALITY_SORT);
+            return credentials;
+        } catch (IOException ex) {
+            throw new IllegalStateException("Failed to decode credentials from intent", ex);
+        }
+    }
+
+    private final class CredentialPickerAdapter extends RecyclerView.Adapter<CredentialViewHolder> {
+
+        List<Credential> mCredentials;
+
+        CredentialPickerAdapter(List<Credential> credentials) {
+            mCredentials = credentials;
+        }
+
+        @Override
+        public CredentialViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+            View credentialView = LayoutInflater.from(parent.getContext())
+                    .inflate(R.layout.credential_picker_item_view, parent, false);
+
+            return new CredentialViewHolder(credentialView);
+        }
+
+        @Override
+        public void onBindViewHolder(CredentialViewHolder holder, int position) {
+            holder.bind(mCredentials.get(position));
+        }
+
+        @Override
+        public int getItemCount() {
+            return mCredentials.size();
+        }
+    }
+
+    private final class CredentialViewHolder extends RecyclerView.ViewHolder {
+
+        private ImageView mProfileIcon;
+        private TextView mPrimaryLabel;
+        private TextView mSecondaryLabel;
+
+        CredentialViewHolder(View itemView) {
+            super(itemView);
+
+            mProfileIcon = (ImageView) itemView.findViewById(R.id.credential_icon);
+            mPrimaryLabel = (TextView) itemView.findViewById(R.id.credential_primary_label);
+            mSecondaryLabel = (TextView) itemView.findViewById(R.id.credential_secondary_label);
+        }
+
+        void bind(final Credential credential) {
+
+            int iconId = CredentialClassifier.getDefaultIconForCredential(credential);
+
+            if (credential.displayPictureUri != null) {
+                Uri displayPictureUri = Uri.parse(credential.displayPictureUri);
+                Glide.with(CredentialPickerActivity.this)
+                        .load(displayPictureUri)
+                        .fitCenter()
+                        .fallback(iconId)
+                        .into(mProfileIcon);
+            } else {
+                mProfileIcon.setImageResource(iconId);
+            }
+
+            if (credential.displayName != null) {
+                mPrimaryLabel.setText(credential.displayName);
+                mSecondaryLabel.setText(credential.id);
+                mSecondaryLabel.setVisibility(View.VISIBLE);
+            } else {
+                mPrimaryLabel.setText(credential.id);
+                mSecondaryLabel.setVisibility(View.GONE);
+            }
+
+            itemView.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    Intent responseData =
+                            RetrieveIntentResultUtil.createResponseData(credential);
+                    setResult(RESULT_OK, responseData);
+                    finish();
+                }
+            });
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
new file mode 100644
index 0000000..9df1169
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/CredentialQueryReceiver.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.util.Log;
+import com.google.bbq.QueryResponseSender;
+import com.google.bbq.proto.BroadcastQuery;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import okio.ByteString;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.RetrieveRequest;
+import org.openyolo.api.internal.IntentUtil;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorage;
+import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.spi.BaseCredentialQueryReceiver;
+
+/**
+ * Implements the OpenYOLO credential query receiver. This receiver is able to determine whether
+ * a credential exists for the claimed set of authentication domains without unlocking the
+ * password store.
+ */
+public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
+
+    private static final String LOG_TAG = "CredentialQueryReceiver";
+
+    /**
+     * Creates the query receiver.
+     */
+    public CredentialQueryReceiver() {
+        super(LOG_TAG);
+    }
+
+    @Override
+    protected void processCredentialRequest(
+            @NonNull final Context context,
+            @NonNull final BroadcastQuery query,
+            @NonNull RetrieveRequest request,
+            @NonNull Set<AuthenticationDomain> requestorDomains) {
+
+        final Context applicationContext = context.getApplicationContext();
+        final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
+
+        // NOTE: in a more complete implementation, this is where we would expand the set of
+        // authentication domains listed in requestorDomains to all equivalent authentication
+        // domains (such as affiliated apps and sites). This potentially larger list would then be
+        // matched against the requested set of domains.
+
+        final Set<AuthenticationDomain> matchingDomains = new HashSet<>();
+        for (AuthenticationDomain domain : request.getAuthenticationDomains()) {
+            if (requestorDomains.contains(domain)) {
+                matchingDomains.add(domain);
+            } else {
+                Log.i(LOG_TAG, "Access to credentials in domain " + domain
+                        + " denied to " + query.requestingApp);
+            }
+        }
+
+        if (matchingDomains.isEmpty()) {
+            Log.w(LOG_TAG, "Credential request from " + query.requestingApp
+                    + " does not match any permitted domains");
+            responseSender.sendResponse(query, null);
+            return;
+        }
+
+        Log.i(LOG_TAG, "Processing query for " + query.requestingApp);
+
+        CredentialStorage storage;
+        try {
+            storage = new CredentialStorage(context);
+        }  catch (IOException ex) {
+            Log.w(LOG_TAG, "Failed to open credential storage", ex);
+            responseSender.sendResponse(query, null);
+            return;
+        }
+
+        boolean credentialsFound = false;
+        byte[] responseBytes = null;
+
+        Iterator<AuthenticationDomain> authDomainIter = matchingDomains.iterator();
+        while (!credentialsFound && authDomainIter.hasNext()) {
+            credentialsFound = storage.hasCredentialFor(authDomainIter.next().toString());
+        }
+
+        Log.d(LOG_TAG, "Credentials found for " + query.requestingApp + ": " + credentialsFound);
+
+        if (credentialsFound) {
+            Intent retrieveIntent = RetrieveCredentialActivity.createIntent(context);
+            CredentialRetrieveResponse response = new CredentialRetrieveResponse.Builder()
+                    .retrieveIntent(ByteString.of(IntentUtil.toBytes(retrieveIntent)))
+                    .build();
+            responseBytes = response.encode();
+        }
+
+        responseSender.sendResponse(query, responseBytes);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
new file mode 100644
index 0000000..f1ce507
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/HintActivity.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2017 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.UiThread;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.api.HintRequest;
+import org.openyolo.demoprovider.barbican.CredentialClassifier;
+import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.proto.Credential;
+
+public class HintActivity
+        extends AppCompatActivity
+        implements CredentialStorageClient.ConnectedCallback {
+
+    private static final String LOG_TAG = "HintActivity";
+
+    private HintRequest mRequest;
+    private AuthenticationDomain mCallerAuthDomain;
+    private CredentialStorageClient mClient;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (!getIntent().hasExtra(CredentialClient.EXTRA_HINT_REQUEST)) {
+            Log.w(LOG_TAG, "No hint request object found in the intent");
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        try {
+            mRequest = HintRequest.fromProtoBytes(
+                    getIntent().getByteArrayExtra(CredentialClient.EXTRA_HINT_REQUEST));
+        } catch (IOException ex) {
+            Log.w(LOG_TAG, "Failed to decode hint request from intent", ex);
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        if (!extractCallerAuthDomain()) {
+            Log.w(LOG_TAG, "Unable to identify calling app");
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mClient = client;
+
+        if (!mClient.isCreated()) {
+            Log.i(LOG_TAG, "Store is not yet initialized, cannot serve hints");
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        // some credential provider implementations may require an unlock to retrieve the
+        // information required for hints, but for Barbican we instead choose to store basic
+        // profile information usable for hints in plain text. With root access, this information
+        // would be retrievable by malicious applications on the device, representing a privacy
+        // risk. However, full credentials and associations between account identifiers
+        // remain encrypted.
+
+        List<AccountHint> hints;
+        try {
+            hints = mClient.getHints();
+        } catch (IOException ex) {
+            Log.e(LOG_TAG, "Failed to retrieve hints from the credential store", ex);
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        // filter the credentials to just those which are pertinent to the request. For those
+        // selected, turn them into credentials. Order the hints by the amount of information
+        // they contain (so more complete items are displayed first), and then alphabetically.
+        ArrayList<Credential> filteredHints = new ArrayList<>();
+        for (AccountHint hint : hints) {
+            Set<Uri> authMethods = mRequest.getAuthenticationMethods();
+            if (!authMethods.contains(Uri.parse(hint.authMethod))) {
+                continue;
+            }
+
+            Set<Uri> identifierTypes = mRequest.getIdentifierTypes();
+            if (!identifierTypes.isEmpty()
+                    && !CredentialClassifier.identifierMatchesOneOf(
+                            hint.identifier,
+                            identifierTypes)) {
+                continue;
+            }
+
+            Credential.Builder hintCredentialBuilder = new Credential.Builder()
+                    .id(hint.identifier)
+                    .authMethod(hint.authMethod)
+                    .authDomain(mCallerAuthDomain.toString())
+                    .displayName(hint.name)
+                    .displayPictureUri(hint.pictureUri);
+
+            // include a generated password if appropriate
+            if (hint.authMethod.equals(AuthenticationMethods.ID_AND_PASSWORD.toString())) {
+                hintCredentialBuilder.password(mRequest.getPasswordSpecification().generate());
+            }
+
+            filteredHints.add(hintCredentialBuilder.build());
+        }
+
+        // if there are no hints, immediately end the request
+        if (filteredHints.isEmpty()) {
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        // otherwise, display the standard credential picker.
+        Intent pickerIntent = CredentialPickerActivity.createIntent(
+                this,
+                filteredHints);
+        pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+        startActivity(pickerIntent);
+        finish();
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mClient.disconnect(this);
+    }
+
+    private boolean extractCallerAuthDomain() {
+        ComponentName callingActivity = getCallingActivity();
+        if (callingActivity == null) {
+            Log.w(LOG_TAG, "No calling activity found for save call");
+            return false;
+        }
+
+        // TODO: a more complete implementation would need to expand this to the full set of
+        // affiliated apps and sites, though it is generally unusual for an app to save a
+        // credential for any authentication domain other than those it can directly identify as.
+        String callingPackage = callingActivity.getPackageName();
+        List<AuthenticationDomain> authDomains =
+                AuthenticationDomain.listForPackage(this, callingPackage);
+
+        if (authDomains.isEmpty()) {
+            return false;
+        }
+
+        mCallerAuthDomain = authDomains.get(0);
+        return true;
+    }
+
+    @UiThread
+    private void finish(int resultCode) {
+        setResult(resultCode);
+        finish();
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
new file mode 100644
index 0000000..2b7618b
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/RetrieveCredentialActivity.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import java.io.IOException;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.UnlockActivity;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.proto.Credential;
+
+/**
+ * A UI-less activity that determines how to retrieve a requested credential. If the credential
+ * store is locked, an unlock activity is started before proceeding. If the store is unlocked
+ * and a single credential exists for the request, an auto sign-in activity is displayed.
+ * If more than one credential exists, a picker is displayed.
+ */
+public class RetrieveCredentialActivity
+        extends AppCompatActivity
+        implements CredentialStorageClient.ConnectedCallback {
+
+    private static final String LOG_TAG = "RetrieveCredential";
+    private CredentialStorageClient mClient;
+
+    /**
+     * Creates the intent to handle releasing a credential to the calling app.
+     */
+    public static Intent createIntent(Context context) {
+        return new Intent(context, RetrieveCredentialActivity.class);
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (getCallingPackage() == null) {
+            setResult(RESULT_CANCELED);
+            finish();
+        }
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        CredentialStorageClient.connect(this, this);
+    }
+
+    @Override
+    public void onStorageConnected(CredentialStorageClient client) {
+        mClient = client;
+        if (!client.isUnlocked()) {
+            Intent retrieveAfterUnlockIntent =
+                    RetrieveCredentialActivity.createIntent(this);
+            retrieveAfterUnlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+
+            Intent unlockIntent =
+                    UnlockActivity.createIntent(this, true, retrieveAfterUnlockIntent);
+            unlockIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+            startActivity(unlockIntent);
+            finish();
+        } else {
+            // TODO: we actually need the full set of requested domains from the original request,
+            // not just those based on the package name.
+
+            List<AuthenticationDomain> authDomains =
+                    AuthenticationDomain.listForPackage(this, getCallingPackage());
+
+            List<Credential> credentials;
+            try {
+                credentials = client.listCredentials(authDomains);
+            } catch (IOException ex) {
+                Log.w(LOG_TAG, "Failed to list credentials for retrieve", ex);
+                finish();
+                return;
+            }
+
+            if (credentials.size() == 1) {
+                Intent autoSignInIntent =
+                        AutoSignInActivity.createIntent(this, credentials.get(0));
+                autoSignInIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+                startActivity(autoSignInIntent);
+            } else {
+                Intent pickerIntent =
+                        CredentialPickerActivity.createIntent(this, credentials);
+                pickerIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+                startActivity(pickerIntent);
+            }
+            finish();
+        }
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        mClient.disconnect(this);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
new file mode 100644
index 0000000..088567d
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveAfterUnlockActivity.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import java.io.IOException;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+import org.openyolo.proto.Credential;
+
+
+/**
+ * Writes a credential to the credential store after it is unlocked.
+ */
+public class SaveAfterUnlockActivity extends AppCompatActivity {
+
+    private static final String EXTRA_CREDENTIAL = "credential";
+    private static final String LOG_TAG = "SaveAfterUnlock";
+
+    private Credential mCredential;
+
+    /**
+     * Creates an intent to save the provided credential after the store is unlocked.
+     */
+    public static Intent createIntent(Context context, Credential credentialProto) {
+        Intent intent = new Intent(context, SaveAfterUnlockActivity.class);
+        intent.putExtra(EXTRA_CREDENTIAL, credentialProto.encode());
+        return intent;
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        byte[] credentialBytes = getIntent().getByteArrayExtra(EXTRA_CREDENTIAL);
+        try {
+            mCredential =
+                    org.openyolo.proto.Credential.ADAPTER.decode(credentialBytes);
+        } catch (IOException e) {
+            Log.w(LOG_TAG, "Failed to decode credential to save");
+        }
+
+        CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
+            @Override
+            public void onStorageConnected(CredentialStorageClient client) {
+                final boolean success;
+                try {
+                    client.upsertCredential(mCredential);
+                    runOnUiThread(new SendResultRunnable(RESULT_OK));
+                } catch (IOException e) {
+                    Log.w(LOG_TAG, "Failed to store credential after save", e);
+                    runOnUiThread(new SendResultRunnable(RESULT_CANCELED));
+                }
+
+                client.disconnect(SaveAfterUnlockActivity.this);
+            }
+        });
+    }
+
+    private class SendResultRunnable implements Runnable {
+        private int mResultCode;
+
+        SendResultRunnable(int resultCode) {
+            mResultCode = resultCode;
+        }
+
+        @Override
+        public void run() {
+            setResult(mResultCode);
+            finish();
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
new file mode 100644
index 0000000..25f39d3
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialActivity.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.UiThread;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import java.io.IOException;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.Credential;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+/**
+ * Verifies the rights to save a credential, before proceeding to
+ * {@link SaveCredentialConfirmationActivity}.
+ */
+public class SaveCredentialActivity extends AppCompatActivity {
+
+    private static final String LOG_TAG = "SaveCredential";
+
+    private Credential mCredential;
+    private String mCallingPackage;
+    private List<AuthenticationDomain> mAuthDomainsForApp;
+    private CredentialStorageClient mClient;
+
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (!getIntent().hasExtra(CredentialClient.EXTRA_CREDENTIAL)) {
+            Log.w(LOG_TAG, "No credential included in request");
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        try {
+            mCredential = Credential.fromProtoBytes(
+                    getIntent().getByteArrayExtra(CredentialClient.EXTRA_CREDENTIAL));
+        } catch (IOException ex) {
+            Log.w(LOG_TAG, "Failed to decode credential for save request");
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        if (!verifyCaller()) {
+            Log.w(LOG_TAG, "Rejecting attempt to forge save request for "
+                    + mCredential.getAuthenticationDomain());
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
+            @Override
+            public void onStorageConnected(final CredentialStorageClient client) {
+                mClient = client;
+                runOnUiThread(new AfterStorageConnect());
+            }
+        });
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        if (mClient != null) {
+            mClient.disconnect(this);
+        }
+    }
+
+    @UiThread
+    private void finish(int resultCode) {
+        setResult(resultCode);
+        finish();
+    }
+
+    private boolean verifyCaller() {
+        ComponentName callingActivity = getCallingActivity();
+        if (callingActivity == null) {
+            Log.w(LOG_TAG, "No calling activity found for save call");
+            return false;
+        }
+
+        // TODO: a more complete implementation would need to expand this to the full set of
+        // affiliated apps and sites, though it is generally unusual for an app to save a
+        // credential for any authentication domain other than those it can directly identify as.
+        mCallingPackage = callingActivity.getPackageName();
+        mAuthDomainsForApp = AuthenticationDomain.listForPackage(this, mCallingPackage);
+
+        if (!mAuthDomainsForApp.contains(mCredential.getAuthenticationDomain())) {
+            Log.w(LOG_TAG, "App " + mCallingPackage
+                    + " is not provably associated to authentication domain "
+                    + mCredential.getAuthenticationDomain()
+                    + " for the credential to be saved.");
+            return false;
+        }
+
+
+        return true;
+    }
+
+    private final class AfterStorageConnect implements Runnable {
+        @Override
+        public void run() {
+            try {
+                if (mClient.isOnNeverSaveList(mAuthDomainsForApp)) {
+                    finish(RESULT_CANCELED);
+                } else {
+                    // start confirm activity
+                    Intent confirmIntent = SaveCredentialConfirmationActivity.createIntent(
+                            SaveCredentialActivity.this,
+                            mCallingPackage,
+                            mCredential);
+                    confirmIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+                    startActivity(confirmIntent);
+                    finish();
+                }
+            } catch (IOException ex) {
+                finish(RESULT_CANCELED);
+            }
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
new file mode 100644
index 0000000..6fbae75
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/SaveCredentialConfirmationActivity.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.provider;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import org.openyolo.api.Credential;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.demoprovider.barbican.UnlockActivity;
+import org.openyolo.demoprovider.barbican.storage.CredentialStorageClient;
+
+/**
+ * Confirms with the user whether they want to save a credential provided by the
+ * calling app. Verification of the app's right to save such a credential occurs
+ * in {@link SaveCredentialActivity} before reaching this point.
+ */
+public class SaveCredentialConfirmationActivity extends AppCompatActivity {
+
+    private static final String LOG_TAG = "SaveCredential";
+    private static final String EXTRA_CALLING_PACKAGE = "callingPackage";
+    private static final String EXTRA_CREDENTIAL = "credential";
+    private static final long STORAGE_CONNECT_TIMEOUT_MS = 1000;
+
+    @BindView(R.id.save_prompt)
+    TextView mSavePromptView;
+
+    private Credential mCredential;
+    private String mCallingAppName;
+
+    private AtomicReference<CredentialStorageClient> mClient = new AtomicReference<>();
+    private final CountDownLatch mClientConnected = new CountDownLatch(1);
+
+    /**
+     * Creates an intent to confirm whether the user wishes to save the specified credential.
+     */
+    public static Intent createIntent(
+            Context context,
+            String callingPackage,
+            Credential credential) {
+        Intent intent = new Intent(context, SaveCredentialConfirmationActivity.class);
+        intent.putExtra(EXTRA_CALLING_PACKAGE, callingPackage);
+        intent.putExtra(EXTRA_CREDENTIAL, credential.getProto().encode());
+        return intent;
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        try {
+            mCredential = Credential.fromProtoBytes(
+                    getIntent().getByteArrayExtra(EXTRA_CREDENTIAL));
+        } catch (IOException e) {
+            Log.e(LOG_TAG, "Unable to decode credential", e);
+            finish(RESULT_CANCELED);
+        }
+
+        try {
+            PackageManager pm = getPackageManager();
+            ApplicationInfo info = pm.getApplicationInfo(getCallingPackage(), 0);
+            mCallingAppName = pm.getApplicationLabel(info).toString();
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        CredentialStorageClient.connect(this, new CredentialStorageClient.ConnectedCallback() {
+            @Override
+            public void onStorageConnected(CredentialStorageClient client) {
+                mClient.set(client);
+                mClientConnected.countDown();
+            }
+        });
+
+        setContentView(R.layout.save_layout);
+        ButterKnife.bind(this);
+
+        String savePromptTemplate = getString(R.string.save_prompt_template);
+        mSavePromptView.setText(String.format(savePromptTemplate, mCallingAppName).trim());
+    }
+
+    private void finish(int resultCode) {
+        setResult(resultCode);
+        finish();
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        CredentialStorageClient client = mClient.get();
+        if (client != null) {
+            client.disconnect(this);
+        }
+    }
+
+    @OnClick(R.id.save_button)
+    void onSaveClicked() {
+        CredentialStorageClient client = getStorageClient();
+        if (client == null) {
+            Log.w(LOG_TAG, "Unable to establish storage connection in a timely manner");
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        if (client.isUnlocked()) {
+            try {
+                client.upsertCredential(mCredential.getProto());
+                finish(RESULT_OK);
+            } catch (IOException e) {
+                Log.w(LOG_TAG, "Failed to write credential to storage");
+                finish(RESULT_CANCELED);
+            }
+        } else {
+            Intent saveAfterUnlock = UnlockActivity.createIntent(
+                    this,
+                    true,
+                    SaveAfterUnlockActivity.createIntent(this, mCredential.getProto()));
+            saveAfterUnlock.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+            startActivity(saveAfterUnlock);
+            finish();
+        }
+    }
+
+    @OnClick(R.id.never_save_button)
+    void onNeverSaveClicked() {
+        CredentialStorageClient client = getStorageClient();
+        if (client == null) {
+            finish(RESULT_CANCELED);
+            return;
+        }
+
+        try {
+            client.addToNeverSaveList(mCredential.getAuthenticationDomain());
+        } catch (IOException e) {
+            Log.w(LOG_TAG, "Failed to add app to never save list", e);
+        }
+
+        finish(RESULT_CANCELED);
+    }
+
+    private CredentialStorageClient getStorageClient() {
+        try {
+            mClientConnected.await(STORAGE_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+            return mClient.get();
+        } catch (InterruptedException e) {
+            Log.w(LOG_TAG, "Failed to connect to the storage client in a timely manner", e);
+            return null;
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/package-info.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/package-info.java
new file mode 100644
index 0000000..0646143
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/provider/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Classes pertaining to the implementation of the provider end of the OpenYOLO protocol.
+ */
+package org.openyolo.demoprovider.barbican.provider;
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
new file mode 100644
index 0000000..30b2ccc
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorage.java
@@ -0,0 +1,629 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.storage;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.Log;
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.TreeSet;
+import okio.BufferedSink;
+import okio.BufferedSource;
+import okio.ByteString;
+import okio.Okio;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.CredentialQualityScore;
+import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.demoprovider.barbican.proto.CredentialMeta;
+import org.openyolo.proto.Credential;
+import org.openyolo.proto.CredentialList;
+import org.spongycastle.crypto.digests.Blake2bDigest;
+import org.spongycastle.crypto.generators.BCrypt;
+
+/**
+ * An encrypted file-system based credential store. Uses bcrypt to derive an encryption key from
+ * a password. Creates a directory for each authentication domain (using a hash of the domain)
+ * under which the set of credentials for that domain is stored. This allows determining whether
+ * a credential is available for a given authentication domain without the encryption key, which
+ * is useful for answering OpenYOLO requests.
+ */
+public final class CredentialStorage {
+
+    private static final String LOG_TAG = "CredentialStorage";
+
+    private static final int SALT_SIZE = 16;
+    private static final int BCRYPT_COST = 10;
+
+    private static final int AUTH_DOMAIN_HASH_SIZE = 32;
+
+    private static final char[] HEX_CHARS =
+            { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+
+    private static final byte[] KEY_VERIFICATION_BYTES =
+            { 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0 };
+    private static final int HALF_BYTE_WIDTH = 4;
+    private static final int HALF_BYTE_MASK = 0xF;
+
+    @NonNull
+    private SecureRandom mRandom;
+
+    @NonNull
+    private File mStoreDir;
+
+    private byte[] mSalt;
+
+    @Nullable
+    private byte[] mKey;
+
+    /**
+     * Initializes a credential store in the default location for the application.
+     * @throws IOException if the store could not be initialized.
+     */
+    public CredentialStorage(Context context) throws IOException {
+        this(new SecureRandom(), new File(context.getFilesDir(), "store"));
+    }
+
+    /**
+     * Initializes a credential store in the specified location.
+     * @throws IOException if the store could not be initialized.
+     */
+    public CredentialStorage(
+            @NonNull SecureRandom random,
+            @NonNull File storeDir)
+            throws IOException {
+        mRandom = random;
+        mStoreDir = storeDir;
+
+        if (mStoreDir.exists()) {
+            CredentialMeta credentialMeta = readCredentialMeta();
+            mSalt = credentialMeta.salt.toByteArray();
+        }
+    }
+
+    /**
+     * Determines whether a credential store exists in the initialized location.
+     */
+    public boolean isCreated() {
+        return mStoreDir.exists();
+    }
+
+    /**
+     * Determines whether the credential store is unlocked, meaning that the encryption key has
+     * been derived from the password and is resident in memory.
+     */
+    public boolean isUnlocked() {
+        return mKey != null;
+    }
+
+    /**
+     * Locks the credential store, meaning that the derived encryption key is released from
+     * memory if necessary.
+     */
+    public void lock() {
+        // overwrite the key with random data, then release it for garbage collection
+        mRandom.nextBytes(mKey);
+        mKey = null;
+    }
+
+    /**
+     * Determines whether any of the specified authentication domains are on the never save list.
+     * This operation can be performed without unlocking the credential store.
+     * @throws IOException if the credential storage metadata cannot be read.
+     */
+    @Nullable
+    public List<String> retrieveNeverSaveList() throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+        return meta.neverSave;
+    }
+
+    /**
+     * Clears the "never save" list.
+     * @throws IOException - in the case when the storage fails to be written
+     */
+    public void clearNeverSaveList() throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+        writeCredentialMeta(meta.newBuilder().neverSave(new ArrayList<String>()).build());
+    }
+
+    /**
+     * Determines whether any of the specified authentication domains are on the never save list.
+     * This operation can be performed without unlocking the credential store.
+     * @throws IOException if the credential storage metadata cannot be read.
+     */
+    public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+        if (meta.neverSave == null) {
+            return false;
+        }
+
+        HashSet<String> authDomainsAsStrings = new HashSet<>();
+        for (AuthenticationDomain authDomain : authDomains) {
+            authDomainsAsStrings.add(authDomain.toString());
+        }
+
+        for (String neverSaveDomain : meta.neverSave) {
+            if (authDomainsAsStrings.contains(neverSaveDomain)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Adds the specified authentication domain to the never save list.
+     * @throws IOException if the credential storage metadata cannot be modified.
+     */
+    public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+
+        TreeSet<String> neverSaveDomains = new TreeSet<>();
+        if (meta.neverSave != null) {
+            for (String neverSaveDomain : meta.neverSave) {
+                neverSaveDomains.add(neverSaveDomain);
+            }
+        }
+
+        neverSaveDomains.add(authDomain.toString());
+
+        writeCredentialMeta(
+                meta.newBuilder().neverSave(new ArrayList<>(neverSaveDomains)).build());
+    }
+
+    /**
+     * Removes the specified list of authentication domains from the never save list.
+     * @throws IOException if the credential storage metadata cannot be modified.
+     */
+    public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+
+        TreeSet<String> neverSaveDomains = new TreeSet<>();
+        if (meta.neverSave != null) {
+            for (String neverSaveDomain : meta.neverSave) {
+                neverSaveDomains.add(neverSaveDomain);
+            }
+        }
+
+        for (AuthenticationDomain authDomain : authDomains) {
+            neverSaveDomains.remove(authDomain.toString());
+        }
+
+        writeCredentialMeta(
+                meta.newBuilder().neverSave(new ArrayList<>(neverSaveDomains)).build());
+    }
+
+    /**
+     * Returns all account hints. The list of hints is automatically maintained as part of the
+     * other credential save / delete operations.
+     * @throws IOException if the credential storage metadata cannot be modified.
+     */
+    public List<AccountHint> getHints() throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+        return meta.hints;
+    }
+
+    /**
+     * Determines whether any credentials are stored for the given authentication domain. This
+     * does not require the credential store to be unlocked.
+     */
+    public boolean hasCredentialFor(@NonNull String authDomain) {
+        return getAuthDomainDir(authDomain).exists();
+    }
+
+    /**
+     * Returns a list of all stored credentials. Requires that the credential store is unlocked.
+     * @throws IOException if the credentials could not be read.
+     */
+    @NonNull
+    public List<Credential> listAllCredentials() throws IOException {
+        ArrayList<Credential> allCredentials = new ArrayList<>();
+        checkUnlocked();
+        for (File authDomainDir : mStoreDir.listFiles()) {
+            if (!authDomainDir.isDirectory()) {
+                continue;
+            }
+
+            List<Credential> credentials = readCredentials(authDomainDir);
+            allCredentials.addAll(credentials);
+        }
+
+        return allCredentials;
+    }
+
+    /**
+     * Returns a list of credentials for the specified authentication domain. Requires
+     * that the credential store is unlocked. May be empty.
+     * @throws IOException if the credentials could not be read.
+     */
+    @NonNull
+    public List<Credential> listCredentials(String authDomain) throws IOException {
+        checkUnlocked();
+        return readCredentials(authDomain);
+    }
+
+    /**
+     * Writes (or overwrites) the provided credential to the store. Requires that the credential
+     * store is unlocked. May be empty.
+     * @throws IOException if the credential could not be written.
+     */
+    public void upsertCredential(Credential credential) throws IOException {
+        checkUnlocked();
+        List<Credential> credentials = new ArrayList<>(readCredentials(credential.authDomain));
+
+        // replace any existing equivalent
+        ListIterator<Credential> it = credentials.listIterator();
+        boolean existingFound = false;
+        while (it.hasNext() && !existingFound) {
+            Credential existing = it.next();
+            if (credential.id.equals(existing.id)
+                    && eq(credential.authDomain, existing.authDomain)) {
+                existingFound = true;
+                it.set(credential);
+            }
+        }
+
+        if (!existingFound) {
+            it.add(credential);
+        }
+
+        writeCredentials(credential.authDomain, credentials);
+        upsertHint(credential);
+    }
+
+    /**
+     * Removes the specified credential (or one with the same authentication domain, identifier
+     * and "type") from the store. Requires that the store is unlocked.
+     * @throws IOException if the credential could not be deleted.
+     */
+    public void deleteCredential(Credential credential) throws IOException {
+        checkUnlocked();
+        List<Credential> credentials = new ArrayList<>(readCredentials(credential.authDomain));
+
+        ListIterator<Credential> it = credentials.listIterator();
+        boolean existingFound = false;
+        while (it.hasNext() && !existingFound) {
+            Credential existing = it.next();
+            if (credentialsAreEquivalent(credential, existing)) {
+                existingFound = true;
+                it.remove();
+            }
+        }
+
+        if (existingFound) {
+            writeCredentials(credential.authDomain, credentials);
+        }
+    }
+
+    private boolean credentialsAreEquivalent(Credential c1, Credential c2) {
+        if (c1 == null) {
+            return c2 == null;
+        }
+
+        if (c2 == null) {
+            return false;
+        }
+
+        return c1.id.equals(c2.id)
+                && c1.authDomain.equals(c2.authDomain)
+                && c1.authMethod.equals(c2.authMethod);
+    }
+
+    private boolean areEqual(Object o1, Object o2) {
+        return o1 == null ? o2 == null : o1.equals(o2);
+    }
+
+    /* **************************** store initialization ******************************************/
+
+    /**
+     * Creates a credential store at the initialized location, deriving an encryption key from
+     * the specified password.
+     * @throws IOException if the store could not be created.
+     */
+    public void create(String password) throws IOException {
+        if (!mStoreDir.mkdirs()) {
+            throw new IllegalStateException("unable to create credential store directory");
+        }
+
+        CredentialMeta meta = generateCredentialMeta();
+        writeCredentialMeta(meta);
+
+        mSalt = meta.salt.toByteArray();
+        mKey = keyFromPassword(password, meta.cost);
+        generateKeyTestFile();
+    }
+
+    /**
+     * Unlocks the credential store, deriving an encryption key from the specified password and
+     * validates it.
+     * @throws IOException if the store could not be unlocked.
+     */
+    public boolean unlock(String password) throws IOException {
+        if (!isCreated()) {
+            throw new IllegalStateException("Store has not been created");
+        }
+
+        CredentialMeta credentialMeta = readCredentialMeta();
+        mSalt = credentialMeta.salt.toByteArray();
+        mKey = keyFromPassword(password, credentialMeta.cost);
+        return verifyKey();
+    }
+
+    /* **************************** credential meta handling **************************************/
+
+    private File getCredentialMetaFile() {
+        return new File(mStoreDir, "meta");
+    }
+
+    private CredentialMeta generateCredentialMeta() {
+        return new CredentialMeta.Builder()
+                .salt(ByteString.of(generateRandomBytes(SALT_SIZE)))
+                .cost(BCRYPT_COST)
+                .build();
+    }
+
+    private void writeCredentialMeta(CredentialMeta meta) throws IOException {
+        BufferedSink sink = null;
+        try {
+            sink = Okio.buffer(Okio.sink(getCredentialMetaFile()));
+            meta.encode(sink);
+        } finally {
+            IoUtil.closeQuietly(sink, LOG_TAG);
+        }
+    }
+
+    private CredentialMeta readCredentialMeta() throws IOException {
+        BufferedSource src = null;
+        try {
+            src = Okio.buffer(Okio.source(getCredentialMetaFile()));
+            return CredentialMeta.ADAPTER.decode(src);
+        } finally {
+            IoUtil.closeQuietly(src, LOG_TAG);
+        }
+    }
+
+    private void upsertHint(Credential credential) throws IOException {
+        CredentialMeta meta = readCredentialMeta();
+        List<AccountHint> hints = new ArrayList<>(readCredentialMeta().hints);
+
+        ListIterator<AccountHint> hintIter = hints.listIterator();
+        boolean found = false;
+        while (!found && hintIter.hasNext()) {
+            AccountHint existingHint = hintIter.next();
+
+            if (existingHint.identifier.equals(credential.id)
+                    && existingHint.authMethod.equals(credential.authMethod)
+                    && CredentialQualityScore.getScore(existingHint)
+                            <= CredentialQualityScore.getScore(credential)) {
+                hintIter.remove();
+                hintIter.add(convertCredentialToHint(credential));
+                found = true;
+            }
+        }
+
+        if (!found) {
+            hintIter.add(convertCredentialToHint(credential));
+        }
+
+        writeCredentialMeta(meta.newBuilder().hints(hints).build());
+    }
+
+    private AccountHint convertCredentialToHint(Credential credential) {
+        return new AccountHint.Builder()
+                .identifier(credential.id)
+                .authMethod(credential.authMethod)
+                .name(credential.displayName)
+                .pictureUri(credential.displayPictureUri)
+                .build();
+    }
+
+    /* **************************** key validation ************************************************/
+
+    private File getKeyTestFile() {
+        return new File(mStoreDir, "test");
+    }
+
+    private void generateKeyTestFile() throws IOException {
+        BufferedSink sink = null;
+        try {
+            sink = IoUtil.encryptTo(getKeyTestFile(), mKey);
+            sink.write(KEY_VERIFICATION_BYTES);
+            sink.close();
+        } finally {
+            IoUtil.closeQuietly(sink, LOG_TAG);
+        }
+    }
+
+    private boolean verifyKey() throws IOException {
+        BufferedSource source = null;
+        try {
+            source = IoUtil.decryptFrom(getKeyTestFile(), mKey);
+            byte[] bytes = source.readByteArray();
+            return bytesEqual(KEY_VERIFICATION_BYTES, bytes);
+        } catch (IOException ex) {
+            Log.i(LOG_TAG, "Key verification failed");
+            return false;
+        } finally {
+            IoUtil.closeQuietly(source, LOG_TAG);
+        }
+    }
+
+    /* ************************** auth domain directory management ********************************/
+
+    private File getAuthDomainDir(String authDomain) {
+        return new File(mStoreDir, toBlakeHash(authDomain));
+    }
+
+    private File initAuthDomainDir(String authDomain) throws IOException {
+        File authorityDir = getAuthDomainDir(authDomain);
+        if (!authorityDir.exists()) {
+            if (!authorityDir.mkdirs()) {
+                throw new IOException("failed to create authority dir");
+            }
+        }
+
+        return authorityDir;
+    }
+
+    private void deleteAuthDomainDir(String authDomain) throws IOException {
+        File credsFile = getCredentialsFile(authDomain);
+        if (credsFile.exists()) {
+            if (!credsFile.delete()) {
+                throw new IOException("failed to delete credentials file");
+            }
+        }
+
+        File authorityDir = getAuthDomainDir(authDomain);
+        if (authorityDir.exists()) {
+            if (!authorityDir.delete()) {
+                throw new IOException("failed to delete authority directory");
+            }
+        }
+    }
+
+    private File getCredentialsFile(String authDomain) {
+        return getCredentialsFile(getAuthDomainDir(authDomain));
+    }
+
+    private File getCredentialsFile(File authDomainDir) {
+        return new File(authDomainDir, "creds");
+    }
+
+    /* **************************** credential manipulation ***************************************/
+
+    private void writeCredentials(String authDomain, List<Credential> credentials)
+            throws IOException {
+        if (credentials.size() == 0) {
+            deleteAuthDomainDir(authDomain);
+            return;
+        }
+
+        initAuthDomainDir(authDomain);
+        BufferedSink credentialsSink = null;
+        try {
+            credentialsSink = IoUtil.encryptTo(
+                    getCredentialsFile(authDomain),
+                    mKey);
+
+            CredentialList proto = new CredentialList.Builder().credentials(credentials).build();
+            proto.encode(credentialsSink);
+        } finally {
+            IoUtil.closeQuietly(credentialsSink, LOG_TAG);
+        }
+    }
+
+    private List<Credential> readCredentials(String authDomain) throws IOException {
+        return readCredentials(getAuthDomainDir(authDomain));
+    }
+
+    private List<Credential> readCredentials(File authDomain) throws IOException {
+        File credentialsFile = getCredentialsFile(authDomain);
+        if (!credentialsFile.exists()) {
+            return Collections.emptyList();
+        }
+
+        BufferedSource credentialsSource = null;
+        try {
+            credentialsSource = IoUtil.decryptFrom(credentialsFile, mKey);
+            CredentialList proto = CredentialList.ADAPTER.decode(credentialsSource);
+            return proto.credentials;
+        } finally {
+            IoUtil.closeQuietly(credentialsSource, LOG_TAG);
+        }
+    }
+
+    /* *********************************** utils **************************************************/
+
+    private void checkUnlocked() {
+        if (!isUnlocked()) {
+            throw new IllegalStateException("credential store is locked");
+        }
+    }
+
+    private byte[] keyFromPassword(String password, int cost) {
+        return BCrypt.generate(toUtf8Bytes(password), mSalt, cost);
+    }
+
+    private static byte[] toUtf8Bytes(String str) {
+        try {
+            return str.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new IllegalStateException("UTF-8 character set not supported, against spec");
+        }
+    }
+
+    private byte[] generateRandomBytes(int length) {
+        byte[] bytes = new byte[length];
+        mRandom.nextBytes(bytes);
+        return bytes;
+    }
+
+    private boolean bytesEqual(byte[] b1, byte[] b2) {
+        if (b1 == null) {
+            return b2 == null;
+        }
+
+        if (b2 == null || b1.length != b2.length) {
+            return false;
+        }
+
+        for (int i = 0; i < b1.length; i++) {
+            if (b1[i] != b2[i]) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    private String toBlakeHash(String message) {
+        Blake2bDigest digest = new Blake2bDigest(
+                null, /* no key */
+                AUTH_DOMAIN_HASH_SIZE,
+                mSalt,
+                null); /* no personalization of the hashing function */
+        byte[] messageBytes = toUtf8Bytes(message);
+        digest.update(messageBytes, 0, messageBytes.length);
+        byte[] result = new byte[AUTH_DOMAIN_HASH_SIZE];
+        digest.doFinal(result, 0);
+        return toHexString(result);
+    }
+
+    private String toHexString(byte[] bytes) {
+        char[] result = new char[bytes.length * 2];
+        for (int i = 0, j = 0; i < bytes.length; i++, j += 2) {
+            byte nextByte = bytes[i];
+
+            result[j] = HEX_CHARS[(nextByte >>> HALF_BYTE_WIDTH) & HALF_BYTE_MASK];
+            result[j + 1] = HEX_CHARS[nextByte & HALF_BYTE_MASK];
+        }
+        return new String(result);
+    }
+
+    private boolean eq(Object o1, Object o2) {
+        if (o1 == null) {
+            return o2 == null;
+        }
+        return o2 != null && o1.equals(o2);
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
new file mode 100644
index 0000000..fa7b51f
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageApi.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.storage;
+
+import java.io.IOException;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.proto.Credential;
+
+
+/**
+ * Credential storage operations which are available via the service interface.
+ */
+public interface CredentialStorageApi {
+
+    /**
+     * Determines whether a credential store exists in the initialized location.
+     */
+    boolean isCreated();
+
+    /**
+     * Creates a credential store at the initialized location, deriving an encryption key from
+     * the specified password.
+     * @throws IOException if the store could not be created.
+     */
+    void create(String password) throws IOException;
+
+    /**
+     * Determines whether the credential store is unlocked, meaning that the encryption key has
+     * been derived from the password and is resident in memory.
+     */
+    boolean isUnlocked();
+
+    /**
+     * Unlocks the credential store, deriving an encryption key from the specified password and
+     * validates it.
+     * @throws IOException if the store could not be unlocked.
+     */
+    boolean unlock(String password) throws IOException;
+
+    /**
+     * Locks the credential store, meaning that the derived encryption key is released from
+     * memory if necessary.
+     */
+    void lock();
+
+    /**
+     * Determines whether any of the provided authentication domains are on the "never save"
+     * list.
+     * @throws IOException if the credential store metadata could not be read.
+     */
+    boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException;
+
+    /**
+     * Adds the specified authentication domain to the "never save" list.
+     * @throws IOException if the credential store metadata could not be modified.
+     */
+    void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException;
+
+    /**
+     * Removes the specified authentication domains from the "never save" list.
+     * @throws IOException if the credential store metadata could not be modified.
+     */
+    void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException;
+
+    /**
+     * Returns the list of all account hints.
+     * @throws IOException if the credential store metadata could not be modified.
+     */
+    List<AccountHint> getHints() throws IOException;
+
+    /**
+     * Returns a {@link List} of {@link AuthenticationDomain}s which are in the "never save" list.
+     * @return a list of "never save" domains
+     * @throws IOException - if the credential store metadata could not be read.
+     */
+    List<String> getNeverSaveList() throws IOException;
+
+    /**
+     * Clears the "never save" list.
+     * @throws IOException - if the credential store metadata could not be read.
+     */
+    void clearNeverSaveList() throws IOException;
+
+    /**
+     * Determines whether any credentials are stored for the given authentication domain. This
+     * does not require the credential store to be unlocked.
+     * @throws IOException if the credential store could not be read.
+     */
+    boolean hasCredentialFor(String authDomain) throws IOException;
+
+    /**
+     * Returns a list of credentials for the specified authentication domain. Requires
+     * that the credential store is unlocked. May be empty.
+     * @throws IOException if the credentials could not be read.
+     */
+    List<Credential> listCredentials(List<AuthenticationDomain> authDomains) throws IOException;
+
+    /**
+     * Returns a list of all stored credentials. Requires that the credential store is unlocked.
+     * @throws IOException if the credentials could not be read.
+     */
+    List<Credential> listAllCredentials() throws IOException;
+
+    /**
+     * Writes (or overwrites) the provided credential to the store. Requires that the credential
+     * store is unlocked. May be empty.
+     * @throws IOException if the credential could not be written.
+     */
+    void upsertCredential(Credential credential) throws IOException;
+
+    /**
+     * Removes the specified credential (or one with the same authentication domain, identifier
+     * and "type") from the store. Requires that the store is unlocked.
+     * @throws IOException if the credential could not be deleted.
+     */
+    void deleteCredential(Credential credential) throws IOException;
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
new file mode 100644
index 0000000..85cc506
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageClient.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.storage;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.util.Log;
+import java.io.IOException;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.proto.Credential;
+
+/**
+ * A client to the {@link CredentialStorageService}, allowing activities to access the
+ * retained instance of the credential store.
+ */
+public class CredentialStorageClient implements CredentialStorageApi {
+
+    private static final String LOG_TAG = "StorageClient";
+
+    private final CredentialStorageApi mApi;
+    private final ServiceConnection mConnection;
+
+    /**
+     * Connects to the credential storage service, invoking the provided callback when connected.
+     */
+    public static void connect(Context context, ConnectedCallback callback) {
+        CredentialStorageConnection connector = new CredentialStorageConnection(callback);
+        Log.d(LOG_TAG, connector.mConnectionId + ": before startService");
+        context.startService(new Intent(context, CredentialStorageService.class));
+        Log.d(LOG_TAG, connector.mConnectionId + ": before bindService");
+        context.bindService(
+                new Intent(context, CredentialStorageService.class),
+                connector,
+                Context.BIND_AUTO_CREATE);
+        Log.d(LOG_TAG, connector.mConnectionId + ": after bindService");
+    }
+
+    CredentialStorageClient(CredentialStorageApi api, ServiceConnection connection) {
+        mApi = api;
+        mConnection = connection;
+    }
+
+    /**
+     * Disconnects the service connection to the storage service.
+     */
+    public void disconnect(Context context) {
+        context.unbindService(mConnection);
+    }
+
+    @Override
+    public boolean isCreated() {
+        return mApi.isCreated();
+    }
+
+    @Override
+    public void create(String password) throws IOException {
+        mApi.create(password);
+    }
+
+    @Override
+    public boolean isUnlocked() {
+        return mApi.isUnlocked();
+    }
+
+    @Override
+    public boolean unlock(String password) throws IOException {
+        return mApi.unlock(password);
+    }
+
+    @Override
+    public void lock() {
+        mApi.lock();
+    }
+
+    @Override
+    public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
+        return mApi.isOnNeverSaveList(authDomains);
+    }
+
+    @Override
+    public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
+        mApi.addToNeverSaveList(authDomain);
+    }
+
+    @Override
+    public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
+        mApi.removeFromNeverSaveList(authDomains);
+    }
+
+    @Override
+    public List<String> getNeverSaveList() throws IOException {
+        return mApi.getNeverSaveList();
+    }
+
+    @Override
+    public void clearNeverSaveList() throws IOException {
+        mApi.clearNeverSaveList();
+    }
+
+    @Override
+    public List<AccountHint> getHints() throws IOException {
+        return mApi.getHints();
+    }
+
+    @Override
+    public boolean hasCredentialFor(String authDomain) throws IOException {
+        return mApi.hasCredentialFor(authDomain);
+    }
+
+    @Override
+    public List<Credential> listAllCredentials() throws IOException {
+        return mApi.listAllCredentials();
+    }
+
+    @Override
+    public void upsertCredential(Credential credential) throws IOException {
+        mApi.upsertCredential(credential);
+    }
+
+    @Override
+    public void deleteCredential(Credential credential) throws IOException {
+        mApi.deleteCredential(credential);
+    }
+
+    @Override
+    public List<Credential> listCredentials(List<AuthenticationDomain> authDomains)
+            throws IOException {
+        return mApi.listCredentials(authDomains);
+    }
+
+    /**
+     * Callback interface for notifing callers when the client is connected.
+     */
+    public interface ConnectedCallback {
+        /**
+         * Invoked when the provided client is connected.
+         */
+        void onStorageConnected(CredentialStorageClient client);
+    }
+
+    private static final class CredentialStorageConnection implements ServiceConnection {
+
+        private String mConnectionId;
+        private ConnectedCallback mCallback;
+        private long mStartTime;
+
+        CredentialStorageConnection(ConnectedCallback callback) {
+            mConnectionId = UUID.randomUUID().toString();
+            mCallback = callback;
+            mStartTime = System.nanoTime();
+        }
+
+        @Override
+        public void onServiceConnected(ComponentName name, IBinder binder) {
+            Log.d(LOG_TAG, mConnectionId + ": enter onServiceConnected");
+            if (mCallback != null) {
+                CredentialStorageClient client = new CredentialStorageClient(
+                        ((CredentialStorageService.LocalBinder)binder).getApi(),
+                        this);
+                mCallback.onStorageConnected(client);
+                mCallback = null;
+            }
+
+            long timeTaken = TimeUnit.MILLISECONDS.convert(
+                    System.nanoTime() - mStartTime,
+                    TimeUnit.NANOSECONDS);
+            Log.d(LOG_TAG, mConnectionId + ": Took " + timeTaken + "ms to connect");
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName name) {
+            Log.d(LOG_TAG, mConnectionId + ": Disconnected from service");
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
new file mode 100644
index 0000000..0c7c9f1
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/CredentialStorageService.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.storage;
+
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+import android.support.annotation.Nullable;
+import android.support.v4.app.NotificationCompat;
+import android.util.Log;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.demoprovider.barbican.CredentialListActivity;
+import org.openyolo.demoprovider.barbican.LockActivity;
+import org.openyolo.demoprovider.barbican.R;
+import org.openyolo.demoprovider.barbican.proto.AccountHint;
+import org.openyolo.proto.Credential;
+
+/**
+ * A service which retains an instance of {@link CredentialStorage} beyond the lifecycle of the
+ * activities that interact with it. This reduces the frequency at which the user would have
+ * to enter their password to unlock the keystore.
+ */
+public class CredentialStorageService extends Service implements CredentialStorageApi {
+
+    private static final String LOG_TAG = "CredentialStorage";
+
+    private static final int UNLOCKED_NOTIFICATION_ID = 1;
+
+    private final IBinder mLocalBinder = new LocalBinder();
+    private CredentialStorage mStorage;
+
+    @Nullable
+    @Override
+    public IBinder onBind(Intent intent) {
+        Log.d(LOG_TAG, "enter onBind");
+        return mLocalBinder;
+    }
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        Log.d(LOG_TAG, "enter onCreate");
+        try {
+            mStorage = new CredentialStorage(this);
+        } catch (IOException ex) {
+            Log.wtf(LOG_TAG, "Failed to open credential storage", ex);
+            return;
+        }
+        Log.d(LOG_TAG, "after create storage");
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+    }
+
+    @Override
+    public boolean isCreated() {
+        return mStorage.isCreated();
+    }
+
+    @Override
+    public void create(final String password) throws IOException {
+        mStorage.create(password);
+        becomeForeground();
+    }
+
+    @Override
+    public boolean isUnlocked() {
+        return mStorage.isUnlocked();
+    }
+
+    @Override
+    public boolean unlock(String password) throws IOException {
+        if (mStorage.unlock(password)) {
+            // when unlocked, we become foreground in order to retain the unlock key for longer,
+            // and also to notify the user of the associated security risk.
+            becomeForeground();
+            return true;
+        }
+
+        return false;
+    }
+
+    @Override
+    public void lock() {
+        if (!mStorage.isUnlocked()) {
+            return;
+        }
+
+        mStorage.lock();
+        stopForeground(true);
+    }
+
+    @Override
+    public boolean isOnNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
+        return mStorage.isOnNeverSaveList(authDomains);
+    }
+
+    @Override
+    public void addToNeverSaveList(AuthenticationDomain authDomain) throws IOException {
+        mStorage.addToNeverSaveList(authDomain);
+    }
+
+    @Override
+    public void removeFromNeverSaveList(List<AuthenticationDomain> authDomains) throws IOException {
+        mStorage.removeFromNeverSaveList(authDomains);
+    }
+
+    @Override
+    public List<String> getNeverSaveList() throws IOException {
+        return mStorage.retrieveNeverSaveList();
+    }
+
+    @Override
+    public void clearNeverSaveList() throws IOException {
+        mStorage.clearNeverSaveList();
+    }
+
+    @Override
+    public List<AccountHint> getHints() throws IOException {
+        return mStorage.getHints();
+    }
+
+    @Override
+    public boolean hasCredentialFor(String authDomain) throws IOException {
+        return mStorage.hasCredentialFor(authDomain);
+    }
+
+    @Override
+    public List<Credential> listCredentials(List<AuthenticationDomain> authDomains)
+            throws IOException {
+        checkUnlocked();
+        ArrayList<Credential> matchingCredentials = new ArrayList<>();
+        for (AuthenticationDomain domain : authDomains) {
+            matchingCredentials.addAll(mStorage.listCredentials(domain.toString()));
+        }
+
+        return matchingCredentials;
+    }
+
+    @Override
+    public List<Credential> listAllCredentials() throws IOException {
+        checkUnlocked();
+        return mStorage.listAllCredentials();
+    }
+
+    @Override
+    public void upsertCredential(Credential credential) throws IOException {
+        checkUnlocked();
+        mStorage.upsertCredential(credential);
+    }
+
+    @Override
+    public void deleteCredential(Credential credential) throws IOException {
+        checkUnlocked();
+        mStorage.deleteCredential(credential);
+    }
+
+    private void becomeForeground() {
+        Notification notification = new NotificationCompat.Builder(this)
+                .setSmallIcon(R.drawable.unlocked_notification_icon)
+                .setContentTitle(getString(R.string.unlocked_notification_title))
+                .setContentText(getString(R.string.unlocked_notification_text))
+                .setCategory(NotificationCompat.CATEGORY_SERVICE)
+                .setContentIntent(PendingIntent.getActivity(
+                        this, 0, new Intent(this, CredentialListActivity.class), 0))
+                .addAction(
+                        R.drawable.lock_notification_icon,
+                        getString(R.string.unlocked_notification_lock_action),
+                        PendingIntent.getActivity(
+                                this, 0, new Intent(this, LockActivity.class), 0
+                ))
+                .setLocalOnly(true)
+                .setAutoCancel(false)
+                .setOngoing(true)
+                .setOnlyAlertOnce(true)
+                .build();
+        startForeground(UNLOCKED_NOTIFICATION_ID, notification);
+    }
+
+    private void checkUnlocked() {
+        if (!mStorage.isUnlocked()) {
+            throw new IllegalStateException("Storage is locked");
+        }
+    }
+
+    class LocalBinder extends Binder {
+        CredentialStorageApi getApi() {
+            return CredentialStorageService.this;
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java
new file mode 100644
index 0000000..c112263
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/IoUtil.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.storage;
+
+import static okio.Okio.buffer;
+import static okio.Okio.sink;
+import static okio.Okio.source;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.Log;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import okio.BlockCipherSink;
+import okio.BlockCipherSource;
+import okio.BufferedSink;
+import okio.BufferedSource;
+import okio.Sink;
+import okio.Source;
+import org.spongycastle.crypto.engines.TwofishEngine;
+import org.spongycastle.crypto.paddings.PKCS7Padding;
+import org.spongycastle.crypto.params.KeyParameter;
+
+/**
+ * Utilities for reading and writing encrypted data to disk.
+ */
+class IoUtil {
+
+    static final int KEY_SIZE = 16;
+
+    static final int BLOCK_SIZE = 16;
+
+    static Sink encryptTo(Sink sink, byte[] key) {
+        TwofishEngine engine = new TwofishEngine();
+        engine.init(true, new KeyParameter(key));
+        return new BlockCipherSink(engine, new PKCS7Padding(), sink);
+    }
+
+    static BufferedSink encryptTo(File file, byte[] key) throws FileNotFoundException {
+        return buffer(encryptTo(buffer(sink(file)), key));
+    }
+
+    static Source decryptFrom(Source source, byte[] key) {
+        TwofishEngine engine = new TwofishEngine();
+        engine.init(false, new KeyParameter(key));
+        return new BlockCipherSource(engine, new PKCS7Padding(), source);
+    }
+
+    static BufferedSource decryptFrom(File file, byte[] key) throws FileNotFoundException {
+        return buffer(decryptFrom(buffer(source(file)), key));
+    }
+
+    static void closeQuietly(@Nullable Closeable resource, @NonNull String logTag) {
+        if (resource != null) {
+            try {
+                resource.close();
+            } catch (IOException ex) {
+                Log.w(logTag, "Failed to close IO stream", ex);
+            }
+        }
+    }
+}
diff --git a/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/package-info.java b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/package-info.java
new file mode 100644
index 0000000..1a214bc
--- /dev/null
+++ b/demoproviders/barbican/java/org/openyolo/demoprovider/barbican/storage/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Classes pertaining to the encrypted storage of credentials.
+ */
+package org.openyolo.demoprovider.barbican.storage;
diff --git a/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java b/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
new file mode 100644
index 0000000..97dae1a
--- /dev/null
+++ b/demoproviders/barbican/javatests/org/openyolo/demoprovider/barbican/storage/IoUtilTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.barbican.storage;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import okio.BufferedSink;
+import okio.BufferedSource;
+import okio.Okio;
+import okio.Sink;
+import okio.Source;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class IoUtilTest {
+
+    @Test
+    public void testCrypto_emptyMessage() throws Exception {
+        byte[] testData = new byte[0];
+        assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
+    }
+
+    @Test
+    public void testCrypto_subBlock() throws Exception {
+        byte[] testData = generateArray(IoUtil.BLOCK_SIZE - 2);
+        assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
+    }
+
+    @Test
+    public void testCrypto_singleBlock() throws Exception {
+        byte[] testData = generateArray(IoUtil.BLOCK_SIZE);
+        assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
+    }
+
+    @Test
+    public void testCrypto_multiBlock() throws Exception {
+        byte[] testData = generateArray(4 * IoUtil.BLOCK_SIZE);
+        assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
+    }
+
+    @Test
+    public void testCrypto_multiBlockWithSubBlock() throws Exception {
+        byte[] testData = generateArray(4 * IoUtil.BLOCK_SIZE + 3);
+        assertThat(testData).isEqualTo(writeAndRead(testData, generateTestKey()));
+    }
+
+    @Test
+    public void testCryptoLongStream() throws Exception {
+        byte[] longData = generateArray(1024 * 1024);
+        assertThat(longData).isEqualTo(writeAndRead(longData, generateTestKey()));
+    }
+
+    private byte[] writeAndRead(byte[] data, byte[] key) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        Sink outSink = Okio.sink(baos);
+        BufferedSink cryptoSink = Okio.buffer(IoUtil.encryptTo(outSink, key));
+        cryptoSink.write(data);
+        cryptoSink.close();
+
+        byte[] cipherText = baos.toByteArray();
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(cipherText);
+        Source inSource = Okio.source(bais);
+        BufferedSource cryptoSource = Okio.buffer(IoUtil.decryptFrom(inSource, generateTestKey()));
+
+        byte[] result = cryptoSource.readByteArray();
+        cryptoSource.close();
+        return result;
+    }
+
+    private byte[] generateArray(int length) {
+        byte[] bytes = new byte[length];
+        for (int i = 0; i < bytes.length; i++) {
+            bytes[i] = (byte) i;
+        }
+
+        return bytes;
+    }
+
+    private byte[] generateTestKey() {
+        return generateArray(IoUtil.KEY_SIZE);
+    }
+}
diff --git a/demoproviders/barbican/proto/credential-meta.proto b/demoproviders/barbican/proto/credential-meta.proto
new file mode 100644
index 0000000..2585032
--- /dev/null
+++ b/demoproviders/barbican/proto/credential-meta.proto
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package org.openyolo.demoprovider.barbican;
+
+option java_package = "org.openyolo.demoprovider.barbican.proto";
+
+message CredentialMeta {
+  required int32 cost = 1;
+  required bytes salt = 2;
+  repeated string neverSave = 3;
+  repeated AccountHint hints = 4;
+}
+
+message AccountHint {
+  optional string identifier = 1; // required
+  optional string authMethod = 2;
+  optional string name = 3;
+  optional string pictureUri = 4;
+}
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable-v23/lock_notification_icon.xml b/demoproviders/barbican/res/drawable-v23/lock_notification_icon.xml
new file mode 100644
index 0000000..235f98a
--- /dev/null
+++ b/demoproviders/barbican/res/drawable-v23/lock_notification_icon.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/lock" />
+</selector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable-v23/splash.xml b/demoproviders/barbican/res/drawable-v23/splash.xml
new file mode 100644
index 0000000..0398d36
--- /dev/null
+++ b/demoproviders/barbican/res/drawable-v23/splash.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:drawable="@color/colorPrimary"
+        android:gravity="fill"/>
+
+    <item android:drawable="@drawable/app_icon"
+          android:gravity="center"
+          android:width="192dp"
+          android:height="192dp">
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable-v23/unlocked_notification_icon.xml b/demoproviders/barbican/res/drawable-v23/unlocked_notification_icon.xml
new file mode 100644
index 0000000..2b9538f
--- /dev/null
+++ b/demoproviders/barbican/res/drawable-v23/unlocked_notification_icon.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/unlock" />
+</selector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/app_icon.xml b/demoproviders/barbican/res/drawable/app_icon.xml
new file mode 100644
index 0000000..7f24ff9
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/app_icon.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="48dp"
+        android:height="48dp"
+        android:viewportWidth="48"
+        android:viewportHeight="48">
+
+    <path
+        android:fillColor="#455a64"
+        android:pathData="M45 24a21 21 0 0 1-21 21A21 21 0 0 1 3 24 21 21 0 0 1 24 3a21 21 0 0 1 21 21z" />
+    <path
+        android:fillColor="#4db6ac"
+        android:pathData="M5 31h38v2H5z" />
+    <path
+        android:fillColor="#e0e0e0"
+        android:pathData="M15 14h2v2h-2zM19 14h2v2h-2zM23 14h2v2h-2zM27 14h2v2h-2zM31 14h2v2h-2z" />
+    <path
+        android:fillColor="#4db6ac"
+        android:pathData="M11 40h25l-4 4H17z" />
+    <path
+        android:fillColor="#4fc3f7"
+        android:pathData="M6 33h4v6l-3-2zM38 33h4l-1 4-3 2z" />
+    <path
+        android:fillColor="#039be5"
+        android:pathData="M10 36h28l1 4H9z" />
+    <path
+        android:fillColor="#9e9e9e"
+        android:pathData="M9 12v1h1v23h4V13h1v-1H9z" />
+    <path
+        android:fillColor="#e0e0e0"
+        android:pathData="M14 16h20v20H14z" />
+    <path
+        android:strokeColor="#e0e0e0"
+        android:strokeWidth="2.142"
+        android:pathData="M44.929 24A20.929 20.929 0 0 1 24 44.929 20.929 20.929 0 0 1 3.071 24 20.929
+20.929 0 0 1 24 3.071 20.929 20.929 0 0 1 44.929 24z" />
+    <path
+        android:fillColor="#795548"
+        android:pathData="M21 28h6v8h-6z" />
+    <path
+        android:fillColor="#9e9e9e"
+        android:pathData="M33 12v1h1v23h4V13h1v-1h-6z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/back.xml b/demoproviders/barbican/res/drawable/back.xml
new file mode 100644
index 0000000..587e72c
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/back.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/create.xml b/demoproviders/barbican/res/drawable/create.xml
new file mode 100644
index 0000000..81dab71
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/create.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39 .39 -1.02
+0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" />
+</vector>
diff --git a/demoproviders/barbican/res/drawable/done.xml b/demoproviders/barbican/res/drawable/done.xml
new file mode 100644
index 0000000..3bca675
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/done.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/done_disabled.xml b/demoproviders/barbican/res/drawable/done_disabled.xml
new file mode 100644
index 0000000..4eb2239
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/done_disabled.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+
+    <path
+        android:fillColor="#87FFFFFF"
+        android:pathData="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/done_states.xml b/demoproviders/barbican/res/drawable/done_states.xml
new file mode 100644
index 0000000..ca8fe21
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/done_states.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_enabled="false" android:drawable="@drawable/done_disabled" />
+    <item android:drawable="@drawable/done" />
+</selector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/email.xml b/demoproviders/barbican/res/drawable/email.xml
new file mode 100644
index 0000000..7561ca0
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/email.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#4fc3f7"
+        android:pathData="M 12 1 C 18.0751322481 1 23 5.92486775186 23 12 C 23 18.0751322481 18.0751322481 23 12 23 C 5.92486775186 23 1 18.0751322481 1 12 C 1 5.92486775186 5.92486775186 1 12 1 Z" />
+
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M 18,6 H 6 C 5.175,6 4.5075,6.675 4.5075,7.5 L 4.5,16.5 C 4.5,17.325 5.175,18 6,18 h 12 c 0.825,0 1.5,-0.675 1.5,-1.5 v -9 C 19.5,6.675 18.825,6 18,6 z M 18,9 12,12.75 6,9 V 7.5 l 6,3.75 6,-3.75 V 9 z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/lock.xml b/demoproviders/barbican/res/drawable/lock.xml
new file mode 100644
index 0000000..af07ddc
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/lock.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1 .9 2 2
+2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9
+2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/lock_notification_icon.xml b/demoproviders/barbican/res/drawable/lock_notification_icon.xml
new file mode 100644
index 0000000..76cbcd9
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/lock_notification_icon.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@mipmap/ic_lock_24dp" />
+</selector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/person.xml b/demoproviders/barbican/res/drawable/person.xml
new file mode 100644
index 0000000..1ca47a7
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/person.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#4fc3f7"
+        android:pathData="M 12 1 C 18.0751322481 1 23 5.92486775186 23 12 C 23 18.0751322481 18.0751322481 23 12 23 C 5.92486775186 23 1 18.0751322481 1 12 C 1 5.92486775186 5.92486775186 1 12 1 Z" />
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M 12,12 c 1.93375,0 3.5,-1.56625 3.5,-3.5 C 15.5,6.56625 13.93375,5 12,5 10.06625,5 8.5,6.56625 8.5,8.5 8.5,10.43375 10.06625,12 12,12 z m 0,1.75 c -2.33625,0 -7,1.1725 -7,3.5 V 19 h 14 v -1.75 c 0,-2.3275 -4.66375,-3.5 -7,-3.5 z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/phone.xml b/demoproviders/barbican/res/drawable/phone.xml
new file mode 100644
index 0000000..1f0b7ff
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/phone.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#4fc3f7"
+        android:pathData="M 12 1 C 18.0751322481 1 23 5.92486775186 23 12 C 23 18.0751322481 18.0751322481 23 12 23 C 5.92486775186 23 1 18.0751322481 1 12 C 1 5.92486775186 5.92486775186 1 12 1 Z" />
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M 7.8155556,11.058889 c 1.12,2.201111 2.9244444,3.997777 5.1255564,5.125555 l 1.71111,-1.71111 c 0.21,-0.21 0.521112,-0.28 0.793334,-0.186668 C 16.316666,14.574444 17.257778,14.73 18.222222,14.73 18.65,14.73 19,15.08 19,15.507778 v 2.714444 C 19,18.65 18.65,19 18.222222,19 10.918889,19 5,13.081112 5,5.7777778 5,5.35 5.35,5 5.7777778,5 H 8.5 C 8.9277778,5 9.2777778,5.35 9.2777778,5.7777778 9.2777778,6.75 9.4333334,7.6833334 9.7211111,8.554444 9.8066661,8.826667 9.7444441,9.13 9.5266666,9.347778 l -1.711111,1.711111 z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/splash.xml b/demoproviders/barbican/res/drawable/splash.xml
new file mode 100644
index 0000000..76f5590
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/splash.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@color/colorPrimary" />
+
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@mipmap/ic_launcher" />
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/unlock.xml b/demoproviders/barbican/res/drawable/unlock.xml
new file mode 100644
index 0000000..7514b5f
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/unlock.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7
+3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2
+2v10c0 1.1 .9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/unlocked_notification_icon.xml b/demoproviders/barbican/res/drawable/unlocked_notification_icon.xml
new file mode 100644
index 0000000..a9c496b
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/unlocked_notification_icon.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@mipmap/ic_lock_open_24dp" />
+</selector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/drawable/wipe_associations.xml b/demoproviders/barbican/res/drawable/wipe_associations.xml
new file mode 100644
index 0000000..7e2b353
--- /dev/null
+++ b/demoproviders/barbican/res/drawable/wipe_associations.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportHeight="24"
+        android:viewportWidth="24">
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M11.7116 18.9981c-1.781 0 -3.22402 -1.405 -3.22402 -3.138 0 -1.623 1.04501 -2.763 2.81302 -3.121 1.767 -0.357 3.599 -1.2059 4.616 -2.576 0.391 1.291 0.595 2.648 0.595 4.035 0 2.6466 -2.153 4.8 -4.8 4.8zm1.788 -18.331033c0 0 0.74 2.648003 0.74 4.798003 0 2.062 -1.352 3.733 -3.413 3.733 -2.06302 0 -3.62702 -1.671 -3.62702 -3.733l0.02701 -0.361C5.21259 7.51174 3.9996 10.6131 3.9996 13.9981c0 4.418 3.582 8 8 8 4.418 0 8 -3.582 8 -8 0 -5.39403 -2.593 -10.20303 -6.5 -13.331033z"
+        android:strokeLineJoin="round"/>
+</vector>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/apipairing_list_layout.xml b/demoproviders/barbican/res/layout/apipairing_list_layout.xml
new file mode 100644
index 0000000..d4125f2
--- /dev/null
+++ b/demoproviders/barbican/res/layout/apipairing_list_layout.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@android:color/white">
+
+    <android.support.design.widget.AppBarLayout
+        android:id="@+id/appBar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:fitsSystemWindows="true"
+        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+        <android.support.v7.widget.Toolbar
+            android:id="@+id/headerToolbar"
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            app:layout_scrollFlags="scroll|enterAlways" />
+
+    </android.support.design.widget.AppBarLayout>
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/paired_list"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingTop="8dp"
+        android:paddingBottom="8dp"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/app_item.xml b/demoproviders/barbican/res/layout/app_item.xml
new file mode 100644
index 0000000..129ebff
--- /dev/null
+++ b/demoproviders/barbican/res/layout/app_item.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="60dp"
+    android:orientation="horizontal"
+    android:gravity="center_vertical"
+    tools:ignore="UseCompoundDrawables">
+
+    <ImageView
+        android:id="@+id/app_icon"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginStart="16dp"
+        android:contentDescription="@string/credential_authority_icon"
+        android:visibility="invisible" />
+
+    <TextView
+        android:id="@+id/app_name"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="32dp"
+        android:layout_marginStart="32dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginEnd="16dp"
+        android:layout_weight="1"
+        android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
+
+</LinearLayout>
diff --git a/demoproviders/barbican/res/layout/auto_sign_in_layout.xml b/demoproviders/barbican/res/layout/auto_sign_in_layout.xml
new file mode 100644
index 0000000..81f7743
--- /dev/null
+++ b/demoproviders/barbican/res/layout/auto_sign_in_layout.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_gravity="bottom"
+    android:background="@color/colorPrimary"
+    android:gravity="center_vertical"
+    android:minHeight="64dp"
+    android:orientation="horizontal"
+    android:padding="8dp"
+    tools:ignore="Overdraw">
+
+    <ImageView
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:contentDescription="@string/logo_contentDescription"
+        app:srcCompat="@drawable/app_icon"/>
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="16dp"
+        android:layout_marginStart="16dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/credential_primary"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Title"
+            tools:text="John Doe" />
+
+        <TextView
+            android:id="@+id/credential_secondary"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+            tools:text="john.doe@example.com"/>
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/demoproviders/barbican/res/layout/create_credential_layout.xml b/demoproviders/barbican/res/layout/create_credential_layout.xml
new file mode 100644
index 0000000..0b0a02f
--- /dev/null
+++ b/demoproviders/barbican/res/layout/create_credential_layout.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <android.support.design.widget.AppBarLayout
+        android:id="@+id/appBar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:fitsSystemWindows="true"
+        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+        <android.support.v7.widget.Toolbar
+            android:id="@+id/headerToolbar"
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            app:layout_scrollFlags="enterAlways" />
+
+    </android.support.design.widget.AppBarLayout>
+
+    <android.support.v4.widget.NestedScrollView
+        android:id="@+id/create_form_container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="16dp"
+            android:orientation="vertical">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="6dp"
+                android:layout_marginStart="6dp"
+                android:text="@string/app_spinner_label"
+                android:labelFor="@+id/app_picker"
+                android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
+
+            <Spinner
+                android:id="@+id/credential_authority"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:nextFocusForward="@+id/credential_id"/>
+
+            <android.support.design.widget.TextInputLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <!--
+                Deprecation of android:singleLine is ignored here as it is
+                actually required to get the correct behavior.
+                -->
+                <android.support.design.widget.TextInputEditText
+                    android:id="@+id/credential_id"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:nextFocusForward="@+id/credential_password"
+                    android:maxLines="1"
+                    android:singleLine="true"
+                    android:imeOptions="actionNext"
+                    android:hint="@string/id_hint"
+                    tools:ignore="Deprecated"/>
+
+            </android.support.design.widget.TextInputLayout>
+
+            <android.support.design.widget.TextInputLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <!--
+                Deprecation of android:singleLine is ignored here as it is
+                actually required to get the correct behavior.
+                -->
+                <android.support.design.widget.TextInputEditText
+                    android:id="@+id/credential_password"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:maxLines="1"
+                    android:singleLine="true"
+                    android:imeOptions="actionDone"
+                    android:hint="@string/password_hint"
+                    tools:ignore="Deprecated"/>
+
+            </android.support.design.widget.TextInputLayout>
+
+        </LinearLayout>
+    </android.support.v4.widget.NestedScrollView>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/demoproviders/barbican/res/layout/credential_list_layout.xml b/demoproviders/barbican/res/layout/credential_list_layout.xml
new file mode 100644
index 0000000..e86a5d2
--- /dev/null
+++ b/demoproviders/barbican/res/layout/credential_list_layout.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@android:color/white">
+
+    <android.support.design.widget.AppBarLayout
+        android:id="@+id/appBar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:fitsSystemWindows="true"
+        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+        <android.support.v7.widget.Toolbar
+            android:id="@+id/headerToolbar"
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            app:layout_scrollFlags="scroll|enterAlways" />
+
+    </android.support.design.widget.AppBarLayout>
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/credential_list"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingTop="8dp"
+        android:paddingBottom="8dp"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+    <android.support.design.widget.FloatingActionButton
+        android:id="@+id/create_credential"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom|end"
+        android:layout_margin="16dp"
+        app:srcCompat="@drawable/create"
+        app:fabSize="normal"
+        app:layout_anchor="@id/credential_list"
+        app:layout_anchorGravity="bottom|right|end"
+        />
+
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/credential_picker_item_view.xml b/demoproviders/barbican/res/layout/credential_picker_item_view.xml
new file mode 100644
index 0000000..9189222
--- /dev/null
+++ b/demoproviders/barbican/res/layout/credential_picker_item_view.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="60dp"
+    android:clickable="true"
+    android:background="?attr/selectableItemBackground"
+    android:orientation="horizontal"
+    android:gravity="center_vertical">
+
+    <ImageView
+        android:id="@+id/credential_icon"
+        android:layout_width="32dp"
+        android:layout_height="32dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginStart="16dp"
+        android:contentDescription="@string/credential_icon" />
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="24dp"
+        android:layout_marginStart="24dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginEnd="16dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/credential_primary_label"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
+
+        <TextView
+            android:id="@+id/credential_secondary_label"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+            tools:text="test@tester.com" />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/demoproviders/barbican/res/layout/credential_view.xml b/demoproviders/barbican/res/layout/credential_view.xml
new file mode 100644
index 0000000..8adab33
--- /dev/null
+++ b/demoproviders/barbican/res/layout/credential_view.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="60dp"
+    android:clickable="true"
+    android:background="?attr/selectableItemBackground"
+    android:orientation="horizontal"
+    android:gravity="center_vertical"
+    tools:ignore="Overdraw">
+
+    <ImageView
+        android:id="@+id/credential_authority_icon"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginStart="16dp"
+        android:contentDescription="@string/credential_authority_icon"
+        android:visibility="invisible" />
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="32dp"
+        android:layout_marginStart="32dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginEnd="16dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/credential_authority"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
+
+        <TextView
+            android:id="@+id/credential_id"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+            tools:text="test@tester.com" />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/demoproviders/barbican/res/layout/paired_api_item.xml b/demoproviders/barbican/res/layout/paired_api_item.xml
new file mode 100644
index 0000000..6ac27a9
--- /dev/null
+++ b/demoproviders/barbican/res/layout/paired_api_item.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="60dp"
+    android:background="?attr/selectableItemBackground"
+    android:clickable="true"
+    android:gravity="center_vertical"
+    android:orientation="horizontal"
+    tools:ignore="Overdraw">
+
+    <ImageView
+        android:id="@+id/api_icon"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginStart="16dp"
+        android:contentDescription="@string/credential_authority_icon"
+        android:visibility="invisible"/>
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="16dp"
+        android:layout_marginLeft="32dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginStart="32dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/paired_api_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body2"
+            android:textColor="@android:color/black"/>
+
+        <TextView
+            android:id="@+id/paired_api_desc"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+            android:textColor="@android:color/black"
+            tools:text="test@tester.com"/>
+
+    </LinearLayout>
+
+    <ImageButton
+        android:id="@+id/btn_delete"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:src="@android:drawable/ic_delete"
+        android:background="@android:drawable/screen_background_light_transparent"
+        android:contentDescription="@string/remove_unpaired_api_dialog_title"/>
+
+</LinearLayout>
diff --git a/demoproviders/barbican/res/layout/picker_layout.xml b/demoproviders/barbican/res/layout/picker_layout.xml
new file mode 100644
index 0000000..71732ad
--- /dev/null
+++ b/demoproviders/barbican/res/layout/picker_layout.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/colorPrimary"
+    android:orientation="vertical"
+    android:paddingBottom="16dp"
+    android:paddingTop="16dp"
+    tools:ignore="InconsistentLayout">
+
+    <ImageView
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_gravity="center_horizontal"
+        android:contentDescription="@string/logo_contentDescription"
+        app:srcCompat="@drawable/app_icon"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:text="@string/credential_selection_prompt"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/available_credentials"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_marginTop="8dp"
+        android:layout_weight="1" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/save_layout.xml b/demoproviders/barbican/res/layout/save_layout.xml
new file mode 100644
index 0000000..e502945
--- /dev/null
+++ b/demoproviders/barbican/res/layout/save_layout.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/colorPrimary"
+    android:orientation="vertical"
+    android:paddingTop="16dp"
+    android:paddingLeft="24dp"
+    android:paddingRight="24dp"
+    android:paddingBottom="8dp">
+
+    <ImageView
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_gravity="center_horizontal"
+        android:contentDescription="@string/logo_contentDescription"
+        app:srcCompat="@drawable/app_icon"/>
+
+    <TextView
+        android:id="@+id/save_prompt"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        style="@style/TextAppearance.AppCompat.Subhead"
+        tools:text="Would you like to save your account for AwesomeApp to Barbican?"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="end"
+        android:layout_marginTop="24dp"
+        android:orientation="horizontal">
+
+        <Button
+            android:id="@+id/never_save_button"
+            style="@style/Widget.AppCompat.Button.Borderless"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/never_save"/>
+
+        <Button
+            android:id="@+id/save_button"
+            style="@style/Widget.AppCompat.Button.Colored"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="8dp"
+            android:layout_marginStart="8dp"
+            android:text="@string/save_account"
+            android:textAppearance="@style/TextAppearance.AppCompat.Widget.Button"/>
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/unlock_layout.xml b/demoproviders/barbican/res/layout/unlock_layout.xml
new file mode 100644
index 0000000..dfdb15a
--- /dev/null
+++ b/demoproviders/barbican/res/layout/unlock_layout.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:padding="16dp">
+
+    <ImageView
+        android:layout_width="96dp"
+        android:layout_height="96dp"
+        android:contentDescription="@string/logo_contentDescription"
+        app:srcCompat="@drawable/app_icon"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="8dp"
+        android:text="@string/unlock_prompt"
+        android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
+
+    <LinearLayout
+        android:id="@+id/password_entry"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical" >
+
+        <EditText
+            android:id="@+id/password"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:inputType="textPassword"
+            />
+
+        <TextView
+            android:id="@+id/invalid_password"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="6dp"
+            android:layout_marginStart="6dp"
+            android:text="@string/invalid_password"
+            android:textColor="@color/colorAccent"
+            android:visibility="gone" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/loading"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:gravity="center"
+        android:visibility="gone">
+
+        <ProgressBar
+            style="@style/Widget.AppCompat.ProgressBar.Horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="30dp"
+            android:indeterminate="true" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/unlock_loading_prompt" />
+    </LinearLayout>
+
+
+</LinearLayout>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/layout/welcome_layout.xml b/demoproviders/barbican/res/layout/welcome_layout.xml
new file mode 100644
index 0000000..f88ec42
--- /dev/null
+++ b/demoproviders/barbican/res/layout/welcome_layout.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:paddingTop="16dp"
+        tools:context=".WelcomeActivity">
+
+        <ImageView
+            android:layout_width="96dp"
+            android:layout_height="96dp"
+            android:contentDescription="@string/logo_contentDescription"
+            app:srcCompat="@drawable/app_icon"/>
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/welcome_title"
+            android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="8dp"
+            android:text="@string/welcome_prompt"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
+
+        <EditText
+                android:id="@+id/password"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:inputType="textPassword"/>
+
+        <LinearLayout
+            android:id="@+id/loading"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:gravity="center"
+            android:visibility="gone">
+
+            <ProgressBar
+                style="@style/Widget.AppCompat.ProgressBar.Horizontal"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="30dp"
+                android:indeterminate="true" />
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/welcome_loading_prompt"/>
+        </LinearLayout>
+
+
+    </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/menu/menu_create.xml b/demoproviders/barbican/res/menu/menu_create.xml
new file mode 100644
index 0000000..8fc608f
--- /dev/null
+++ b/demoproviders/barbican/res/menu/menu_create.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <item
+        android:id="@+id/action_done"
+        android:title="@string/action_create_done_contentDescription"
+        android:icon="@drawable/done_states"
+        app:showAsAction="ifRoom" />
+
+</menu>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/menu/menu_main.xml b/demoproviders/barbican/res/menu/menu_main.xml
new file mode 100644
index 0000000..945a112
--- /dev/null
+++ b/demoproviders/barbican/res/menu/menu_main.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <item
+        android:id="@+id/action_wipe"
+        android:icon="@drawable/wipe_associations"
+        android:title="@string/action_wipe_contentDescription"
+        app:showAsAction="ifRoom"/>
+
+    <item
+        android:id="@+id/action_lock"
+        android:icon="@drawable/lock"
+        android:title="@string/action_lock_contentDescription"
+        app:showAsAction="ifRoom"/>
+
+</menu>
\ No newline at end of file
diff --git a/demoproviders/barbican/res/mipmap-hdpi/ic_launcher.png b/demoproviders/barbican/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..996ff4a
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/demoproviders/barbican/res/mipmap-hdpi/ic_lock_24dp.png b/demoproviders/barbican/res/mipmap-hdpi/ic_lock_24dp.png
new file mode 100644
index 0000000..559b6c5
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-hdpi/ic_lock_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-hdpi/ic_lock_open_24dp.png b/demoproviders/barbican/res/mipmap-hdpi/ic_lock_open_24dp.png
new file mode 100644
index 0000000..238cb00
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-hdpi/ic_lock_open_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-mdpi/ic_launcher.png b/demoproviders/barbican/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..68bd9a0
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/demoproviders/barbican/res/mipmap-mdpi/ic_lock_24dp.png b/demoproviders/barbican/res/mipmap-mdpi/ic_lock_24dp.png
new file mode 100644
index 0000000..6173341
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-mdpi/ic_lock_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-mdpi/ic_lock_open_24dp.png b/demoproviders/barbican/res/mipmap-mdpi/ic_lock_open_24dp.png
new file mode 100644
index 0000000..929ad36
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-mdpi/ic_lock_open_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-xhdpi/ic_launcher.png b/demoproviders/barbican/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..e21e245
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/demoproviders/barbican/res/mipmap-xhdpi/ic_lock_24dp.png b/demoproviders/barbican/res/mipmap-xhdpi/ic_lock_24dp.png
new file mode 100644
index 0000000..93d9ed9
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xhdpi/ic_lock_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-xhdpi/ic_lock_open_24dp.png b/demoproviders/barbican/res/mipmap-xhdpi/ic_lock_open_24dp.png
new file mode 100644
index 0000000..989611f
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xhdpi/ic_lock_open_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-xxhdpi/ic_launcher.png b/demoproviders/barbican/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..26926f6
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/demoproviders/barbican/res/mipmap-xxhdpi/ic_lock_24dp.png b/demoproviders/barbican/res/mipmap-xxhdpi/ic_lock_24dp.png
new file mode 100644
index 0000000..1850436
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xxhdpi/ic_lock_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-xxhdpi/ic_lock_open_24dp.png b/demoproviders/barbican/res/mipmap-xxhdpi/ic_lock_open_24dp.png
new file mode 100644
index 0000000..a7bf028
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xxhdpi/ic_lock_open_24dp.png differ
diff --git a/demoproviders/barbican/res/mipmap-xxxhdpi/ic_launcher.png b/demoproviders/barbican/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..54a20e8
Binary files /dev/null and b/demoproviders/barbican/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/demoproviders/barbican/res/values/colors.xml b/demoproviders/barbican/res/values/colors.xml
new file mode 100644
index 0000000..1cddef3
--- /dev/null
+++ b/demoproviders/barbican/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#546E7A</color>
+    <color name="colorPrimaryDark">#37474F</color>
+    <color name="colorAccent">#4fc3f7</color>
+</resources>
diff --git a/demoproviders/barbican/res/values/strings.xml b/demoproviders/barbican/res/values/strings.xml
new file mode 100644
index 0000000..2e93dcb
--- /dev/null
+++ b/demoproviders/barbican/res/values/strings.xml
@@ -0,0 +1,37 @@
+<resources xmlns:xliff="http://schemas.android.com/tools">
+    <string name="action_create_done_contentDescription">Store credential</string>
+    <string name="action_lock_contentDescription">Lock credential store</string>
+    <string name="app_name_short">Barbican</string>
+    <string name="app_spinner_label">App:</string>
+    <string name="create_credential_activity_label">Store credential</string>
+    <string name="create_failure">Failed to create the credential store :(</string>
+    <string name="credential_storage_service_label">Barbican credential storage service</string>
+    <string name="credential_authority_icon">App icon</string>
+    <string name="credential_selection_prompt">Continue with:</string>
+    <string name="credential_icon">Credential profile picture</string>
+    <string name="id_hint">User name</string>
+    <string name="invalid_password">Invalid password, try again</string>
+    <string name="logo_contentDescription">Barbican logo</string>
+    <string name="password_hint">Password</string>
+    <string name="save_failed">Failed to save credential :(</string>
+    <string name="unlock_prompt">Enter your password:</string>
+    <string name="unlock_loading_prompt">Decrypting store…</string>
+    <string name="unlocked_notification_title">Barbican is unlocked</string>
+    <string name="unlocked_notification_text">Passwords are currently readable.</string>
+    <string name="unlocked_notification_lock_action">Lock now</string>
+    <string name="welcome_loading_prompt">Initializing storage…</string>
+    <string name="welcome_title">Welcome!</string>
+    <string name="welcome_prompt">Please choose a password with at least 6 characters:</string>
+    <string name="never_save">Never</string>
+    <string name="save_account">Save account</string>
+    <string name="save_prompt_template">
+        Would you like to save your account for
+        <xliff:g example="Netflix" id="appName">%1$s</xliff:g>
+        to Barbican?
+    </string>
+    <string name="action_wipe_contentDescription">Wipe associations for save</string>
+    <string name="remove_unpaired_api_dialog_title">Remove this App from the \"Never Save\" list?</string>
+    <string name="openyolo_simple_yes">Yes</string>
+    <string name="openyolo_simple_no">No</string>
+    <string name="ask_delete_credential">Delete credential?</string>
+</resources>
diff --git a/demoproviders/barbican/res/values/styles.xml b/demoproviders/barbican/res/values/styles.xml
new file mode 100644
index 0000000..a05bb57
--- /dev/null
+++ b/demoproviders/barbican/res/values/styles.xml
@@ -0,0 +1,43 @@
+<resources>
+    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+        <item name="colorAccent">@color/colorAccent</item>
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+    </style>
+
+    <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
+        <item name="colorAccent">@color/colorAccent</item>
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="android:background">@color/colorPrimary</item>
+    </style>
+
+    <style name="AppTheme.NoUi" parent="Theme.AppCompat.NoActionBar">
+        <item name="android:colorBackgroundCacheHint">@null</item>
+        <item name="android:windowAnimationStyle">@null</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowIsTranslucent">true</item>
+    </style>
+
+    <style name="AppTheme.Dialog" parent="Theme.AppCompat.Dialog">
+        <item name="android:windowActionBar">false</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowMinWidthMajor">80%</item>
+        <item name="android:windowMinWidthMinor">80%</item>
+        <item name="android:background">@color/colorPrimary</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="AutoSignInTheme" parent="Theme.AppCompat">
+        <item name="android:backgroundDimEnabled">false</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
+        <item name="android:windowBackground">@drawable/splash</item>
+        <item name="android:windowAnimationStyle">@null</item>
+    </style>
+</resources>
diff --git a/demoproviders/trapdoor/AndroidManifest.xml b/demoproviders/trapdoor/AndroidManifest.xml
new file mode 100644
index 0000000..546c641
--- /dev/null
+++ b/demoproviders/trapdoor/AndroidManifest.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="org.openyolo.demoprovider.trapdoor">
+
+    <permission android:name="org.openyolo.demoprovider.trapdoor.STORAGE" />
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="org.openyolo.demoprovider.trapdoor.STORAGE" />
+
+    <application
+        android:allowBackup="false"
+        android:fullBackupContent="false"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name_short"
+        android:supportsRtl="false"
+        android:theme="@style/AppTheme"
+        android:name=".Application"
+        tools:ignore="GoogleAppIndexingWarning">
+
+        <activity
+            android:name=".MainActivity"
+            android:label="@string/app_name_short"
+            android:theme="@style/AppTheme.NoActionBar"
+            android:windowSoftInputMode="stateHidden"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name=".RetrieveActivity"
+            android:label="@string/app_name_short"
+            android:theme="@style/AppTheme.Dialog"
+            android:excludeFromRecents="true"
+            android:windowSoftInputMode="stateAlwaysVisible"
+            android:exported="true" />
+
+        <receiver
+            android:name=".CredentialQueryReceiver"
+            android:exported="true"
+            android:enabled="true"
+            tools:ignore="ExportedReceiver">
+            <intent-filter>
+                <action android:name="org.openyolo.credential" />
+                <category android:name="com.google.bbq.QUERY" />
+            </intent-filter>
+        </receiver>
+
+    </application>
+</manifest>
diff --git a/demoproviders/trapdoor/README.md b/demoproviders/trapdoor/README.md
new file mode 100644
index 0000000..cfafa33
--- /dev/null
+++ b/demoproviders/trapdoor/README.md
@@ -0,0 +1,7 @@
+# Trapdoor - a minimal credential provider
+
+Trapdoor is much simpler credential provider than Barbican, with no storage and a very simple
+cryptographic operation to generate passwords for apps. It transforms a 6-digit pin and an
+app identifier into a 16 character password. This approach is fine for a demo, but is riddled
+with issues for a real world password manager - DO NOT copy this approach for any real world
+usage.
diff --git a/demoproviders/trapdoor/build.gradle b/demoproviders/trapdoor/build.gradle
new file mode 100644
index 0000000..b757c47
--- /dev/null
+++ b/demoproviders/trapdoor/build.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'com.android.application'
+apply plugin: 'checkstyle'
+apply plugin: 'com.neenbedankt.android-apt'
+
+apply from: "${rootDir}/config/android-common.gradle"
+
+android {
+    defaultConfig {
+        applicationId 'org.openyolo.demoprovider.trapdoor'
+        project.archivesBaseName = 'openyolo-demoprovider-trapdoor'
+        vectorDrawables.useSupportLibrary = true
+    }
+    buildTypes {
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt')
+        }
+    }
+}
+
+dependencies {
+    compile project(':spi')
+    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    compile "com.android.support:support-vector-drawable:${rootProject.supportLibVersion}"
+    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    compile "com.android.support:design:${rootProject.supportLibVersion}"
+    compile 'com.madgag.spongycastle:core:1.54.0.0'
+
+    // stylish pin entry field
+    compile 'me.philio:pinentryview:1.0.6'
+
+    compile 'com.jakewharton:butterknife:8.5.1'
+    compile 'com.github.bumptech.glide:glide:3.7.0'
+    apt 'com.jakewharton:butterknife-compiler:8.5.1'
+
+    apply from: "${rootDir}/config/testdeps.gradle", to:it
+    testCompile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+}
+
+apply from: "${rootDir}/config/style.gradle"
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/Application.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/Application.java
new file mode 100644
index 0000000..229c48c
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/Application.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.trapdoor;
+
+import android.support.v7.app.AppCompatDelegate;
+
+/**
+ * Application object; ensures that the support library is correctly configured for use of
+ * vector drawables.
+ */
+public class Application extends android.app.Application {
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
+    }
+}
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
new file mode 100644
index 0000000..b6a6f4e
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/CredentialQueryReceiver.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.trapdoor;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.util.Log;
+import com.google.bbq.QueryResponseSender;
+import com.google.bbq.proto.BroadcastQuery;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+import okio.ByteString;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.RetrieveRequest;
+import org.openyolo.api.internal.IntentUtil;
+import org.openyolo.proto.CredentialRetrieveResponse;
+import org.openyolo.spi.BaseCredentialQueryReceiver;
+
+/**
+ * Handles OpenYOLO credential retrieve broadcasts. As trapdoor does not store any credentials,
+ * we respond to all requests with an intent as long as at least one of the requested authentication
+ * domains is explicitly associated with the requesting app, and that the
+ * {@link org.openyolo.api.AuthenticationMethods#ID_AND_PASSWORD id and password} authentication
+ * method is supported.
+ */
+public class CredentialQueryReceiver extends BaseCredentialQueryReceiver {
+
+    private static final String LOG_TAG = "CredentialQueryReceiver";
+
+    /**
+     * Creates the query receiver.
+     */
+    public CredentialQueryReceiver() {
+        super(LOG_TAG);
+    }
+
+    @Override
+    protected void processCredentialRequest(
+            @NonNull Context context,
+            @NonNull BroadcastQuery query,
+            @NonNull RetrieveRequest request,
+            @NonNull Set<AuthenticationDomain> requestorDomains) {
+
+        Log.i(LOG_TAG, "Processing retrieve query from claimed caller: " + query.requestingApp);
+
+        final Context applicationContext = context.getApplicationContext();
+        final QueryResponseSender responseSender = new QueryResponseSender(applicationContext);
+
+        TreeSet<AuthenticationDomain> matchingDomains =
+                new TreeSet<AuthenticationDomain>(requestorDomains);
+        matchingDomains.retainAll(new HashSet<Object>(request.getAuthenticationDomains()));
+
+        if (matchingDomains.isEmpty()) {
+            Log.i(LOG_TAG, "Caller does not match any requested auth domains - ignoring");
+            responseSender.sendResponse(query, null);
+            return;
+        }
+
+        Intent retrieveIntent = RetrieveActivity.createIntent(applicationContext);
+        CredentialRetrieveResponse response = new CredentialRetrieveResponse.Builder()
+                .retrieveIntent(ByteString.of(IntentUtil.toBytes(retrieveIntent)))
+                .build();
+
+        Log.i(LOG_TAG, "Accepting credential request for claimed caller: " + query.requestingApp);
+        responseSender.sendResponse(query, response.encode());
+    }
+}
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/MainActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/MainActivity.java
new file mode 100644
index 0000000..9d8f3d1
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/MainActivity.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.trapdoor;
+
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import me.philio.pinentry.PinEntryView;
+
+/**
+ * The launch activity for Trapdoor, which allows the user to set some basic user data for
+ * credentials and test out password generation.
+ */
+public class MainActivity extends AppCompatActivity {
+
+    private static final int PIN_LENGTH = 6;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main_layout);
+
+        EditText userNameField = (EditText)findViewById(R.id.user_name_field);
+        if (getUsername().isEmpty()) {
+            userNameField.setText(UserDataStore.getUserName(this));
+        }
+
+        ((EditText)findViewById(R.id.user_name_field))
+                .addTextChangedListener(new UpdateUsernameWatcher());
+
+        ((PinEntryView)findViewById(R.id.pin_entry_field))
+                .addTextChangedListener(new RegenerateWatcher());
+
+        ((EditText)findViewById(R.id.app_name_field))
+                .addTextChangedListener(new RegenerateWatcher());
+
+        findViewById(R.id.copy_password).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                copyPassword();
+            }
+        });
+
+        generatePassword();
+    }
+
+    private void generatePassword() {
+        String userName = getUsername();
+        String pin = getPin();
+        String appName = getAppName();
+
+        TextView passwordView = (TextView)findViewById(R.id.password_view);
+        Button copyButton = (Button)findViewById(R.id.copy_password);
+
+        if (userName.isEmpty() || pin.length() < PIN_LENGTH || appName.isEmpty()) {
+            passwordView.setText("");
+            copyButton.setVisibility(View.GONE);
+        } else {
+            passwordView.setText(PasswordGenerator.generatePassword(userName, pin, appName));
+            copyButton.setVisibility(View.VISIBLE);
+        }
+    }
+
+    private String getPin() {
+        return ((PinEntryView) findViewById(R.id.pin_entry_field)).getText().toString();
+    }
+
+    private String getUsername() {
+        return ((EditText) findViewById(R.id.user_name_field)).getText().toString().trim();
+    }
+
+    private String getAppName() {
+        return ((EditText) findViewById(R.id.app_name_field)).getText().toString().trim();
+    }
+
+    private String getLastPassword() {
+        return ((TextView) findViewById(R.id.password_view)).getText().toString();
+    }
+
+    private void copyPassword() {
+        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
+        ClipData clip = ClipData.newPlainText("Password", getLastPassword());
+        clipboard.setPrimaryClip(clip);
+    }
+
+    private class RegenerateWatcher implements TextWatcher {
+
+        @Override
+        public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
+
+        @Override
+        public void onTextChanged(CharSequence seq, int start, int before, int count) {}
+
+        @Override
+        public void afterTextChanged(Editable ed) {
+            generatePassword();
+        }
+    }
+
+    private class UpdateUsernameWatcher implements TextWatcher {
+        @Override
+        public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
+
+        @Override
+        public void onTextChanged(CharSequence seq, int start, int before, int count) {}
+
+        @Override
+        public void afterTextChanged(Editable userName) {
+            UserDataStore.setUserName(MainActivity.this, userName.toString());
+        }
+    }
+}
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/PasswordGenerator.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/PasswordGenerator.java
new file mode 100644
index 0000000..f8f8710
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/PasswordGenerator.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.trapdoor;
+
+import java.math.BigInteger;
+import java.nio.charset.Charset;
+import org.spongycastle.crypto.digests.Blake2bDigest;
+
+/**
+ * Generates passwords to handle credential retrieve requests.
+ */
+public class PasswordGenerator {
+
+    private static final int HASH_SIZE = 8;
+
+    private static final int PASSWORD_SIZE = 12;
+
+    private static final String BASE56_ENCODING_CHARS =
+            "8Zy5giQPhGbUS4FBJjDfuVwE9t7LkHX2sAKv6NczRdpnTWmexqa3rCYM";
+
+    /**
+     * Generates a password for a given user name, pin and unique application identifier.
+     */
+    public static String generatePassword(String userName, String pin, String appId) {
+        String plainText = userName + "-" + pin + "-" + appId;
+        byte[] plainTextBytes = plainText.getBytes(Charset.forName("UTF-8"));
+        return toBase56(digest(plainTextBytes));
+    }
+
+    private static byte[] digest(byte[] input) {
+        Blake2bDigest digest = new Blake2bDigest(
+                null, /* no key */
+                HASH_SIZE,
+                null, /* no salt */
+                null); /* no personalization of the hashing function */
+
+        digest.update(input, 0, input.length);
+        byte[] result = new byte[HASH_SIZE];
+        digest.doFinal(result, 0);
+
+        return result;
+    }
+
+    private static String toBase56(byte[] value) {
+        StringBuilder builder = new StringBuilder();
+        BigInteger quotient = new BigInteger(value);
+
+        BigInteger base = new BigInteger("56");
+
+        int size = 0;
+        while (quotient.compareTo(BigInteger.ZERO) > 0 || size < PASSWORD_SIZE) {
+            int remainder = quotient.mod(base).intValue();
+            builder.append(BASE56_ENCODING_CHARS.charAt(remainder));
+            quotient = quotient.divide(base);
+            size++;
+        }
+
+        return builder.toString();
+    }
+}
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
new file mode 100644
index 0000000..f770785
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/RetrieveActivity.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.trapdoor;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import java.util.TreeSet;
+import me.philio.pinentry.PinEntryView;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.AuthenticationMethods;
+import org.openyolo.proto.Credential;
+import org.openyolo.spi.RetrieveIntentResultUtil;
+
+/**
+ * Collects a 6-digit pin from the user, then generates a password to return to the invoking app.
+ */
+public class RetrieveActivity extends AppCompatActivity {
+
+    private static final int PIN_SIZE = 6;
+
+    private static final String LOG_TAG = "TrapdoorRetrieve";
+
+    private AuthenticationDomain mDomain;
+
+    /**
+     * Creates an Intent to start this activity.
+     */
+    public static Intent createIntent(Context context) {
+        return new Intent(context, RetrieveActivity.class);
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (getCallingPackage() == null) {
+            Log.w(LOG_TAG, "No calling package for retrieve request, canceling");
+            setResult(RESULT_CANCELED);
+            finish();
+            return;
+        }
+
+        mDomain = new TreeSet<>(
+                AuthenticationDomain.listForPackage(this, getCallingPackage())).first();
+        Log.i(LOG_TAG, "processing retrieve intent from " + mDomain);
+
+        setContentView(R.layout.dialog_layout);
+        ((PinEntryView)findViewById(R.id.pin_entry_field))
+                .addTextChangedListener(new PinChangedWatcher());
+    }
+
+    private class PinChangedWatcher implements TextWatcher {
+        @Override
+        public void beforeTextChanged(CharSequence seq, int start, int count, int after) {}
+
+        @Override
+        public void onTextChanged(CharSequence seq, int start, int before, int count) {}
+
+        @Override
+        public void afterTextChanged(Editable pin) {
+            if (pin.length() != PIN_SIZE) {
+                return;
+            }
+            String userName = UserDataStore.getUserName(RetrieveActivity.this);
+            String password = PasswordGenerator.generatePassword(
+                    userName,
+                    pin.toString(),
+                    mDomain.toString());
+
+            Credential credential = new Credential.Builder()
+                    .authMethod(AuthenticationMethods.ID_AND_PASSWORD.toString())
+                    .authDomain(mDomain.toString())
+                    .id(UserDataStore.getUserName(RetrieveActivity.this))
+                    .password(password)
+                    .build();
+
+            setResult(RESULT_OK, RetrieveIntentResultUtil.createResponseData(credential));
+            finish();
+        }
+    }
+}
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/UserDataStore.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/UserDataStore.java
new file mode 100644
index 0000000..77200a2
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/UserDataStore.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.demoprovider.trapdoor;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * Utility class to access and manipulate user data that is pertinent to password generation.
+ */
+public class UserDataStore {
+
+    private static final String SHARED_PREF_NAME = "userData";
+
+    private static final String KEY_USER_NAME = "userName";
+
+    private static final String DEFAULT_USER_NAME = "jdoe";
+
+    /**
+     * Changes the stored user name to the provided value.
+     */
+    public static void setUserName(Context context, String userName) {
+        SharedPreferences prefs =
+                context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
+        prefs.edit().putString(KEY_USER_NAME, userName).apply();
+    }
+
+    /**
+     * Retrieves the stored user name for credentials.
+     */
+    public static String getUserName(Context context) {
+        SharedPreferences prefs =
+                context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
+        return prefs.getString(KEY_USER_NAME, DEFAULT_USER_NAME);
+    }
+}
diff --git a/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/package-info.java b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/package-info.java
new file mode 100644
index 0000000..3205ccc
--- /dev/null
+++ b/demoproviders/trapdoor/java/org/openyolo/demoprovider/trapdoor/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Trapdoor is much simpler credential provider than Barbican, with no storage and a very simple
+ * cryptographic operation to generate passwords for apps. It transforms a 6-digit pin and an
+ * app identifier into a 16 character password. This approach is fine for a demo, but is riddled
+ * with issues for a real world password manager - DO NOT copy this approach for any real world
+ * usage.
+ */
+package org.openyolo.demoprovider.trapdoor;
diff --git a/demoproviders/trapdoor/res/drawable-v23/splash.xml b/demoproviders/trapdoor/res/drawable-v23/splash.xml
new file mode 100644
index 0000000..c1ed4ba
--- /dev/null
+++ b/demoproviders/trapdoor/res/drawable-v23/splash.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:drawable="@color/colorLight"
+        android:gravity="fill"/>
+
+    <item android:drawable="@drawable/app_icon"
+        android:gravity="center"
+        android:width="192dp"
+        android:height="192dp">
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/drawable/app_icon.xml b/demoproviders/trapdoor/res/drawable/app_icon.xml
new file mode 100644
index 0000000..7e87ae0
--- /dev/null
+++ b/demoproviders/trapdoor/res/drawable/app_icon.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="48dp"
+    android:height="48dp"
+    android:viewportWidth="48"
+    android:viewportHeight="48">
+
+    <path
+        android:fillColor="#8bc34a"
+        android:strokeWidth="1"
+        android:pathData="M19,7 L43,7 L43,31 L19,31 Z" />
+    <path
+        android:fillColor="#212121"
+        android:strokeWidth="1"
+        android:pathData="M19,31 L43,31 L29,41 L5,41 Z" />
+    <path
+        android:fillColor="#f4ff81"
+        android:strokeWidth="1"
+        android:pathData="M5,41 L5,17 L19,7 L19,31 Z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/drawable/copy.xml b/demoproviders/trapdoor/res/drawable/copy.xml
new file mode 100644
index 0000000..4f6eede
--- /dev/null
+++ b/demoproviders/trapdoor/res/drawable/copy.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/copy_icon" />
+</selector>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/drawable/copy_icon.xml b/demoproviders/trapdoor/res/drawable/copy_icon.xml
new file mode 100644
index 0000000..42463b4
--- /dev/null
+++ b/demoproviders/trapdoor/res/drawable/copy_icon.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M16,1 L4,1 C2.9,1,2,1.9,2,3 L2,17 L4,17 L4,3 L16,3 L16,1 Z M19,5 L8,5
+C6.9,5,6,5.9,6,7 L6,21 C6,22.1,6.9,23,8,23 L19,23 C20.1,23,21,22.1,21,21 L21,7
+C21,5.9,20.1,5,19,5 Z M19,21 L8,21 L8,7 L19,7 L19,21 Z" />
+</vector>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/drawable/splash.xml b/demoproviders/trapdoor/res/drawable/splash.xml
new file mode 100644
index 0000000..488b397
--- /dev/null
+++ b/demoproviders/trapdoor/res/drawable/splash.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@color/colorLight" />
+
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@mipmap/ic_launcher" />
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/layout/dialog_layout.xml b/demoproviders/trapdoor/res/layout/dialog_layout.xml
new file mode 100644
index 0000000..0ff857e
--- /dev/null
+++ b/demoproviders/trapdoor/res/layout/dialog_layout.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:padding="16dp">
+
+    <ImageView
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_gravity="center_horizontal"
+        android:contentDescription="@string/trapdoor_icon_contentDescription"
+        app:srcCompat="@drawable/app_icon"/>
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_horizontal"
+        android:text="@string/pin_prompt"
+        android:textAppearance="@style/TextAppearance.AppCompat.Title" />
+
+    <me.philio.pinentry.PinEntryView
+        android:id="@+id/pin_entry_field"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        app:accentType="character"
+        app:digitBackground="@android:color/white"
+        app:digitHeight="20dp"
+        app:digitTextColor="@color/black_54pc"
+        app:digitTextSize="8dp"
+        app:digitWidth="20dp"
+        app:numDigits="6" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/layout/main_layout.xml b/demoproviders/trapdoor/res/layout/main_layout.xml
new file mode 100644
index 0000000..11996ba
--- /dev/null
+++ b/demoproviders/trapdoor/res/layout/main_layout.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <android.support.v4.widget.NestedScrollView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="8dp"
+            android:gravity="center_horizontal"
+            android:orientation="vertical">
+
+            <TextView
+                style="@style/TextAppearance.AppCompat.Display1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/app_name_short" />
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/user_name_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <android.support.design.widget.TextInputEditText
+                    android:id="@+id/user_name_field"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/user_name_hint"
+                    android:inputType="textNoSuggestions|textVisiblePassword"
+                    />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <android.support.design.widget.TextInputLayout
+                android:id="@+id/app_name_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <android.support.design.widget.TextInputEditText
+                    android:id="@+id/app_name_field"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:hint="@string/app_name_hint"
+                    android:inputType="textNoSuggestions|textVisiblePassword"
+                    />
+
+            </android.support.design.widget.TextInputLayout>
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/pin_prompt"/>
+
+            <me.philio.pinentry.PinEntryView
+                android:id="@+id/pin_entry_field"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="20dp"
+                app:accentType="character"
+                app:digitBackground="@android:color/white"
+                app:digitHeight="40dp"
+                app:digitWidth="40dp"
+                app:numDigits="6" />
+
+            <TextView
+                android:id="@+id/password_view"
+                style="@style/TextAppearance.AppCompat.Large"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
+                android:fontFamily="monospace"
+                tools:ignore="UnusedAttribute" />
+
+            <Button
+                android:id="@+id/copy_password"
+                style="@style/PrimaryButtonStyle"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:drawableLeft="@drawable/copy"
+                android:drawableStart="@drawable/copy"
+                android:text="@string/copy_password_text" />
+
+        </LinearLayout>
+    </android.support.v4.widget.NestedScrollView>
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/demoproviders/trapdoor/res/mipmap-hdpi/ic_launcher.png b/demoproviders/trapdoor/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..df6af86
Binary files /dev/null and b/demoproviders/trapdoor/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/demoproviders/trapdoor/res/mipmap-mdpi/ic_launcher.png b/demoproviders/trapdoor/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..120fc82
Binary files /dev/null and b/demoproviders/trapdoor/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/demoproviders/trapdoor/res/mipmap-xhdpi/ic_launcher.png b/demoproviders/trapdoor/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..b45f7fd
Binary files /dev/null and b/demoproviders/trapdoor/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/demoproviders/trapdoor/res/mipmap-xxhdpi/ic_launcher.png b/demoproviders/trapdoor/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..4a74eec
Binary files /dev/null and b/demoproviders/trapdoor/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/demoproviders/trapdoor/res/mipmap-xxxhdpi/ic_launcher.png b/demoproviders/trapdoor/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..0fb84f3
Binary files /dev/null and b/demoproviders/trapdoor/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/demoproviders/trapdoor/res/values/colors.xml b/demoproviders/trapdoor/res/values/colors.xml
new file mode 100644
index 0000000..54ddb45
--- /dev/null
+++ b/demoproviders/trapdoor/res/values/colors.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#8bc34a</color>
+    <color name="colorPrimaryDark">#388e3c</color>
+    <color name="colorAccent">#2e7d32</color>
+
+    <color name="colorLight">#c5e1a5</color>
+</resources>
diff --git a/demoproviders/trapdoor/res/values/strings.xml b/demoproviders/trapdoor/res/values/strings.xml
new file mode 100644
index 0000000..03fe9bf
--- /dev/null
+++ b/demoproviders/trapdoor/res/values/strings.xml
@@ -0,0 +1,8 @@
+<resources>
+    <string name="app_name_short">Trapdoor</string>
+    <string name="app_name_hint">App / site name</string>
+    <string name="copy_password_text">Copy password</string>
+    <string name="user_name_hint">User name</string>
+    <string name="pin_prompt">Enter your pin:</string>
+    <string name="trapdoor_icon_contentDescription">Trapdoor icon</string>
+</resources>
diff --git a/demoproviders/trapdoor/res/values/styles.xml b/demoproviders/trapdoor/res/values/styles.xml
new file mode 100644
index 0000000..4f06a59
--- /dev/null
+++ b/demoproviders/trapdoor/res/values/styles.xml
@@ -0,0 +1,48 @@
+<resources>
+    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+        <item name="colorAccent">@color/colorAccent</item>
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+    </style>
+
+    <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
+        <item name="colorAccent">@color/colorAccent</item>
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="android:background">@color/colorLight</item>
+    </style>
+
+    <style name="AppTheme.NoUi" parent="Theme.AppCompat.NoActionBar">
+        <item name="android:colorBackgroundCacheHint">@null</item>
+        <item name="android:windowAnimationStyle">@null</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowIsTranslucent">true</item>
+    </style>
+
+    <style name="AppTheme.Dialog" parent="Theme.AppCompat.Dialog">
+        <item name="android:windowActionBar">false</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowMinWidthMajor">80%</item>
+        <item name="android:windowMinWidthMinor">80%</item>
+        <item name="android:background">@color/colorPrimary</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="AutoSignInTheme" parent="Theme.AppCompat">
+        <item name="android:backgroundDimEnabled">false</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
+        <item name="android:windowBackground">@drawable/splash</item>
+        <item name="android:windowAnimationStyle">@null</item>
+    </style>
+
+    <style name="PrimaryButtonStyle" parent="Widget.AppCompat.Button.Colored">
+        <item name="colorButtonNormal">@color/colorAccent</item>
+        <item name="android:textColor">@android:color/white</item>
+    </style>
+</resources>
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..deedc7f
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..678a46a
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Feb 01 19:21:11 PST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..9aa616c
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,169 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..e95643d
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..989fef4
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':bbq', ':api', ':spi', ':demoapp', ':demoproviders:barbican', ':demoproviders:trapdoor'
diff --git a/spec/.gitignore b/spec/.gitignore
new file mode 100644
index 0000000..f174344
--- /dev/null
+++ b/spec/.gitignore
@@ -0,0 +1 @@
+_book
diff --git a/spec/LANGS.md b/spec/LANGS.md
new file mode 100644
index 0000000..f8515ab
--- /dev/null
+++ b/spec/LANGS.md
@@ -0,0 +1,5 @@
+* [English](en)
+
+<!--
+* [French](fr)
+-->
diff --git a/spec/en/README.md b/spec/en/README.md
new file mode 100644
index 0000000..1b8d2e3
--- /dev/null
+++ b/spec/en/README.md
@@ -0,0 +1,73 @@
+# The OpenYOLO Specification
+
+OpenYOLO is a protocol for retrieving, updating and assisting in the creation of
+user credentials for Android apps. The protocol is intended to work on any
+Android 15+ device, and has no mandatory dependencies on Google-specific
+software or infrastructure, such as Google Play Services or the
+Google Play Store.
+
+This document describes the OpenYOLO protocol, and the underlying
+Background Broadcast Query protocol (BBQ) upon which it is built, and the
+APIs that simplify their usage:
+
+- The [OpenYOLO overview](openyolo-overview.md) chapter describes the high
+  level concepts and operations that OpenYOLO provides.
+
+- The [BBQ protocol](bbq-protocol.md) chapter describes the broadcast intent based
+  mechanism that is used to communicate with multiple credential providers
+  simultaneously. This is primarily used by the credential request flow.
+
+- [Retrieving credentials](retrieving-credentials.md) describes in detail the
+  flow for retrieving a credential from one of the providers installed on a
+  user's device, and allows for automatic sign-in to applications in most
+  cases.
+
+- [Assisting sign-up](assisting-sign-up.md) describes in detail the mechanism
+  by which a credential provider can provide information to "bootstrap" a new
+  account for an app. This typically allows the app to bypass the majority of
+  the manual text entry that is required for new account creation.
+
+- [Saving credentials](saving-credentials.md) describes in detail the flow for
+  saving and updating credentials, allowing an app to increase the chances that
+  a credential can be automatically retrieved upon future installations.
+
+- [Protecting users from malicious providers](protecting-users.md) describes
+  the technical counter-measures employed by the OpenYOLO API to minimize
+  the risk of credential theft and spoofing by malicious apps.
+
+- The [OpenYOLO API](api-overview.md) chapter describes the high-level API that
+  allows apps to retrieve and save credentials, and request assisted sign-up.
+
+- The [OpenYOLO SPI](spi-overview.md) chapter describes the Service Provider
+  Interface which helps credential providers to support the OpenYOLO protocol.
+
+App developers who wish to use OpenYOLO should read the
+[OpenYOLO overview](openyolo-overview.md) and the
+[API overview](api-overview.md) chapters. The other chapters may be of interest
+but are not pertinent to simply using the API. Those who are implementing
+OpenYOLO in a credential provider should read all chapters.
+
+## Authors
+
+* Iain McGinniss ([@iainmcgin](https://github.com/iainmcgin)), Google Inc.
+
+## Errata
+
+Queries and errata related to the specification should
+be filed as [GitHub issues](https://github.com/google/OpenYOLO/issues)
+on the [OpenYOLO repository](https://github.com/google/OpenYOLO)
+under the label "specification". The raw markdown source for the specification
+can be found at
+[https://github.com/google/OpenYOLO/spec](https://github.com/google/OpenYOLO/spec).
+We accept and encourage contributions, large and small, from any interested
+parties who are able to sign the Contributor License Agreement - see the
+[CONTRIBUTORS](https://github.com/google/OpenYOLO/CONTRIBUTORS) file for more
+information.
+
+## What does the name mean?
+
+YOLO, You Only Login Once, is the internal code name for Google's
+[Smart Lock for Passwords][yolo] API. Lessons learned from the design and use
+of this API have heavily influenced the design of OpenYOLO.
+
+[yolo]: https://developers.google.com/identity/smartlock-passwords/android
diff --git a/spec/en/SUMMARY.md b/spec/en/SUMMARY.md
new file mode 100644
index 0000000..c1cff49
--- /dev/null
+++ b/spec/en/SUMMARY.md
@@ -0,0 +1,8 @@
+* [OpenYOLO overview](openyolo-overview.md)
+* [BBQ protocol](bbq-protocol.md)
+* [Retrieving credentials](retrieving-credentials.md)
+* [Assisting sign-up](assisting-sign-up.md)
+* [Saving credentials](saving-credentials.md)
+* [Protecting users from malicious providers](protecting-users.md)
+* [OpenYOLO API](api-overview.md)
+* [OpenYOLO SPI](spi-overview.md)
diff --git a/spec/en/api-overview.md b/spec/en/api-overview.md
new file mode 100644
index 0000000..56f1443
--- /dev/null
+++ b/spec/en/api-overview.md
@@ -0,0 +1,4 @@
+# OpenYOLO API
+
+The details of OpenYOLO API are not yet formally defined. See the reference
+implementation for current progress.
diff --git a/spec/en/assisting-sign-up.md b/spec/en/assisting-sign-up.md
new file mode 100644
index 0000000..29b22d0
--- /dev/null
+++ b/spec/en/assisting-sign-up.md
@@ -0,0 +1,3 @@
+# Assisting sign-up
+
+The details of the assisted sign-up protocol are not yet defined.
diff --git a/spec/en/bbq-protocol.md b/spec/en/bbq-protocol.md
new file mode 100644
index 0000000..684380c
--- /dev/null
+++ b/spec/en/bbq-protocol.md
@@ -0,0 +1,178 @@
+# Background broadcast query protocol (BBQ)
+
+BBQ is a protocol designed to allow an Android app to simultaneously request
+data from multiple providers on the device. Requests and responses are sent
+as targeted broadcast messages, using
+[protocol buffer (v2) messages][protobuf] to encode the request and response
+data. The use of broadcast messages allows implementations to be fully
+asynchronous, and protocol buffers allow messages to be compact and efficient,
+while avoiding common issues with custom Parcelable types.
+
+## Structure of a request
+
+A broadcast query has the following mandatory properties:
+
+- The data type being requested, described with
+  [reverse domain name notation][reverse-domain], as is
+  typically used for package names and intent actions in Android.
+  For example, `org.openyolo.credential`.
+- The package name of the requesting app, e.g. `com.example.app`.
+- A randomly generated, 64-bit request ID. This is used to distinguish the
+  request from other requests with the same data type that may not have been
+  fully resolved.
+- A randomly generated, 64-bit response ID. A separate response ID is generated
+  for each expected responder, allowing responders to be distinguished and their
+  identity to be recovered from the mapping of response ID to package name that
+  is created prior to sending the request.
+- A description of the cryptographic scheme used for the exchange:
+    - A string that uniquely identifies the scheme.
+    - A set of key-value pairs carrying scheme-specific parameters.
+
+An additional data-type specific message can be carried in the request if
+necessary, in the form of a byte-array (typically an encoded protocol buffer).
+Additional parameters can also be encoded into the message as
+key-value pairs, allowing for extension of the protocol itself.
+
+The request is encoded using a [protocol buffer (v2) message][protobuf].
+Following the current guidance for protocol buffer message definitions, all
+fields are marked `optional` or `repeated` to provide flexibility in changing
+this specification in future. Fields currently considered to be required are
+marked as such with a comment.
+
+```protobuf
+message BroadcastQuery {
+  optional string       dataType         = 1; // required
+  optional string       requestingApp    = 2; // required
+  optional sfixed64     requestId        = 3; // required
+  optional sfixed64     responseId       = 4; // required
+  optional bytes        queryMessage     = 5;
+  repeated Parameter    additionalParams = 6;
+}
+
+message Parameter {
+	optional string name  = 1; // required
+	optional bytes  value = 2;
+}
+```
+
+## Dispatching a request
+
+A request is dispatched as one or more targeted broadcast intents. First, the
+requester uses the Android [PackageManager][pm-api] API to determine the set
+of apps which can provide data of the required type:
+
+```java
+Intent intent = new Intent(dataType);
+intent.addCategory(BBQ_CATEGORY);
+List<ResolveInfo> responderInfos =
+    packageManager.queryBroadcastReceivers(intent, 0);
+```
+
+A separate request is created for each potential responder, with a unique
+response ID, and sent as a targeted broadcast:
+
+```java
+BroadcastQuery query = new BroadcastQuery.Builder()
+    /* ... */
+    .setResponseId(idForResponder.get(responder))
+    .build();
+Intent bbqIntent = new Intent(dataType);
+bbqIntent.setPackage(responder);
+bbqIntent.setExtra(EXTRA_QUERY_MESSAGE, query.encode());
+context.sendBroadcast(bbqIntent);
+```
+
+## Structure of a response
+
+A broadcast query response has the following mandatory properties:
+
+- The 64-bit request ID that the response is associated with, copied from the
+  request.
+- The 64-bit response ID unique to this response, copied from the request.
+
+Query responses are also represented as a V2 protocol buffer messages.
+The response copies the request and response IDs from the request message,
+and may include a data-type specific response message, if necessary.
+The absence of a data-type specific response message is generally interpreted
+to mean that the provider is unable to service the request.
+
+The structure of the query response message is therefore as follows:
+
+```protobuf
+message BroadcastQueryResponse {
+  optional sfixed64  requestId             = 1; // required
+  optional sfixed64  responseId            = 2; // required
+  optional bytes     responseMessage       = 3;
+  repeated Parameter additionalParams      = 4;
+}
+```
+
+## Receiving a response
+
+Responses are sent back to the requester in the form of targeted broadcasts.
+The requester dynamically registers a broadcast receiver to capture
+responses. The _ACTION_ for the response is the requested data type with the
+request ID concatenated in zero-padded hex form, e.g.
+"org.openyolo.credential:000000000000CAFE" where "org.openyolo.credential" is
+the requested data type and "000000000000CAFE" is the request ID (51966 in
+decimal).
+
+```java
+IntentFilter filter = new IntentFilter();
+filter.addAction(encodeAction(dataType, requestId));
+filter.addCategory(BBQ_CATEGORY);
+context.registerReceiver(new BroadcastReciever() { ... }, filter);
+```
+
+In order to avoid waiting indefinitely for responses from faulty receivers,
+a timeout should be used, after which absent responses should be treated as
+though the provider was unable to service the request (equivalent to
+responding with no data-type specific message payload).
+
+## Rooted devices
+
+The BBQ protocol relies on the integrity of the Android broadcast system
+(and the `setPackage` mechanism in particular) to guarantee the privacy of the
+messages sent between a requester and a provider. On a rooted device, it is
+potentially possible for a malicious app or system service with root access to
+read these messages, and expose plain-text passwords.
+
+Cryptography provides no additional protection. If an attacker can read the
+private messages sent via the broadcast system, this will typically imply they
+have access to the memory location of the buffers. If ephemeral public-private
+key pairs are used, which don't authenticate either party, a man-in-the-middle
+attack is possible.
+
+There is no trusted third party which can sign keys to
+prove they are associated to a particular app:
+
+- Key pairs cannot be distributed with the app, as they could be easily
+  extracted from the application in advance, or on-demand with
+  root access on the device.
+
+- Keys cannot be dynamically signed by a trusted entity on the device (such as
+  the platform itself, or Google Play Services) as these exchanges
+  would also be susceptible to attack by anything with root access.
+
+As such, we strongly recommend that password manager apps disable the OpenYOLO
+protocol on rooted devices, if they are able to detect this. The option could
+be given to the user to re-enable the feature, with a warning as to the security
+risks of doing this. Generally, rooted devices are very risky to a user's
+security, so warning users of this fact prior to even allowing a password
+manager to be configured is also advisable, as the following attacks are
+also possible:
+
+- Directly reading keys and passwords from the memory space of the password
+  manager or app
+- Scraping the contents of EditText instances for passwords
+- Key-logging the user
+- Injecting code into the process space of the password manager or app
+
+The authors of this specification have no evidence that the kernel modifications
+required to break this protocol exist on real devices, but they are certainly
+feasible. As such, all rooted devices should be treated with suspicion when
+using the BBQ protocol to transport security- or privacy-sensitive data.
+
+[pm-api]: https://developer.android.com/reference/android/content/pm/PackageManager.html "android.content.pm.PackageManager"
+[protobuf]: https://developers.google.com/protocol-buffers
+[reverse-domain]: https://en.wikipedia.org/wiki/Reverse_domain_name_notation
diff --git a/spec/en/openyolo-overview.md b/spec/en/openyolo-overview.md
new file mode 100644
index 0000000..096144e
--- /dev/null
+++ b/spec/en/openyolo-overview.md
@@ -0,0 +1,329 @@
+# OpenYOLO overview
+
+The OpenYOLO protocol defines three core operations to assist with
+authentication in an Android app:
+
+- Retrieving an existing credential: An app can attempt to retrieve a
+  credential to authenticate a user. In most cases, a user can be
+  automatically signed-in using a credential retrieved using OpenYOLO.
+
+- Assisting with sign-up: In the case where no credential can be retrieved
+  by OpenYOLO, a request can be made to a provider to retrieve information
+  that can be used to create a new account, including generating a unique
+  password if required. The entire sign-up process of the app can often be
+  replaced with a single tap when using this API, producing a basic user profile
+  and unique password suitable for use with the application.
+
+- Saving a credential: An app can attempt to save a credential that
+  has been used to successfully authenticate. With user permission, this
+  credential will be saved to the provider of their choice. Saving the
+  credential facilitates future authentication attempts through the retrieve
+  operation, and is particularly useful when the credential provider supports
+  cross-device synchronization.
+
+## High level concepts
+
+Before providing a high level overview of the OpenYOLO operations, some
+terms that will be used throughout the discussion must be defined.
+
+### Credential
+
+A _credential_ is defined in OpenYOLO to be composed of the following
+properties:
+
+- A required _authentication domain_, where the credential can be used.
+
+- A required _authentication method_, which describes how to verify the
+  credential.
+
+- A required _identifier_ which designates a specific account in the context of
+  both the authentication domain and method. Typically, identifiers are
+  email addresses, phone numbers, or some other unique account identifier
+  associated with a federated identity provider.
+
+- An optional _password_, which can be used for password-based authentication
+  methods.
+
+- An optional _display name_, used to assist the user in identifying
+  credentials. Typically, the display name for a credential is the user's
+  real name or chosen alias.
+
+- An optional _display picture_, used to assist the user in visually identifying
+  credentials. Typically, the display picture is a picture of the user, or
+  an avatar that they have chosen or been assigned.
+
+Additional properties can also be optionally specified for a credential,
+however a credential provider is not _required_ to store or return any optional
+values. As such, the existence of these values should not be relied upon by
+apps which consume credentials from OpenYOLO.
+
+A credential is represented in OpenYOLO using a
+[protocol buffer (v2) message][protobuf], defined as follows:
+
+```protobuf
+message Credential {
+    optional string       id                    = 1; // required
+    optional string       authDomain            = 2; // required
+    optional string       authMethod            = 3; // required
+    optional string       displayName           = 4;
+    optional string       displayPictureUri     = 5;
+    optional string       password              = 6;
+    repeated KeyValuePair additionalProps       = 7;
+}
+```
+
+### Credential providers
+
+A _credential provider_ is defined in OpenYOLO to be any application which
+provides the required broadcast receivers and activity intent filters to
+handle all OpenYOLO operations. Credential providers are typically one of
+the following:
+
+- Dedicated apps whose sole purpose is to store and protect credentials a
+  user has chosen to store.
+
+- Browsers which save and form-fill credentials. Many sites have dedicated
+  Android applications which can benefit from retrieving credentials that are
+  already stored in the browser.
+
+- System services such as Smart Lock for Passwords which can store credentials
+  for the user in the absence of other installed alternatives.
+
+While any app can become a credential provider by supporting the
+required OpenYOLO endpoints, only apps for which credential management is a
+clearly declared and visible feature to the user should become credential
+providers. [Protecting users](protecting-users.md) describes these criteria
+in more detail, and the technical counter-measures that are taken to make it
+difficult for inappropriate or malicious apps to be used as credential
+providers.
+
+### Authentication domains
+
+An _authentication domain_ is defined in OpenYOLO to be a scope within
+which a credential is considered to be usable. Authentication domains are
+represented as absolute, hierarchical URIs of form `scheme://authority` -
+no path, query or fragment is permitted.
+
+Two forms of authentication domain are defined for OpenYOLO:
+
+- Android authentication domains, of form `android://FINGERPRINT@PACKAGE` where
+  `PACKAGE` is the package name of an app and `FINGERPRINT` is a
+  Base64, URL-safe encoding of the app's public key (provided by
+  the [Signature][signature-class] type in Android). The fingerprint string
+  includes both the hash used, and the hash data, e.g.
+  `sha512-7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg==`.
+  The two fingerprint hash algorithms officially supported by all OpenYOLO
+  providers are `sha256` and `sha512`.
+
+- Web authentication domains, which match the domain of the site and can have
+  either a http or https scheme (e.g. `https://example.com` and
+  `http://www.example.com` are valid web authentication domains).
+
+A single _authentication system_, which maintains and validates credentials,
+may be represented by multiple distinct authentication domains. For example,
+a credential for `android://...@com.example.app` may be usable on
+`https://example.com` or `https://www.example.com`, when these three entities
+all use the same authentication system.
+However, it is important that `android://HASH-A@com.example.app` and
+`android://HASH-B@com.example.app` should not be treated as equivalent
+_automatically_ - either could represent a compromised, side-loaded variant of
+an app that is attempting to steal user credentials.
+
+An authentication domain _equivalence class_ defines the set of authentication
+domains across which a given credential can be freely shared. Such equivalence
+classes improve the usability of OpenYOLO, but must be carefully defined to
+avoid compromising the security of a user's credentials.
+
+Determining which apps and sites form an equivalence class is the
+responsibility of a credential provider implementation, and need not be
+consistent between credential provider implementations. Google's
+[Digital Asset Links API][asset-links] provides a data source of declared,
+verifiable relationships between apps and sites that can be used to construct
+an authentication domain equivalence class for a given credential.
+The [OpenYOLO SPI](spi-overview.md) will provide utilities to help in using
+the digital asset links API, though credential providers are free to use any
+other data source.
+
+### Authentication method
+
+An _authentication method_ is a mechanism by which a user credential can be
+verified, and is given a unique URI identifier. Any URI of form
+`scheme://authority` can be used to describe an authentication method; OpenYOLO
+defines some standard URIs for the two most common types of authentication
+method:
+
+- Identifier and password based authentication under the direct control of the
+  app, where the identifier and password are non-empty strings composed of
+  printable ASCII characters. The URI for this authentication method is
+  standardized as `openyolo://id-and-password`.
+
+- Federated credentials (e.g. OpenID Connect), where a user identifier is
+  passed to an identity provider (that is typically not controlled by the app).
+  with some supporting information that identifies the app. The URI
+  used to denote authentication with an identity provider is based upon the
+  origin to which federated requests are typically sent for that provider.
+  For example, the URI that should be used for Google Sign-in accounts is
+  `https://accounts.google.com`, while the URI that should be used for
+  Facebook Sign-in accounts is `https://www.facebook.com`. Other common
+  federated identity provider URIs are defined in the OpenYOLO specification.
+  Any authentication mechanism with protocol http or https is assumed to
+  represent an federated identity provider.
+
+## Retrieving credentials
+
+Credential retrieval requests are dispatched using the
+[BBQ protocol](bbq-protocol.md) to all credential providers on the device
+simultaneously. This is particularly useful for users who have more than one
+credential provider, such as Smart Lock for Passwords (present on all devices
+with Google apps), and Dashlane, which the user has chosen to install. Such
+users are often in a state where disjoint sets of credentials are stored in
+each, so querying both increases the chance that a credential can be found.
+
+The BBQ protocol uses [Android broadcast intents][intent-overview] with
+recipients specified by package name in order to asynchronously deliver
+requests and responses. A retrieval request carries the following information:
+
+- A set of authentication domains from which a credential is required.
+
+- The set of authentication mechanisms that are supported by the requester.
+
+It is recommended that an app send a credential request whenever a user would
+typically be required to sign in manually, and _before_ any login UI is shown.
+Some intermediate UI (such as a loading screen) can be displayed while waiting
+for a response. If a credential is available, the entire manual sign-in flow
+can be skipped, resulting in an improved user experience.
+
+Retrieval responses may carry an intent that can be used to retrieve a
+credential from a provider. Providers respond with no intent if they know that
+they do not have a credential for the provider, or if they refuse to service
+the request. Providers _may_ respond with an intent even if they do not know
+that they have a credential available: providers which use a master password
+to encrypt their stores which is not stored to disk may require the user to
+take an action to unlock the store before an accurate answer can be determined.
+
+The OpenYOLO API will return a single intent that can be dispatched with
+[startActivityForResult][intent-results], and returns the selected credential
+data (if any) via `onActivityResult`.
+
+For the specifics of this flow, see
+[Retrieving Credentials](retrieving-credentials.md).
+
+## Assisting sign-up
+
+If no existing credentials can be retrieved from a credential provider,
+then OpenYOLO provides a fall-back mechanism that can be used to help in
+creating a new account. This mechanism will typically allow a new user
+account to be created without the need to manually enter any information.
+
+First, the app must provide a descriptor of the types of credentials that
+it can support. This is done by providing a list of one or more
+supported authentication methods. If password authentication is supported,
+then a _password specification_ can optionally be provided that describes
+the set of passwords that the app supports.
+
+This descriptor can then be sent to a credential provider using the OpenYOLO
+API in order to derive a credential hint. If a default credential provider can
+be determined by the OpenYOLO API, then it will construct an intent to send the
+descriptor to this provider and return it for the app to dispatch when ready.
+Similarly, if only one credential provider is available on the device and it is
+a "known" provider, then an intent to directly interact with that provider will
+be constructed and returned. See [Protecting users](protecting-users.md) for
+details on default and known providers.
+
+If no default provider is found or multiple providers exist, an intent
+is constructed for a dialog that will allow the user to choose a provider,
+after which an intent will be dispatched to that provider containing the
+descriptor.
+
+The flow for creating a credential hint based on the descriptor is under the
+control of the provider, and not part of this specification. A hint constructed
+by the provider is returned to the app via the intent data carried by
+`onActivityResult`.
+
+For more detail on this flow, see [Assisting sign-up](assisting-sign-up.md).
+
+## Saving credentials
+
+When a user successfully authenticates with an app, either manually or via
+the OpenYOLO retrieve or assisted sign-up flows, this credential should be
+saved for future use. Manually saving credentials to a provider is frustrating
+and error-prone - the user must manually switch to the credential provider,
+and follow the provider-specific flow to manually enter their credential again
+for storage, with the possibility of typographical errors.
+
+A significantly better user experience can be provided if the credential can
+be saved in-context, just after it has been verified by an app. OpenYOLO
+provides the mechanism to achieve this.
+
+After a credential has been verified by an app, it should construct a
+representation of the credential to be saved by a credential provider. This
+can then be sent to be stored using the OpenYOLO aPI.
+
+If a preferred credential provider can be determined by the OpenYOLO API, then
+it will construct an intent to send the save request to the provider,
+carrying the plain-text credential data in an intent extra. Similarly, if
+only one credential provider is available on the device and it is a "known"
+provider, the intent to directly interact with that provider will be
+constructed. See [Protecting users](protecting-users.md) for details on
+default and known providers.
+
+If no preferred provider is found, an intent is constructed for a dialog that
+will allow the user to choose a provider, after which an intent will be
+dispatched to that provider containing the credential.
+
+The flow for saving the credential past this point is under the control of
+the provider, and not part of this specification. The outcome of the save
+operation (success or failure) is communicated back to the app via a result
+code to `onActivityResult`.
+
+For more detail on this flow, see [Saving credentials](saving-credentials.md).
+
+## Protecting users from malicious providers
+
+Given the sensitive nature of the data being exchanged by OpenYOLO, the protocol
+will become an obvious target for attackers. A probable attack will be for
+malicious apps to register themselves as credential providers, and attempt to
+trick users into providing credentials. Distinguishing legitimate credential
+provider apps from malicious apps is therefore an important aspect of building
+trust in the protocol, for both app developers and users.
+
+In order to achieve this, a "known provider" list will be hosted by the
+OpenID Foundation. A static version of this list is included in the OpenYOLO
+API, and is automatically updated by client library when necessary.
+
+An "unknown" provider will still be usable via the protocol. Prior to any
+interaction with an unknown provider, a dialog will be displayed
+warning the user that this provider is unknown, and that they should only
+proceed if they trust the provider. "Known" providers will not have this
+restriction.
+
+Additionally, on devices with Google Play Services, further protections can
+be offered. Play Services will provide a secure host for user preferences
+on the majority of Android devices. A new API for Google Play Services is
+proposed that will:
+
+- Specify which providers are enabled. This will require that providers
+  explicitly "opt-in" by directing the user to a settings page to enable
+  the provider, typically after installing the provider. Many credential
+  providers already include such a flow in order to enable themselves as an
+  "accessibility service" in order to perform form-fill.
+
+  If a provider is not on this explicit whitelist, the OpenYOLO API
+  will not even attempt to communicate with it. This protects the user in a much
+  more direct way, avoiding the possibility of a user accidentally interacting
+  with a provider.
+
+- Specify a "default" provider. This is the provider that will be automatically
+  used for save requests and hint requests, removing the need to show a
+  "provider picker" dialog prior to these operations.
+
+Technical information on the known provider list and the Play Services API
+can be found in the chapter on [protecting users](protecting-users.md).
+
+
+[asset-links]: https://developers.google.com/digital-asset-links/
+[cancel-result]: https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED
+[intent-results]: https://developer.android.com/training/basics/intents/result.html
+[intent-overview]: https://developer.android.com/guide/components/intents-filters.html
+[protobuf]: https://developers.google.com/protocol-buffers
+[signature-class]: https://developer.android.com/reference/android/content/pm/Signature.html
diff --git a/spec/en/protecting-users.md b/spec/en/protecting-users.md
new file mode 100644
index 0000000..e65caec
--- /dev/null
+++ b/spec/en/protecting-users.md
@@ -0,0 +1,236 @@
+# Protecting users from malicious providers
+
+OpenYOLO offers a novel mechanism for direct credential exchange between apps
+and credential providers, which can dramatically simplify the sign-in and
+sign-up experience. User understanding of the feature, and in particular its
+security implications, will also be low. It is therefore important that
+technical measures are taken to prevent the user from inadvertently compromising
+the security of their credentials.
+
+Two mechanisms are proposed in order to achieve this:
+
+- A known provider list, which can be utilized by the client library in order
+  to warn a user before it interacts with an unknown provider. This will work
+  on any Android device.
+- A supporting Google Play Services API, which will store an explicit
+  whitelist of providers that the user has selected, and their "default"
+  provider for the save and hint flows. This will only work on devices with
+  Google Play Services - the majority, but not all, Android devices. The API
+  is therefore designed to provide additional security when available, but not
+  to be essential to the functioning of OpenYOLO.
+
+## The known provider list
+
+The "known provider" list will be retrievable from
+(*TODO: URL TO BE DETERMINED*), and served from infrastructure
+controlled by the OpenID Foundation. This resource has mime-type
+"application/json", is UTF-8 encoded, and contains a list of JSON objects that
+describe each provider via the following properties:
+
+- "name": The canonical, human-readable name of the provider (e.g.
+  "Smart Lock for Passwords")
+- "package-identifiers": a list of one or more strings in the format used for
+  authentication domains, that identifies the legitimate app package name(s)
+  and signature(s) for this provider. For instance, a provider may have multiple
+  signatures due to key rotation, and multiple package names if they release
+  "beta" / "alpha" channels of their app under different package names, to
+  allow concurrent installation.
+- "store-link": a canonical link for the app. It must be possible for the
+  maintainers of the known app list to verify the app's signature using this
+  link. Google Play Store links are preferred, but other stores may be
+  referenced for apps that are targeted at specific demographics
+  (e.g. the Chinese market).
+
+For example, such a list may look like:
+
+```json
+[
+  {
+    "name": "Firefox",
+    "package-identifiers": [
+      "android://sha256-2gCe6pR_AO_Q2Vu8Iep-4AsiKNnUHQxu0FaDHO_qa178GByKybdT_BuE8_dYk99G5Uvx_gdONXAOO2EaXidpVQ==@org.mozilla.firefox",
+      "android://sha256-2gCe6pR_AO_Q2Vu8Iep-4AsiKNnUHQxu0FaDHO_qa178GByKybdT_BuE8_dYk99G5Uvx_gdONXAOO2EaXidpVQ==@org.mozilla.firefox_beta"
+    ],
+    "store-link": "https://play.google.com/store/apps/details?id=org.mozilla.firefox"
+  },
+  //
+  // ...
+  //
+  {
+    "name": "LastPass",
+    "package-identifiers": [
+      "android://sha256-d5XXKGMGcVvMZ7bw3-Aotgq035ClbqO7RwDQG7x6P7ofwLxW42VRYL8jScbFfyW7hLyXYZEmrPrPsYqkJfDeNQ==@com.lastpass.lpandroid"
+    ],
+    "store-link": "https://www.amazon.com/dp/B005V2S7FW",
+  },
+  {
+    "name": "Smart Lock for Passwords",
+    "package-identifiers": [
+      "android://sha256-7fmduHKTdHHrlMvldlEqAIlSfii1tl35bxj1OXN5Ve8c4lU6URVu4xtSHc3BVZxS6WWJnxMDhIfQN0N0K2NDJg==@com.google.android.gms"
+    ],
+    "store-link": "https://play.google.com/store/apps/details?id=com.google.android.gms",
+  },
+]
+```
+
+### Inclusion and exclusion criteria
+
+The criteria for an provider to be included in the known list are as follows:
+
+- The app must be published on at least one major app store, as determined by
+  the OpenYOLO repository owners.
+- The app must clearly be a credential provider of some form: either a
+  dedicated app, or an app that clearly states its ability to store passwords
+  (browsers typically fall into this category).
+- A point of contact (email) must be designated for the app for notification
+  of security issues, and acknowledgment of security issues via this address
+  must occur in a timely manner (e.g. 1 business day for critical issues).
+
+Only "production" package identifiers will be permitted in the list: apps
+compiled with debug keys or those that are not published in a manner accessible
+to end users will not be included.
+
+An app may be removed from the list for the following reasons:
+
+- An actively exploited security issue with high user impact is discovered.
+- If an adequate plan to fix a lower impact security issue is not sent in
+  response to a query via the point of contact in a timely manner (e.g.
+  10 business days).
+- If a plan to fix a security issue is not adhered to, leaving an app
+  exploitable with no steps towards resolution.
+
+Examples of security issues with high user impact are:
+
+- The provider does not correctly construct an authentication domain equivalence
+  class, resulting in one or more apps being able to retrieve credentials to
+  which they should not have access.
+- An exploit exists allowing an app to corrupt the provider data store
+  with a save credential request, resulting in loss of user credential data.
+- A code injection attack on a provider from data sent via the OpenYOLO
+  protocol.
+
+A provider will be reinstated to the known provider list after critical issues
+are resolved and the updated app has been available in app stores long enough
+for most user devices to have updated.
+
+To submit your application for inclusion in the known provider list, an issue
+must be opened on the OpenYOLO repository.
+
+## The Google Play Services "credentialproviders" API
+
+*NOTE*: The API described in this section is a proposal, that may or may not
+be implemented in this form or at all.
+
+The BBQ and OpenYOLO protocols are designed to work without the need for a
+"trusted" intermediary, allowing it to work on any Android device.
+A trusted intermediary would, however, be very useful in providing additional
+protection against attackers. Similar to root certificate authorities for
+transport layer security, a mutually trusted party allows otherwise
+independent entities to establish mutual trust.
+
+Most Android devices at API level 9 and above have the suite of Google apps
+installed, including Google Play Services, which provides developer APIs
+independently of the base platform. Google Play Services is a viable candidate
+for a trusted intermediary for OpenYOLO, providing security benefits
+for the OpenYOLO API when available.
+
+A "credentialproviders" support API is proposed that will provide the following
+functionality:
+
+```java
+package com.google.android.gms.auth.credentialproviders;
+
+import com.google.android.gms.tasks.Task;
+
+public interface CredentialProvidersApi {
+
+  /**
+   * Provides the (potentially empty) list of credential providers that the
+   * user has selected.
+   * Each provider is identified by a URI of form
+   * {@code android://SIGNATURE@PACKAGE}, where:
+   *
+   * <ul>
+   * <li>
+   * {@code SIGNATURE} is a url-safe Base64 encoding of the SHA-512 hash of the
+   * {@link Signature} object associated with the app.
+   * </li>
+   * <li>
+   * {@code PACKAGE} is the package name of the app.
+   * </li>
+   */
+  Task<List<String>> getProviders();
+
+
+  /**
+   * Provides the user's default credential provider, if defined. The provider
+   * is identified by a URI of form {@code android://SIGNATURE@PACKAGE}, where:
+   *
+   * <ul>
+   * <li>
+   * {@code SIGNATURE} is a url-safe Base64 encoding of the SHA-512 hash of the
+   * {@link Signature} object associated with the app.
+   * </li>
+   * <li>
+   * {@code PACKAGE} is the package name of the app.
+   * </li>
+   */
+  Task<String> getDefaultProvider();
+
+  /**
+   * Provides an {@link Intent} for launching the credential provider settings
+   * activity, that allows the user to whitelist credential providers for
+   * use on the device.
+   */
+  Intent getSettingsIntent();
+}
+
+public final class CredentialProviders implements CredentialProvidersApi {
+  public static CredentialProviders getInstance();
+  // ... implementation of CredentialProvidersApi methods ...
+}
+```
+
+This API will be used by the OpenYOLO client library to:
+
+- Ensure that the library does not interact with credential providers they have
+  not explicitly selected (as returned by `getProviders()`).
+
+- Interact with only the user's default credential provider for save and
+  hint requests.
+
+It is recommended that providers direct the user to the settings activity at
+some point during the setup flow, immediately after installation.
+This is a common occurrence in providers already to enable the provider as an
+`accessibility provider` in order to perform form-fill in apps. Our hope is that
+over time, and with additional platform support, launching the credential
+provider settings activity will be the system configuration step that a
+credential provider will need to do in order to fully integrate their
+functionality into the platform.
+
+The selection of providers available to the user in the settings activity will
+be populated by all apps found on the device that provide broadcast receivers
+and activity intent filters for the OpenYOLO operations. The known provider list
+will be used to annotate these entries with "known" / "unknown" as appropriate
+and to warn the user if they enable an unknown provider.
+
+One may wonder why the API does not provide methods allowing a provider to
+request that they be added to the whitelist, or be set as the
+default credential provider, rather than launching a general settings activity.
+Such an API would likely be implemented by showing a dialog to the user stating
+"Would you like to add X as a credential provider?" with some
+explanatory text and "YES"/"NO" options. The risk with such a presentation is
+that users often don't read or understand the implications of such a prompt,
+and will press the button that most obviously looks like the default action
+of the dialog. This is particularly risky for a credential provider list, as
+an app can trick a user into agreeing to this prompt by manipulating the
+context in which it is shown. For example, a malicious app masquerading as a
+game could present a screen prior to launching the dialog stating "agree to
+the following prompt to disable ads" and users will likely click through any
+sequence of actions for this. Warnings about unknown providers would likely
+be similarly ignored.
+
+It is therefore preferable to launch a full-screen dialog which does not have
+an obvious "default" action to continue: the user must at least process the
+contents of the screen, increasing the chance that they will realize they are
+being put at risk by a malicious app.
diff --git a/spec/en/retrieving-credentials.md b/spec/en/retrieving-credentials.md
new file mode 100644
index 0000000..456a5d7
--- /dev/null
+++ b/spec/en/retrieving-credentials.md
@@ -0,0 +1,76 @@
+# Retrieving credentials
+
+NOTE: writing this chapter is *in progress*.
+
+## Credential
+
+## Retrieve request messages
+
+```protobuf
+message FindRequest {
+    repeated string       authDomains        = 1; // at least one required
+    repeated string       authMethods        = 2; // at least one required
+    repeated KeyValuePair additionalParams   = 3;
+}
+```
+
+The set of authentication domains specified in the request _may_ be disjoint
+from the set of domains known to be related to the requester (via its package
+name): such requests would allow trusted intermediaries (e.g. keyboard apps,
+mail clients, etc.) to request credentials that they do not directly own.
+It is the responsibility of the credential provider to determine whether to
+permit such requests. Typically, requests should only be permitted for
+an authentication domain that is provably associated with to the requester,
+or if the app has been explicitly whitelisted (by the user or provider) to
+request credentials outside its equivalence class.
+
+## Retrieve response messages
+
+```protobuf
+message FindResponse {
+    optional bytes        retrieveIntent   = 1; // required
+    repeated KeyValuePair additionalParams = 2;
+}
+```
+
+Providers indicate whether they may be able to provide a credential to the
+requester by responding with a message that optionally contains an activity
+[Intent][intent-class]
+to retrieve the credential. The absence of an intent in the response indicates
+that the provider knows that it does not have an available credential, or is
+refusing to serve the request.
+
+An activity intent is used for the final stage of retrieving the request to
+allow the credential provider to interact with the user in some way before
+releasing the credential. Many credential providers will require an unlock code
+(a PIN number, password or recognized fingerprint) in order to decrypt and
+release the credential, or may simply wish to notify the user that the
+credential is being released to avoid surprising the user.
+
+If the requester receives more than one Intent-carrying response, the user
+should be prompted to choose between the available options. If no
+intent-carrying responses are received, then the requester should proceed to
+a manual sign-in.
+
+## Retrieve intent responses
+
+The intent should be dispatched using [startActivityForResult][intent-results],
+allowing the response to be delivered to via `onActivityResult`. The provider
+can describe two outcomes to this process:
+
+- The operation was canceled (indicated by
+  [ACTIVITY_CANCELED][result-canceled]). This can occur as a result of the user
+  failing to enter their unlock code correctly, or explicitly canceling the
+  flow.
+- The operation succeeded (indicated by [ACTIVITY_OK][result-ok]), and a
+  credential is carried in the response. The credential is encrypted using the
+  shared secret established by the BBQ protocol.
+
+When provided with a credential, the application should immediately attempt to
+use this credential, and should do so without requiring any additional user
+input (e.g. pressing a "sign in" button).
+
+[intent-class]: https://developer.android.com/reference/android/content/Intent.html
+[intent-results]: https://developer.android.com/training/basics/intents/result.html
+[result-canceled]: https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED
+[result-ok]: https://developer.android.com/reference/android/app/Activity.html#RESULT_OK
diff --git a/spec/en/saving-credentials.md b/spec/en/saving-credentials.md
new file mode 100644
index 0000000..95a5d82
--- /dev/null
+++ b/spec/en/saving-credentials.md
@@ -0,0 +1,109 @@
+# Saving credentials
+
+After successfully authenticating a user, it is recommended that an app always
+attempt to save this known-good credential using OpenYOLO. First, the
+system must be queried to determine which providers are able to save the
+credential. This is a simple [Package Manager][pm-api] API call to find
+activities with action `org.openyolo.save` and category `org.openyolo`.
+
+It is anticipated that some credential providers will only be able to store
+id-and-password based credentials, while others may support federated
+credentials. Such providers can be distinguished by requiring that providers
+declare their supported set of authentication methods via an intent filter,
+with a data URI filter based on the authentication method URI.
+
+For a credential provider which only supports id-and-password based credentials,
+this would look as follows:
+
+```xml
+<activity
+    android:name="com.example.provider.SaveCredentialActivity"
+    android:theme="@style/AppTheme.Dialog"
+    android:exported="true"
+    android:excludeFromRecents="true">
+  <intent-filter>
+    <action android:name="org.openyolo.save"/>
+    <category android:name="org.openyolo" />
+    <!--
+    as this app only supports saving ID and password based credentials, this is
+    declared using a data filter.
+    -->
+    <data
+        android:scheme="openyolo"
+        android:host="id-and-password" />
+  </intent-filter>
+</activity>
+```
+
+If a provider supports saving credentials for multiple authentication methods,
+then multiple data filters can be specified. If the data filter is omitted,
+this indicates the provider supports saving all credentials, regardless of
+authentication type.
+
+Given a credential object to be saved, the system can be queried to
+find all password managers which support saving this credential:
+
+```java
+Intent saveIntent = new Intent("org.openyolo.save");
+saveIntent.addCategory("org.openyolo");
+
+// set the authentication type as a data parameter
+saveIntent.setData(Uri.parse("openyolo://id-and-password"));
+
+List<ResolveInfo> supportingProviders =
+    getPackageManager().queryIntentActivities(saveIntent, 0);
+```
+
+This list should be presented to the user, in order to allow them to select
+which provider they wish to save the credential to.
+
+## Filtering the provider list
+
+The list of credential providers returned by querying the package manager
+may include unsafe options - it is important to further filter this list based
+on the following criteria:
+
+1. If the user has a preferred credential provider defined in the Google Play
+   Services managed settings, and this credential provider
+   is in the list, it should be used directly.
+
+1. If the user has a whitelist of credential providers defined in the
+   Google Play Services managed settings, the dialog presented to the user
+   for save should be restricted to these options.
+
+1. If Google Play Services is unavailable, all options should be displayed
+   such that known providers are clearly distinguished from unknown providers.
+   Selecting an unknown provider should require a second confirmation, to avoid
+   the user accidentally interacting with an unknown provider by tapping on the
+   wrong area of the screen.
+
+[Protecting the user from malicious providers](protecting-users.md) provides
+more information on how the Google Play Services settings and the known
+providers list are defined.
+
+## Behavior of the save intent
+
+The behavior of the activity or activities that implement the save flow
+is beyond the scope of this specification. However,. if a saved credential
+matches an existing credential by identifier and authentication method, and
+authentication domain, the credential provider should allow this to be
+automatically saved where possible. This will allow apps to easily update
+credentials in response to password change events.
+
+To mitigate potential attempts to spoof a credential provider's UI, it is
+also recommended that a method of pushing the request to a full screen version
+of the provider is made available. This will allow security-conscious users
+to determine that it is really the credential provider they are interacting
+with, and not some attempt to phish their master password.
+
+## Save response
+
+The save response, returned to the app via `onActivityResult`, can be one of
+two values:
+
+1. `RESULT_OK`, if the credential is successfully saved.
+2. `RESULT_CANCELLED`, if the credential was not saved for any reason. No
+   further details need to be provided to the calling application, as the
+   application is unlikely to be able to take any remedial action.
+
+[pm-api]: https://developer.android.com/reference/android/content/pm/PackageManager.html "android.content.pm.PackageManager"
diff --git a/spec/en/spi-overview.md b/spec/en/spi-overview.md
new file mode 100644
index 0000000..40783df
--- /dev/null
+++ b/spec/en/spi-overview.md
@@ -0,0 +1,4 @@
+# OpenYOLO SPI
+
+The details of OpenYOLO SPI are not yet formally defined. See the reference
+implementation for current progress.
diff --git a/spi/AndroidManifest.xml b/spi/AndroidManifest.xml
new file mode 100644
index 0000000..67d2d97
--- /dev/null
+++ b/spi/AndroidManifest.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.openyolo.spi">
+
+</manifest>
diff --git a/spi/build.gradle b/spi/build.gradle
new file mode 100644
index 0000000..980a22b
--- /dev/null
+++ b/spi/build.gradle
@@ -0,0 +1,21 @@
+apply plugin: 'com.android.library'
+apply from:'../config/android-common.gradle'
+
+android {
+    defaultConfig {
+        project.archivesBaseName = 'openyolo-spi'
+        consumerProguardFiles 'proguard-rules.txt'
+    }
+}
+
+
+dependencies {
+    compile project(':api')
+    compile "com.android.support:support-annotations:${rootProject.supportLibVersion}"
+    compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
+    apply from:'../config/testdeps.gradle', to:it
+}
+
+apply from: '../config/style.gradle'
+apply from: '../config/coverage.gradle'
+apply from: '../config/javadoc.gradle'
diff --git a/spi/java/org/openyolo/spi/AssetStatementsUtil.java b/spi/java/org/openyolo/spi/AssetStatementsUtil.java
new file mode 100644
index 0000000..42d92d4
--- /dev/null
+++ b/spi/java/org/openyolo/spi/AssetStatementsUtil.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.support.annotation.Nullable;
+import android.util.Log;
+
+/**
+ * Utility methods for retrieving an app's asset statements.
+ */
+public final class AssetStatementsUtil {
+    private static final String ASSET_STATEMENTS = "asset_statements";
+    private static final String TAG = "AssetStatementsUtil";
+
+    private AssetStatementsUtil() {
+        throw new AssertionError(); // so this class isn't instantiated
+    }
+
+    /**
+     * Get the <code>asset_statements</code> from the meta-data of specified app package.
+     *
+     * @param context     Context
+     * @param packageName Package name of the app from which the asset_statements should be
+     *                    retrieved
+     * @return The asset_statements string or null if not found
+     */
+    @Nullable
+    public static String getAssetStatements(final Context context,
+                                            final String packageName) {
+        ApplicationInfo applicationInfo;
+        try {
+            applicationInfo = context.getPackageManager().getApplicationInfo(packageName,
+                    PackageManager.GET_META_DATA);
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.w(TAG, "Unable to find application info for package "
+                    + packageName);
+            return null;
+        }
+
+        if (applicationInfo.metaData == null
+                || !applicationInfo.metaData.containsKey(ASSET_STATEMENTS)) {
+            return null;
+        }
+
+        Resources resources;
+        try {
+            resources = context.getPackageManager().getResourcesForApplication(applicationInfo);
+        } catch (PackageManager.NameNotFoundException e) {
+            return null;
+        }
+
+        return resources.getString(applicationInfo.metaData.getInt(ASSET_STATEMENTS));
+    }
+}
diff --git a/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
new file mode 100644
index 0000000..ac9eaf6
--- /dev/null
+++ b/spi/java/org/openyolo/spi/BaseCredentialQueryReceiver.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.util.Log;
+import com.google.bbq.BaseBroadcastQueryReceiver;
+import com.google.bbq.QueryResponseSender;
+import com.google.bbq.proto.BroadcastQuery;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.RetrieveRequest;
+import org.openyolo.proto.CredentialRetrieveRequest;
+
+/**
+ * Partial implementation of an OpenYOLO request receiver, that should be extended by providers.
+ * This implementation handles some basic validation and decoding of the request before
+ * handing the request to
+ * {@link #processCredentialRequest(Context, BroadcastQuery, RetrieveRequest, Set)}.
+ */
+public abstract class BaseCredentialQueryReceiver extends BaseBroadcastQueryReceiver {
+
+    /**
+     * Creates a receiver that will log errors to the specified log tag.
+     */
+    public BaseCredentialQueryReceiver(String logTag) {
+        super(logTag);
+    }
+
+    @Override
+    protected void processQuery(@NonNull Context context, @NonNull BroadcastQuery query) {
+        CredentialRetrieveRequest requestProto;
+        try {
+            requestProto = CredentialRetrieveRequest.ADAPTER.decode(query.queryMessage);
+        } catch (NullPointerException | IOException ex) {
+            Log.w(mLogTag, "Failed to parse credential request message", ex);
+            new QueryResponseSender(context).sendResponse(query, null);
+            return;
+        }
+
+        RetrieveRequest request;
+        try {
+            request = new RetrieveRequest.Builder(requestProto).build();
+        } catch (NullPointerException | IllegalArgumentException ex) {
+            // respond with no result
+            Log.w(mLogTag, "Credential request message failed field validation", ex);
+            new QueryResponseSender(context).sendResponse(query, null);
+            return;
+        }
+
+        // TODO: validate claimed authentication domains
+        Set<AuthenticationDomain> requestorDomains =
+                new HashSet<>(AuthenticationDomain.listForPackage(context, query.requestingApp));
+
+        processCredentialRequest(context, query, request, requestorDomains);
+    }
+
+    protected abstract void processCredentialRequest(
+            @NonNull Context context,
+            @NonNull BroadcastQuery query,
+            @NonNull RetrieveRequest request,
+            @NonNull Set<AuthenticationDomain> requestorDomains);
+}
diff --git a/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
new file mode 100644
index 0000000..6ad612b
--- /dev/null
+++ b/spi/java/org/openyolo/spi/RetrieveIntentResultUtil.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi;
+
+import android.content.Intent;
+import android.support.annotation.Nullable;
+import org.openyolo.api.CredentialClient;
+import org.openyolo.proto.Credential;
+
+/**
+ * Utility methods for expressing and manipulating the result of a credential retrieve intent.
+ */
+public final class RetrieveIntentResultUtil {
+
+    /**
+     * Creates an {@link android.content.Intent} wrapper for the result of a credential retrieve
+     * intent.
+     */
+    public static Intent createResponseData(@Nullable Credential credential) {
+        Intent responseData = new Intent();
+        if (credential != null) {
+            responseData.putExtra(CredentialClient.EXTRA_CREDENTIAL, credential.encode());
+        }
+        return responseData;
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java b/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
new file mode 100644
index 0000000..e61c54c
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/AssetRelationshipHelper.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.spi.assetlinks.data.AndroidAssetStatement;
+import org.openyolo.spi.assetlinks.data.AssetStatement;
+
+/**
+ * <p>
+ * This class loads the {@link org.openyolo.api.AuthenticationDomain}s for the 'source'
+ * (client) and 'target' asset statements and finds the ones that are bidirectional.  That is,
+ * where the source and target apps grant the same relations to each other.
+ * </p>
+ *
+ * <p>Example for looking-up bidirectional relationships:</p>
+ *
+ * <pre>
+ * {@code
+ *
+ * private void loadRelatedAuthDomains(Context context, String requestedAppPackage) {
+ *      // get the asset statements for the requesting/client app
+ *      List<AssetStatement> sourceAssetStatements = getSourceAssetStatements
+ *               (context, requestedAppPackage);
+ *
+ *      TargetAssetStatementLoader assetStatementLoader = new
+ *               TargetAssetStatementLoader(context, sourceAssetStatements);
+ *
+ *      // get all 'related' target asset statements - those referenced in the client app's
+ *      // asset statements
+ *      List<AssetStatement> targetAssetStatements = assetStatementLoader
+ *               .getRelatedAssetStatements();
+ *
+ *      AssetRelationshipHelper assetRelationshipHelper = new
+ *               AssetRelationshipHelper(context, requestedAppPackage, sourceAssetStatements,
+ *                targetAssetStatements);
+ *
+ *      List<AuthenticationDomain> bidirectionalAuthDomains =
+ *               assetRelationshipHelper.getBidirectionalAuthDomains();
+ * }
+ *
+ * private List<AssetStatement> getSourceAssetStatements(Context context, String packageName) {
+ *      String clientAssetStatements = AssetStatementsUtil.getAssetStatements(context,
+ *               packageName);
+ *      return parseAssetStatementsJson(clientAssetStatements);
+ * }
+ *
+ * private List<AssetStatement> parseAssetStatementsJson(String json) {
+ *      return AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+ * }
+ *}
+ * </pre>
+ */
+public class AssetRelationshipHelper {
+    private static final String TAG = "AssetRelationshipHelper";
+
+    private final Context mContext;
+    private final String mClientPackageName;
+    private final List<AssetStatement> mSourceAssetStatements;
+    private final List<AssetStatement> mTargetAssetStatements;
+
+    /**
+     * Setup the helper and validate the input params.
+     *
+     * @param context Context
+     * @param clientPackageName The client app's package name
+     * @param sourceAssetStatements Asset statements from the 'source' (client) app
+     * @param targetAssetStatements Asset statements from the various 'targets' referenced by the
+     *     'source' (client) app
+     */
+    public AssetRelationshipHelper(@NonNull Context context, @NonNull String clientPackageName,
+                @NonNull List<AssetStatement> sourceAssetStatements, @NonNull List<AssetStatement>
+                targetAssetStatements) {
+
+        require(context, notNullValue());
+        require(!TextUtils.isEmpty(clientPackageName), "mClientPackageName must not be null or "
+                    + "empty");
+        require(sourceAssetStatements, notNullValue());
+        require(targetAssetStatements, notNullValue());
+
+        this.mContext = context.getApplicationContext();
+        this.mClientPackageName = clientPackageName;
+        this.mSourceAssetStatements = sourceAssetStatements;
+        this.mTargetAssetStatements = targetAssetStatements;
+    }
+
+    /**
+     * <p>
+     * Load the asset statements for the client app.  Load the asset statements for each Android
+     * 'target' in the client app's asset statements.  Return the of
+     * {@link org.openyolo.api.AuthenticationDomain}s that have bidirectional relationships with
+     * the client app.
+     * </p>
+     * <p>
+     * Note, this currently only supports Android 'target' asset statements.
+     * </p>
+     *
+     * @return Authentication domains that have a bidirectional relationship with the client
+     *     Android app
+     */
+    public List<AuthenticationDomain> getBidirectionalAuthDomains() {
+        if (mSourceAssetStatements.isEmpty() || mTargetAssetStatements.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        final List<AuthenticationDomain> bidirectionalAuthDomains = new ArrayList<>();
+
+        bidirectionalAuthDomains.addAll(getBidirectionalAuthDomains
+                    (getTargetAndroidAssetStatements()));
+
+        // TODO load authentication domains for web targets
+
+        return bidirectionalAuthDomains;
+    }
+
+    private List<AuthenticationDomain> getBidirectionalAuthDomains(
+                final List<AndroidAssetStatement> androidAssetStmts) {
+        final List<AuthenticationDomain> authDomains = new ArrayList<>();
+        for (AndroidAssetStatement androidAssetStmt : androidAssetStmts) {
+            authDomains.addAll(getBidirectionalAuthDomains(androidAssetStmt));
+        }
+        // TODO remove before released
+        Log.d(TAG, "Android bidirectional auth domains: " + authDomains);
+        return authDomains;
+    }
+
+    /**
+     * Filter out any authentication domains from the target apps that aren't in the requestor
+     * domains, leaving us with the authentication domains that have bidirectional
+     * credential sharing relationships.
+     *
+     * @param targetAssetStatement Asset statement of the 'target' app
+     */
+    private List<AuthenticationDomain> getBidirectionalAuthDomains(final AndroidAssetStatement
+                targetAssetStatement) {
+
+        // get the AuthenticationDomains for the source (client) app
+        final List<AuthenticationDomain> sourceAuthDomains = createAuthDomains(
+                    mClientPackageName);
+
+        // get the AuthenticationDomains for app identified in the (target) android asset statement
+        final List<AuthenticationDomain> targetAuthDomains = createAuthDomains(
+                    targetAssetStatement);
+
+        // filter out of the 'target' auth domains any AuthenticationDomains not in the
+        // 'source' auth domains
+        targetAuthDomains.retainAll(sourceAuthDomains);
+
+        // TODO remove before released
+        Log.d(TAG, "bidirectional auth domains for target pkg '" + mClientPackageName + "' and "
+                    + "source pkg '" + targetAssetStatement.getTarget().getPackageName() + "': "
+                    + targetAuthDomains);
+
+        return targetAuthDomains;
+    }
+
+    /**
+     * Returns a list of all the {@link org.openyolo.spi.assetlinks.data.AndroidAssetStatement}s in
+     * {@link #mTargetAssetStatements}.
+     */
+    private List<AndroidAssetStatement> getTargetAndroidAssetStatements() {
+        List<AndroidAssetStatement> androidAssetStatements = new ArrayList<>();
+        for (AssetStatement assetStatement : mTargetAssetStatements) {
+            if (assetStatement instanceof AndroidAssetStatement) {
+                androidAssetStatements.add((AndroidAssetStatement) assetStatement);
+            }
+        }
+        return androidAssetStatements;
+    }
+
+    private List<AuthenticationDomain> createAuthDomains(
+                final AndroidAssetStatement androidAssetStatement) {
+        return createAuthDomains(androidAssetStatement.getTarget().getPackageName());
+    }
+
+    private List<AuthenticationDomain> createAuthDomains(
+                final String packageName) {
+        return AuthenticationDomain.listForPackage(mContext, packageName);
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java
new file mode 100644
index 0000000..90e2a32
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatement.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+
+import java.util.List;
+
+/**
+ * Java representation of an asset statement for an Android app.
+ */
+public class AndroidAssetStatement implements AssetStatement {
+    private static final int PRIME = 31;
+    private final List<RelationType> mRelations;
+    private final AndroidTarget mTarget;
+
+    private AndroidAssetStatement(Builder builder) {
+        this.mRelations = builder.mRelations;
+        this.mTarget = builder.mTarget;
+    }
+
+    /**
+     * Get the list of asset statement relations.
+     *
+     * @return Asset statement relations
+     */
+    @Override
+    public List<RelationType> getRelations() {
+        return mRelations;
+    }
+
+    /**
+     * Get the asset statement target app descriptor.
+     *
+     * @return Asset statement target app descriptor
+     */
+    public AndroidTarget getTarget() {
+        return mTarget;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+
+        AndroidAssetStatement that = (AndroidAssetStatement) obj;
+
+        if (!mRelations.equals(that.mRelations)) {
+            return false;
+        }
+        return mTarget.equals(that.mTarget);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = mRelations.hashCode();
+        result = PRIME * result + mTarget.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("AndroidAssetStatement{");
+        sb.append("mRelations=").append(mRelations);
+        sb.append(", mTarget=").append(mTarget);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    /**
+     * Builder for creating a {@link AndroidAssetStatement.Builder}.
+     */
+    public static final class Builder {
+        private List<RelationType> mRelations;
+        private AndroidTarget mTarget;
+
+        /**
+         * Relations, for a Digital Asset Link.
+         *
+         * @param relations List of relations
+         * @return The Builder
+         */
+        public Builder relations(@NonNull List<RelationType> relations) {
+            this.mRelations = relations;
+            return this;
+        }
+
+        /**
+         * The Android target (asset descriptor).
+         *
+         * @param target Android asset descriptor
+         * @return The Builder
+         */
+        public Builder target(@NonNull AndroidTarget target) {
+            this.mTarget = target;
+            return this;
+        }
+
+        /**
+         * Generate a {@link AndroidAssetStatement}.
+         *
+         * @return The {@link AndroidAssetStatement}
+         */
+        public AndroidAssetStatement build() {
+            require(this.mRelations, notNullValue());
+            require(this.mTarget, notNullValue());
+            return new AndroidAssetStatement(this);
+        }
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java
new file mode 100644
index 0000000..14d20ae
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializer.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.spi.assetlinks.data.DeserializerUtil.getRelations;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Deserializer for converting JSON into a list of {@link AndroidAssetStatement}.
+ */
+public class AndroidAssetStatementDeserializer implements Deserializer<AndroidAssetStatement> {
+    private static final String TAG = "AndroidAssetStatementDe";
+
+    @Override
+    public List<AndroidAssetStatement> deserialize(@NonNull final JSONObject assetStatementJson) {
+        require(assetStatementJson, notNullValue());
+        if (!isAndroidAssetStatement(assetStatementJson)) {
+            Log.e(TAG, "not a web asset statement");
+            return Collections.emptyList();
+        }
+        return buildAndroidAssetStatements(assetStatementJson);
+    }
+
+    private List<AndroidAssetStatement> buildAndroidAssetStatements(final JSONObject
+                assetStatementJson) {
+        List<AndroidAssetStatement> assetStatements = new ArrayList<>();
+
+        JSONObject target = assetStatementJson.optJSONObject("target");
+        if (target == null) {
+            Log.e(TAG, "'target' property not found");
+            return Collections.emptyList();
+        }
+
+        JSONArray sha256CertFingerprints = target.optJSONArray("sha256_cert_fingerprints");
+        if (sha256CertFingerprints == null) {
+            Log.e(TAG, "'sha256_cert_fingerprints' property not found");
+            return Collections.emptyList();
+        }
+
+        List<RelationType> relationTypes = getRelations(assetStatementJson);
+        if (relationTypes.isEmpty()) {
+            Log.e(TAG, "no asset statement relations found");
+            return Collections.emptyList(); // asset statement is useless without relations
+        }
+
+        // creating a separate AndroidTarget for each cert fingerprint
+        for (int i = 0; i < sha256CertFingerprints.length(); i++) {
+            AndroidTarget androidTarget = buildAndroidTarget(target, sha256CertFingerprints
+                        .optString(i));
+
+            if (androidTarget == null) {
+                Log.e(TAG, "unable to create valid android target");
+                continue;
+            }
+
+            final AndroidAssetStatement assetStatement = new AndroidAssetStatement.Builder()
+                        .relations(relationTypes)
+                        .target(androidTarget)
+                        .build();
+
+            assetStatements.add(assetStatement);
+        }
+        return assetStatements;
+    }
+
+    private AndroidTarget buildAndroidTarget(final JSONObject target, final String fingerprint) {
+        String packageName = target.optString("package_name");
+        if (TextUtils.isEmpty(packageName)) {
+            Log.e(TAG, "package name not found");
+            return null;
+        }
+
+        if (TextUtils.isEmpty(fingerprint)) {
+            Log.e(TAG, "cert fingerprint not defined");
+            return null;
+        }
+
+        return new AndroidTarget.Builder()
+                    .packageName(packageName)
+                    .sha256CertFingerprint(fingerprint)
+                    .build();
+    }
+
+    private boolean isAndroidAssetStatement(final JSONObject jsonObject) {
+        JSONObject target = jsonObject.optJSONObject("target");
+        if (target == null) {
+            return false;
+        }
+        final String namespace = target.optString("namespace");
+        return NamespaceType.AndroidApp.getDescription().equals(namespace);
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AndroidTarget.java b/spi/java/org/openyolo/spi/assetlinks/data/AndroidTarget.java
new file mode 100644
index 0000000..61246f8
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AndroidTarget.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+
+/**
+ * <p>Java representation of a target in an Android asset statement.</p>
+ *
+ * <p>Note: the cert-fingerprint is scalar because a separate
+ * {@link AndroidAssetStatement} is created for each cert-fingerprint.
+ * This is done as a convenience and for precision when determining whether an asset relationship
+ * is bidirectional.
+ * </p>
+ */
+public class AndroidTarget {
+    private static final int PRIME = 31;
+    private final NamespaceType mNamespace;
+    private final String mPackageName;
+    private final String mSha256CertFingerprint;
+
+    private AndroidTarget(AndroidTarget.Builder builder) {
+        this.mNamespace = builder.mNamespace;
+        this.mPackageName = builder.mPackageName;
+        this.mSha256CertFingerprint = builder.mSha256CertFingerprint;
+    }
+
+    /**
+     * Get the target's namespace.
+     *
+     * @return Namespace
+     */
+    public NamespaceType getNamespace() {
+        return mNamespace;
+    }
+
+    /**
+     * Returns the target package name.
+     *
+     * @return package name
+     */
+    public String getPackageName() {
+        return mPackageName;
+    }
+
+    /**
+     * Returns the target app's cert fingerprint.
+     *
+     * @return cert fingerprint
+     */
+    public String getSha256CertFingerprint() {
+        return mSha256CertFingerprint;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+
+        AndroidTarget that = (AndroidTarget) obj;
+
+        if (mNamespace != that.mNamespace) {
+            return false;
+        }
+        if (!mPackageName.equals(that.mPackageName)) {
+            return false;
+        }
+        return mSha256CertFingerprint.equals(that.mSha256CertFingerprint);
+
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("AndroidTarget{");
+        sb.append("mNamespace=").append(mNamespace);
+        sb.append(", mPackageName='").append(mPackageName).append('\'');
+        sb.append(", sha256CertFingerprints=").append(mSha256CertFingerprint);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public int hashCode() {
+        int result = mNamespace.hashCode();
+        result = PRIME * result + mPackageName.hashCode();
+        result = PRIME * result + mSha256CertFingerprint.hashCode();
+        return result;
+    }
+
+    /**
+     * Builder for creating a {@link AndroidTarget}.
+     */
+    public static final class Builder {
+        private final NamespaceType mNamespace = NamespaceType.AndroidApp;
+        private String mPackageName;
+        private String mSha256CertFingerprint;
+
+        /**
+         * Set the target app package name.
+         *
+         * @param packageName App package name
+         * @return The Builder
+         */
+        public Builder packageName(@NonNull String packageName) {
+            this.mPackageName = packageName;
+            return this;
+        }
+
+        /**
+         * Set the target's cert fingerprint.
+         *
+         * @param sha256CertFingerprint The app's cert-fingerprint
+         * @return The Builder
+         */
+        public Builder sha256CertFingerprint(@NonNull String sha256CertFingerprint) {
+            this.mSha256CertFingerprint = sha256CertFingerprint;
+            return this;
+        }
+
+        /**
+         * Generate the {@link AndroidTarget}.
+         * @return The {@link AndroidTarget}
+         */
+        public AndroidTarget build() {
+            require(this.mPackageName, notNullValue());
+            require(this.mSha256CertFingerprint, notNullValue());
+            return new AndroidTarget(this);
+        }
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AssetStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/AssetStatement.java
new file mode 100644
index 0000000..abac7b3
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AssetStatement.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import java.util.List;
+
+/**
+ * Parent type for asset statements, either web or android.
+ */
+public interface AssetStatement {
+
+    /**
+     * Get the list of relations for the statement.
+     *
+     * @return List of relations.
+     */
+    List<RelationType> getRelations();
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java b/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java
new file mode 100644
index 0000000..507bdee
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactory.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Used to create a list of {@link AssetStatement}s from a JSON string.
+ */
+public enum AssetStatementsFactory {
+    /**
+     * The instance of the factory.
+     */
+    INSTANCE;
+
+    private static final String TAG = "AssetStatementsFactory";
+
+    /**
+     * Parses the provided asset statements JSON into a list of
+     * {@link AssetStatement}s.
+     *
+     * @param json Asset statements JSON
+     * @return A list of {@link AssetStatement}s or an empty list
+     */
+    @NonNull
+    public List<AssetStatement> createAssetStatements(@Nullable String json) {
+        if (TextUtils.isEmpty(json)) {
+            return Collections.emptyList();
+        }
+
+        JSONArray assetStatementsArray = parseJson(json);
+        if (assetStatementsArray == null) {
+            return Collections.emptyList();
+        }
+
+        return parseAssetStatements(assetStatementsArray);
+    }
+
+    private List<AssetStatement> parseAssetStatements(@NonNull JSONArray assetStatementsArray) {
+        List<AssetStatement> assetStatements = new ArrayList<>();
+        for (int i = 0; i < assetStatementsArray.length(); i++) {
+            final JSONObject assetStatementJson = assetStatementsArray.optJSONObject(i);
+            if (assetStatementJson == null) {
+                continue;
+            }
+
+            final AssetType assetType = getAssetType(assetStatementJson);
+            if (assetType == null) {
+                Log.e(TAG, "invalid asset statement type found");
+                continue;
+            }
+
+            switch (assetType) {
+                case Android:
+                    assetStatements.addAll(createAndroidAssetStatement(assetStatementJson));
+                    break;
+                case Web:
+                    assetStatements.addAll(createWebAssetStatement(assetStatementJson));
+                    break;
+                case Include:
+                    assetStatements.addAll(createIncludeAssetStatement(assetStatementJson));
+                    break;
+                default:
+                    Log.e(TAG, "invalid asset statement type found");
+            }
+        }
+        return assetStatements;
+    }
+
+    private Collection<? extends AssetStatement> createIncludeAssetStatement(JSONObject
+                assetStatementJson) {
+        return new IncludeAssetStatementDeserializer().deserialize(assetStatementJson);
+    }
+
+    private Collection<? extends AssetStatement> createWebAssetStatement(JSONObject
+                assetStatementJson) {
+        return new WebAssetStatementDeserializer().deserialize(assetStatementJson);
+    }
+
+    private Collection<? extends AssetStatement> createAndroidAssetStatement(JSONObject
+                assetStatementJson) {
+        return new AndroidAssetStatementDeserializer().deserialize(assetStatementJson);
+    }
+
+    @Nullable
+    private AssetType getAssetType(@NonNull JSONObject assetStatementJson) {
+        if (assetStatementJson.has("include")) {
+            return AssetType.Include;
+        } else {
+            JSONObject target = assetStatementJson.optJSONObject("target");
+            if (target == null) {
+                return null;
+            }
+            String namespace = target.optString("namespace");
+            if (TextUtils.isEmpty(namespace)) {
+                return null;
+            }
+            if (NamespaceType.Web.getDescription().equals(namespace)) {
+                return AssetType.Web;
+            } else if (NamespaceType.AndroidApp.getDescription().equals(namespace)) {
+                return AssetType.Android;
+            }
+            return null;
+        }
+    }
+
+    @Nullable
+    private JSONArray parseJson(String input) {
+        try {
+            return new JSONArray(input);
+        } catch (JSONException e) {
+            Log.e(TAG, "", e);
+        }
+        return null;
+    }
+
+    private enum AssetType {
+        Include, Android, Web
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/Deserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/Deserializer.java
new file mode 100644
index 0000000..9ca37f2
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/Deserializer.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import java.util.List;
+import org.json.JSONObject;
+
+/**
+ * Interface for asset statement deserializers.
+ *
+ * @param <T> Type of asset statement being created
+ */
+public interface Deserializer<T extends AssetStatement> {
+    /**
+     * Deserialize the provided JSON into a list of {@link AssetStatement}s.
+     *
+     * @param json Asset statements JSON
+     * @return A list of {@link AssetStatement}s or an empty list if no valid asset statements
+     *      are found
+     */
+    List<T> deserialize(JSONObject json);
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java b/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java
new file mode 100644
index 0000000..20b36dc
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/DeserializerUtil.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import android.util.Patterns;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Utility methods for deserializing asset statements.
+ */
+public class DeserializerUtil {
+    private DeserializerUtil() {
+        throw new IllegalAccessError("do not instantiate this class");
+    }
+
+    /**
+     * Get a list of {@link RelationType}s from the provided JSON.
+     *
+     * @param jsonObject JSON asset statement
+     * @return List of {@link RelationType}s or an empty list
+     */
+    public static List<RelationType> getRelations(final JSONObject jsonObject) {
+        JSONArray relation = jsonObject.optJSONArray("relation");
+        if (relation == null) {
+            return Collections.emptyList();
+        }
+
+        List<RelationType> relationTypes = new ArrayList<>();
+        for (int i = 0; i < relation.length(); i++) {
+            RelationType relationType = RelationType.getRelationType(relation.optString(i));
+            if (relationType != null) {
+                relationTypes.add(relationType);
+            }
+        }
+        return relationTypes;
+    }
+
+    /**
+     * Check if a URL is valid, using {@link Patterns#WEB_URL}.
+     *
+     * @param potentialUrl Potential URL to check
+     * @return True if the string is a valid URL, otherwise false
+     */
+    public static boolean isValidUrl(String potentialUrl) {
+        return Patterns.WEB_URL.matcher(potentialUrl).matches();
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java
new file mode 100644
index 0000000..f6cddc0
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializer.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.spi.assetlinks.data.DeserializerUtil.isValidUrl;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+import android.util.Log;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.json.JSONObject;
+
+/**
+ * Deserializer for converting JSON into a list of {@link IncludeStatement}.
+ */
+public class IncludeAssetStatementDeserializer implements Deserializer<IncludeStatement> {
+    private static final String TAG = "IncludeAssetStatementDe";
+
+    @Override
+    public List<IncludeStatement> deserialize(@NonNull final JSONObject assetStatementJson) {
+        require(assetStatementJson, notNullValue());
+        if (isIncludeAssetStatement(assetStatementJson)) {
+            IncludeStatement includeStatement = buildIncludeAssetStatement(assetStatementJson);
+            if (includeStatement == null) {
+                return Collections.emptyList();
+            }
+            return Collections.singletonList(includeStatement);
+        }
+        return Collections.emptyList();
+    }
+
+    private IncludeStatement buildIncludeAssetStatement(JSONObject assetStatementJson) {
+        String url = assetStatementJson.optString("include");
+        if (!isValidUrl(url)) {
+            Log.e(TAG, "include is not a valid URL");
+            return null;
+        }
+
+        return new IncludeStatement.Builder()
+                    .url(url)
+                    .build();
+    }
+
+    private boolean isIncludeAssetStatement(JSONObject assetStatementJson) {
+        return assetStatementJson != null && assetStatementJson.has("include");
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java
new file mode 100644
index 0000000..0c60ffd
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/IncludeStatement.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Represents an include asset statement.
+ */
+public class IncludeStatement implements AssetStatement {
+    private String mInclude;
+
+    private IncludeStatement(Builder builder) {
+        this.mInclude = builder.mUrl;
+    }
+
+    public String getInclude() {
+        return mInclude;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+
+        IncludeStatement that = (IncludeStatement) obj;
+
+        return mInclude.equals(that.mInclude);
+
+    }
+
+    @Override
+    public int hashCode() {
+        return mInclude.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("IncludeStatement{");
+        sb.append("mInclude='").append(mInclude).append('\'');
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public List<RelationType> getRelations() {
+        return Collections.emptyList();
+    }
+
+    /**
+     * Builder for creating {@link IncludeStatement}.
+     */
+    public static final class Builder {
+        private String mUrl;
+
+        /**
+         * Set the URL for the include.
+         *
+         * @param url The URL
+         * @return The builder
+         */
+        public Builder url(@NonNull String url) {
+            this.mUrl = url;
+            return this;
+        }
+
+        /**
+         * Create a new {@link IncludeStatement}.
+         *
+         * @return New {@link IncludeStatement}
+         */
+        public IncludeStatement build() {
+            require(this.mUrl, notNullValue());
+            return new IncludeStatement(this);
+        }
+    }
+
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/NamespaceType.java b/spi/java/org/openyolo/spi/assetlinks/data/NamespaceType.java
new file mode 100644
index 0000000..115f291
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/NamespaceType.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import android.support.annotation.Nullable;
+
+/**
+ * Used to represent the different types of namespaces in a Digital Asset Links.
+ */
+public enum NamespaceType {
+
+    /**
+     * Web asset namespace.
+     */
+    Web("web"),
+
+    /**
+     * Android asset namespace.
+     */
+    AndroidApp("android_app");
+
+    private final String mDescription;
+
+    NamespaceType(String desc) {
+        this.mDescription = desc;
+    }
+
+    public String getDescription() {
+        return mDescription;
+    }
+
+    /**
+     * Get the {@link NamespaceType} with the matching description or
+     * null.
+     *
+     * @param desc The {@link NamespaceType} mDescription.
+     * @return The {@link NamespaceType} with the matching
+     * {@link #getDescription()} } or null if a match isn't found.
+     */
+    @Nullable
+    public static NamespaceType getNamespaceType(String desc) {
+        for (NamespaceType nsType : values()) {
+            if (nsType.mDescription.equals(desc)) {
+                return nsType;
+            }
+        }
+        return null;
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/RelationType.java b/spi/java/org/openyolo/spi/assetlinks/data/RelationType.java
new file mode 100644
index 0000000..c397994
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/RelationType.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import android.support.annotation.Nullable;
+
+/**
+ * Represents an asset statement relation.
+ */
+public enum RelationType {
+    /**
+     * Relation to handle all URLs.
+     */
+    HandleAllUrls("delegate_permission/common.handle_all_urls"),
+
+    /**
+     * Relation to share sign-in credentials.
+     */
+    GetLoginCreds("delegate_permission/common.get_login_creds");
+
+    private final String mDescription;
+
+    RelationType(String desc) {
+        this.mDescription = desc;
+    }
+
+    /**
+     * Get the relation type description.
+     *
+     * @return The relation type string.
+     */
+    public String getDescription() {
+        return mDescription;
+    }
+
+    /**
+     * Get the {@link NamespaceType} with the matching description or
+     * null.
+     *
+     * @param desc The {@link RelationType} description.
+     * @return The {@link RelationType} with the matching
+     * {@link #getDescription()} } or null if a match isn't found.
+     */
+    @Nullable
+    public static RelationType getRelationType(String desc) {
+        for (RelationType relationType : values()) {
+            if (relationType.getDescription().equals(desc)) {
+                return relationType;
+            }
+        }
+        return null;
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java b/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java
new file mode 100644
index 0000000..2b432ea
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializer.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.openyolo.spi.assetlinks.data.DeserializerUtil.isValidUrl;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Deserializer for converting JSON into a list of {@link WebSiteAssetStatement}.
+ */
+public class WebAssetStatementDeserializer implements Deserializer<WebSiteAssetStatement> {
+    private static final String TAG = "WebAssetStatementDeseri";
+
+    @Override
+    public List<WebSiteAssetStatement> deserialize(@NonNull final JSONObject assetStatementJson) {
+        require(assetStatementJson, notNullValue());
+        if (!isWebAssetStatement(assetStatementJson)) {
+            Log.e(TAG, "not a web asset statement");
+            return Collections.emptyList();
+
+        }
+        WebSiteAssetStatement webSiteAssetStatement = buildWebStatement(assetStatementJson);
+        if (webSiteAssetStatement == null) {
+            return Collections.emptyList();
+        }
+        return Collections.singletonList(webSiteAssetStatement);
+    }
+
+    private WebSiteAssetStatement buildWebStatement(JSONObject assetStatementJson) {
+        JSONObject target = assetStatementJson.optJSONObject("target");
+        if (target == null) {
+            Log.e(TAG, "'target' property not found");
+            return null;
+        }
+
+        List<RelationType> relationTypes = getRelations(assetStatementJson);
+        if (relationTypes.isEmpty()) {
+            Log.e(TAG, "no asset statement relations found");
+            return null;
+        }
+
+        final WebTarget webTarget = createWebTarget(target);
+        if (webTarget == null) {
+            Log.e(TAG, "unable to create web target");
+            return null;
+        }
+
+        return new WebSiteAssetStatement.Builder()
+                    .relations(relationTypes)
+                    .webTarget(webTarget)
+                    .build();
+    }
+
+    private WebTarget createWebTarget(JSONObject targetJson) {
+        final String site = targetJson.optString("site");
+        if (!isValidUrl(site)) {
+            Log.e(TAG, "invalid 'site' value in asset statement");
+            return null;
+        }
+
+        return new WebTarget.Builder()
+                    .site(site)
+                    .build();
+    }
+
+    private List<RelationType> getRelations(final JSONObject jsonObject) {
+        JSONArray relation = jsonObject.optJSONArray("relation");
+        if (relation == null) {
+            return Collections.emptyList();
+        }
+
+        List<RelationType> relationTypes = new ArrayList<>();
+        for (int i = 0; i < relation.length(); i++) {
+            RelationType relationType = RelationType.getRelationType(relation.optString(i));
+            if (relationType != null) {
+                relationTypes.add(relationType);
+            }
+        }
+        return relationTypes;
+    }
+
+    private boolean isWebAssetStatement(JSONObject jsonObject) {
+        JSONObject target = jsonObject.optJSONObject("target");
+        if (target == null) {
+            Log.e(TAG, "'target' property not found");
+            return false;
+        }
+        final String namespace = target.optString("namespace");
+        return NamespaceType.Web.getDescription().equals(namespace);
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java b/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java
new file mode 100644
index 0000000..32b8639
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatement.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+
+import java.util.List;
+
+public class WebSiteAssetStatement implements AssetStatement {
+    private static final int PRIME = 31;
+    private List<RelationType> mRelations;
+    private WebTarget mTarget;
+
+    private WebSiteAssetStatement(Builder builder) {
+        this.mRelations = builder.mRelations;
+        this.mTarget = builder.mWebTarget;
+    }
+
+    @Override
+    public List<RelationType> getRelations() {
+        return mRelations;
+    }
+
+    public WebTarget getTarget() {
+        return mTarget;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+
+        WebSiteAssetStatement that = (WebSiteAssetStatement) obj;
+
+        if (!mRelations.equals(that.mRelations)) {
+            return false;
+        }
+        return mTarget.equals(that.mTarget);
+
+    }
+
+    @Override
+    public int hashCode() {
+        int result = mRelations.hashCode();
+        result = PRIME * result + mTarget.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("WebSiteAssetStatement{");
+        sb.append("mRelations=").append(mRelations);
+        sb.append(", mTarget=").append(mTarget);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    public static final class Builder {
+        private WebTarget mWebTarget;
+        private List<RelationType> mRelations;
+
+        /**
+         * Relations, for a Digital Asset Link.
+         *
+         * @param relations List of relations
+         * @return The Builder
+         */
+        public Builder relations(@NonNull List<RelationType> relations) {
+            this.mRelations = relations;
+            return this;
+        }
+
+        /**
+         * Set the {@link WebTarget}.
+         *
+         * @param webTarget The web target for the asset statement.
+         * @return The Builder
+         */
+        public Builder webTarget(@NonNull WebTarget webTarget) {
+            this.mWebTarget = webTarget;
+            return this;
+        }
+
+        /**
+         * Create a new {@link WebSiteAssetStatement}.
+         * @return The new instance.
+         */
+        public WebSiteAssetStatement build() {
+            require(this.mWebTarget, notNullValue());
+            require(this.mRelations, notNullValue());
+            return new WebSiteAssetStatement(this);
+        }
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/WebTarget.java b/spi/java/org/openyolo/spi/assetlinks/data/WebTarget.java
new file mode 100644
index 0000000..376b7a5
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/WebTarget.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.support.annotation.NonNull;
+
+/**
+ * Represents a web asset.
+ */
+public class WebTarget {
+
+    private static final int PRIME = 31;
+    private NamespaceType mNamespace;
+    private String mSite;
+
+    private WebTarget(Builder builder) {
+        this.mNamespace = builder.mNamespace;
+        this.mSite = builder.mSite;
+    }
+
+    /**
+     * Get the asset descriptor namespace.
+     *
+     * @return Asset descriptor namespace
+     */
+    public NamespaceType getNamespace() {
+        return mNamespace;
+    }
+
+    /**
+     * Get the asset descriptor site.
+     *
+     * @return Asset descriptor site.
+     */
+    public String getSite() {
+        return mSite;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+
+        WebTarget target = (WebTarget) obj;
+
+        if (mNamespace != target.mNamespace) {
+            return false;
+        }
+        return mSite != null ? mSite.equals(target.mSite) : target.mSite == null;
+
+    }
+
+    @Override
+    public int hashCode() {
+        int result = mNamespace != null ? mNamespace.hashCode() : 0;
+        result = PRIME * result + (mSite != null ? mSite.hashCode() : 0);
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("WebTarget{");
+        sb.append("mNamespace=").append(mNamespace);
+        sb.append(", mSite='").append(mSite).append('\'');
+        sb.append('}');
+        return sb.toString();
+    }
+
+    /**
+     * Builder for creating a {@link AndroidTarget}.
+     */
+    public static final class Builder {
+        private final NamespaceType mNamespace = NamespaceType.Web;
+        private String mSite;
+
+        /**
+         * Set the site URL.
+         *
+         * @param site Site URL
+         * @return The Builder
+         */
+        public Builder site(@NonNull String site) {
+            this.mSite = site;
+            return this;
+        }
+
+        /**
+         * Generate the {@link AndroidTarget}.
+         * @return The {@link AndroidTarget}
+         */
+        public WebTarget build() {
+            require(this.mSite, notNullValue());
+            return new WebTarget(this);
+        }
+    }
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/data/package-info.java b/spi/java/org/openyolo/spi/assetlinks/data/package-info.java
new file mode 100644
index 0000000..27380d6
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/data/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Helper classes for deserializing Digital Asset Link statements.
+ */
+package org.openyolo.spi.assetlinks.data;
diff --git a/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java
new file mode 100644
index 0000000..d3e8a4a
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoader.java
@@ -0,0 +1,334 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.loader;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.openyolo.spi.AssetStatementsUtil;
+import org.openyolo.spi.assetlinks.data.AndroidAssetStatement;
+import org.openyolo.spi.assetlinks.data.AssetStatement;
+import org.openyolo.spi.assetlinks.data.AssetStatementsFactory;
+import org.openyolo.spi.assetlinks.data.RelationType;
+
+/**
+ * <p>This class loads the asset statement(s) from the Android app identified in the provided
+ * <code>AndroidAssetStatement</code>.</p>
+ */
+@SuppressLint("PackageManagerGetSignatures")
+public class TargetAndroidAssetStatementLoader {
+    private static final String TAG = "AndroidAssetStatementLo";
+
+    private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
+    private static final String DIGEST_SHA_256 = "SHA-256";
+
+    private static final int HEX_0F = 0x0F;
+    private static final int HEX_FF = 0xFF;
+    private static final int FOUR = 4;
+
+    private final AndroidAssetStatement mSourceAssetStatement;
+    private final Context mContext;
+
+    /**
+     * <p>Create an instance of the target asset statement loader.</p>
+     *
+     * <p>The asset statements from the Android app identified by
+     * {@link AndroidAssetStatement#getTarget()} in the <code>sourceAssetStatement</code> will be
+     * retrieved and returned if the package name and cert-fingerprint match and if it has the
+     * relation for sharing sign-in credentials.
+     *</p>
+     *
+     * @param context Context
+     * @param sourceAssetStatement The 'source' Digital Asset Link asset statement from a
+     *     requesting client app.
+     */
+    public TargetAndroidAssetStatementLoader(@NonNull Context context,
+                @NonNull AndroidAssetStatement sourceAssetStatement) {
+        require(context, notNullValue());
+        require(sourceAssetStatement, notNullValue());
+        require(sourceAssetStatement.getTarget(), notNullValue());
+
+        this.mContext = context.getApplicationContext();
+        this.mSourceAssetStatement = sourceAssetStatement;
+    }
+
+    /**
+     * <p>Load the 'target' (Android) {@link AssetStatement}s that are referenced in the 'source'
+     * app's asset statements with the relation for sharing sign-in credentials.
+     * </p>
+     *
+     * <p>
+     * The following steps are performed:
+     * <ol>
+     * <li>Verify the source app has the relation to share sign-in credentials</li>
+     * <li>Verify an Android app (the "target") is installed on the device with the target app
+     * package name
+     * and
+     * cert fingerprint, and it has the relation for sharing sign-in credentials</li>
+     * </ol>
+     * If those checks are successful, the asset statements (if any) from the "target" Android will
+     * be returned.  Otherwise an empty list will be returned.
+     * </p>
+     *
+     * @return A List of (Android) {@link AssetStatement}s that passed the verification or an
+     *     empty list
+     */
+    @NonNull
+    public List<AssetStatement> getRelatedAssetStatements() {
+        // verify the source asset statement has the relation for sharing sign-in credentials
+        if (!containsRelation(mSourceAssetStatement, RelationType.GetLoginCreds)) {
+            // TODO remove before released
+            Log.d(TAG, "no asset statements found from "
+                        + mSourceAssetStatement.getTarget().getPackageName()
+                        + " for sharing credentials");
+            return Collections.emptyList();
+        }
+
+        // see if an app exists with the target package name and cert-fingerprint
+        final PackageInfo targetPackageInfo = getPackageInfo(mContext,
+                    mSourceAssetStatement.getTarget().getPackageName(),
+                    mSourceAssetStatement.getTarget().getSha256CertFingerprint());
+
+        // if no app was found with the target package name and fingerprint, the target app
+        // doesn't exist
+        if (targetPackageInfo == null) {
+            // TODO remove before released
+            Log.d(TAG, "no app found with package name "
+                        + mSourceAssetStatement.getTarget().getPackageName()
+                        + " and cert fingerprint matching "
+                        + mSourceAssetStatement.getTarget().getSha256CertFingerprint());
+            return Collections.emptyList();
+        }
+
+        // get the asset statements from the target app
+        final String targetAssetStmtsStr = AssetStatementsUtil.getAssetStatements(mContext,
+                    mSourceAssetStatement.getTarget().getPackageName());
+        if (TextUtils.isEmpty(targetAssetStmtsStr)) {
+            // TODO remove before released
+            Log.d(TAG, "no asset statements found for package name "
+                        + mSourceAssetStatement.getTarget().getPackageName());
+            return Collections.emptyList();
+        }
+
+        // get the asset statements from the target app defined in the source/client app's
+        // asset_statements
+        final List<AssetStatement> targetAssetStatements = parseAssetStatements
+                    (targetAssetStmtsStr);
+        if (targetAssetStatements.isEmpty()) {
+            // TODO remove before released
+            Log.d(TAG, "target app " + mSourceAssetStatement.getTarget().getPackageName()
+                        + " contains no asset statements");
+            return Collections.emptyList();
+        }
+
+        // filter out asset statements with non-Android app descriptors
+        final List<AssetStatement> androidTargetAssetStmts
+                    = filterAssetStatements(targetAssetStatements, AndroidAssetStatement.class);
+        if (androidTargetAssetStmts.isEmpty()) {
+            // TODO remove before released
+            Log.d(TAG, "target app " + mSourceAssetStatement.getTarget().getPackageName()
+                        + " contains no Android asset statements");
+            return Collections.emptyList();
+        }
+
+        // filter out asset statements that done have the relation for sharing sign-in credentials
+        final List<AssetStatement> androidLoginCredsAssetStmts
+                    = filterAssetStatements(androidTargetAssetStmts,
+                    RelationType.GetLoginCreds);
+        if (androidLoginCredsAssetStmts.isEmpty()) {
+            // TODO remove before released
+            Log.d(TAG, "target app " + mSourceAssetStatement.getTarget().getPackageName()
+                        + " contains no asset statements for sharing credentials");
+        }
+        return androidLoginCredsAssetStmts;
+    }
+
+    /**
+     * Get the {@link PackageInfo} for the specified <code>packageName</code> if the fingerprint
+     * of the signing-cert matches the provided <code>certFingerprint</code>.
+     *
+     * @param context Context
+     * @param packageName App package name
+     * @param certFingerprint Hex, SHA-256 of the app signature (no dots)
+     * @return The {@link PackageInfo} of the specified app or null if the {@link PackageManager}
+     *     can't find the app or if signing signatures have the correct fingerprint.
+     */
+    @Nullable
+    static PackageInfo getPackageInfo(@NonNull Context context, @NonNull String
+                packageName, @NonNull String certFingerprint) {
+        require(context, notNullValue());
+        require(!TextUtils.isEmpty(packageName), "packageName must not be null or empty");
+        require(!TextUtils.isEmpty(certFingerprint), "certFingerprint must not be null or empty");
+
+        PackageInfo packageInfo;
+        try {
+            packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager
+                        .GET_SIGNATURES);
+        } catch (PackageManager.NameNotFoundException e) {
+            return null;
+        }
+        return containsFingerprint(packageInfo, certFingerprint) ? packageInfo : null;
+    }
+
+    /**
+     * Check if the {@link PackageInfo} app contains the specified cert fingerprint.
+     *
+     * @param packageInfo PackageInfo (retrieved with
+     * {@link PackageManager#GET_SIGNATURES}
+     * @param certFingerprint Hex, SHA-256 of the app signature (no dots)
+     *
+     * @return Whether the specified app contains the cert fingerprint
+     */
+    static boolean containsFingerprint(@NonNull PackageInfo packageInfo,
+                @NonNull final String certFingerprint) {
+
+        require(packageInfo, notNullValue());
+        require(!TextUtils.isEmpty(certFingerprint), "certFingerprint must not be null or empty");
+
+        final String paramFingerprint = certFingerprint.replaceAll(":", "");
+
+        for (Signature signature : packageInfo.signatures) {
+            String fingerprint = toHex(sha256(signature.toByteArray()));
+            if (fingerprint.equals(paramFingerprint)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    static byte[] sha256(final byte[] input) {
+        try {
+            MessageDigest digest = MessageDigest.getInstance(DIGEST_SHA_256);
+            return digest.digest(input);
+        } catch (NoSuchAlgorithmException e) {
+            throw new IllegalStateException("Platform does not support" + DIGEST_SHA_256 + " "
+                        + "hashing");
+        }
+    }
+
+    static String toHex(byte[] bytes) {
+        char[] hexChars = new char[bytes.length * 2];
+        for (int i = 0; i < bytes.length; i++) {
+            int indx = bytes[i] & HEX_FF;
+            hexChars[i * 2] = HEX_DIGITS[indx >>> FOUR];
+            hexChars[i * 2 + 1] = HEX_DIGITS[indx & HEX_0F];
+        }
+        return new String(hexChars);
+    }
+
+    /**
+     * Check if the {@link AssetStatement} contains the specified {@link RelationType}.
+     *
+     * @param assetStatement Asset statement to be checked for the relation
+     * @param relationType Relation to check for
+     * @return True if the asset statement contains the relation, otherwise false
+     */
+    static boolean containsRelation(@NonNull final AssetStatement assetStatement,
+                @NonNull final RelationType relationType) {
+
+        require(assetStatement, notNullValue());
+        require(relationType, notNullValue());
+
+        if (assetStatement.getRelations() == null || assetStatement.getRelations().isEmpty()) {
+            return false;
+        }
+        return assetStatement.getRelations().contains(relationType);
+    }
+
+    /**
+     * From the provided list of {@link AssetStatement}s, return those containing the specified
+     * {@link RelationType}.
+     *
+     * @param assetStatements Asset statements from with the return List will be generated
+     * @param relationType Asset statements must have this relation type to be included in the
+     *     output.
+     * @return List of asset statements containing the specified relation type, or empty
+     */
+    @NonNull
+    static List<AssetStatement> filterAssetStatements(@NonNull final List<AssetStatement>
+                assetStatements,
+                @NonNull final RelationType relationType) {
+
+        require(assetStatements, notNullValue());
+        require(relationType, notNullValue());
+
+        List<AssetStatement> outputStatements = new ArrayList<>();
+        for (AssetStatement stmt : assetStatements) {
+            if (containsRelation(stmt, relationType)) {
+                outputStatements.add(stmt);
+            }
+        }
+        return outputStatements;
+    }
+
+    /**
+     * From the provided list of {@link AssetStatement}s, return those that are an instance of
+     * {@link Class}.
+     *
+     * @param assetStatements Asset statements from with the return List will be generated
+     * @param clazz Asset statements must be of this type to be included in the
+     *     output.
+     * @return List of asset statements of the specified relation type, or empty
+     */
+    @NonNull
+    static List<AssetStatement> filterAssetStatements(@NonNull final List<AssetStatement>
+                assetStatements, Class clazz) {
+
+        require(assetStatements, notNullValue());
+
+        List<AssetStatement> outputStatements = new ArrayList<>();
+        for (AssetStatement assetStatement : assetStatements) {
+            if (assetStatement.getClass() == clazz) {
+                outputStatements.add(assetStatement);
+            }
+        }
+        return outputStatements;
+    }
+
+    /**
+     * Parse the provided input into a {@link List} of {@link AssetStatement}s using
+     * {@link AssetStatementsFactory}.
+     *
+     * @param assetStatements Input asset statements JSON
+     * @return List of {@link AssetStatement}s
+     */
+    @NonNull
+    static List<AssetStatement> parseAssetStatements(@NonNull final String assetStatements) {
+
+        require(!TextUtils.isEmpty(assetStatements), "assetStatements must not be null or empty");
+
+        if (TextUtils.isEmpty(assetStatements)) {
+            return Collections.emptyList();
+        }
+        return AssetStatementsFactory.INSTANCE.createAssetStatements(assetStatements);
+    }
+
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java
new file mode 100644
index 0000000..d3daeca
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoader.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.loader;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.valid4j.Assertive.require;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openyolo.spi.assetlinks.data.AndroidAssetStatement;
+import org.openyolo.spi.assetlinks.data.AssetStatement;
+
+/**
+ * <p> This class loads the asset statements defined as 'targets' in the source asset statements
+ * parameter.  It's basically a wrapper around calling {@link TargetAndroidAssetStatementLoader}
+ * to load
+ * Android (target) asset statements.
+ * </p>
+ * <p> Note, currently this class only loads Android (target) asset statements.  Web asset
+ * statements not yet supported.
+ * </p>
+ */
+public class TargetAssetStatementLoader {
+    private final Context mContext;
+    private final List<AssetStatement> mSourceAssetStatements;
+
+    /**
+     * Create a 'target' asset statement loader for the given 'source' asset statements.
+     *
+     * @param context Context
+     * @param sourceAssetStatements Asset statements from the 'source' app.  Asset
+     *     statements for the 'target' asset descriptors in this list will be retrieved.
+     */
+    public TargetAssetStatementLoader(@NonNull final Context context,
+                @NonNull final List<AssetStatement> sourceAssetStatements) {
+        require(context, notNullValue());
+        require(sourceAssetStatements, notNullValue());
+
+        this.mContext = context.getApplicationContext();
+        this.mSourceAssetStatements = sourceAssetStatements;
+    }
+
+    /**
+     * <p>Get the 'target' asset statements listed in the 'source' app's asset statements.</p>
+     *
+     * <p>See
+     * {@link TargetAndroidAssetStatementLoader#getRelatedAssetStatements()} for more details on
+     * the rules applied.</p>
+     *
+     * @return List of {@link AssetStatement}s or an empty list.
+     */
+    public List<AssetStatement> getRelatedAssetStatements() {
+        final List<AssetStatement> statements = new ArrayList<>();
+
+        // get asset statements from android apps that are referenced as targets in the source
+        // app's asset statements
+        statements.addAll(getTargetAndroidAssetStatements(mSourceAssetStatements));
+
+        // get asset statements from websites that are referenced as targets in the source
+        // app's asset statements
+        //statements.addAll(getTargetWebAssetStatements(mSourceAssetStatements));
+
+        return statements;
+    }
+
+    private List<AssetStatement> getTargetAndroidAssetStatements(final List<AssetStatement>
+                sourceAssetStatements) {
+        final List<AssetStatement> targetAndroidAssetStmts = new ArrayList<>();
+        for (AssetStatement sourceAssetStatement : sourceAssetStatements) {
+            if (sourceAssetStatement instanceof AndroidAssetStatement) {
+                targetAndroidAssetStmts.addAll(getTargetAndroidAssetStatements(
+                            (AndroidAssetStatement) sourceAssetStatement));
+            }
+        }
+        return targetAndroidAssetStmts;
+    }
+
+    private List<AssetStatement> getTargetAndroidAssetStatements(final AndroidAssetStatement
+                androidAssetStatement) {
+        return new TargetAndroidAssetStatementLoader(mContext, androidAssetStatement)
+                    .getRelatedAssetStatements();
+    }
+
+    //private List<AssetStatement> getTargetWebAssetStatements(final List<AssetStatement>
+    //        mSourceAssetStatements) {
+    //    return Collections.emptyList(); // TODO
+    //}
+}
diff --git a/spi/java/org/openyolo/spi/assetlinks/loader/package-info.java b/spi/java/org/openyolo/spi/assetlinks/loader/package-info.java
new file mode 100644
index 0000000..4650a20
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/loader/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Helper classes for loading Digital Asset Link statements and checking relationships.
+ */
+package org.openyolo.spi.assetlinks.loader;
diff --git a/spi/java/org/openyolo/spi/assetlinks/package-info.java b/spi/java/org/openyolo/spi/assetlinks/package-info.java
new file mode 100644
index 0000000..b3420bf
--- /dev/null
+++ b/spi/java/org/openyolo/spi/assetlinks/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Helper classes for working with Digital Asset Link statements.
+ */
+package org.openyolo.spi.assetlinks;
diff --git a/spi/java/org/openyolo/spi/package-info.java b/spi/java/org/openyolo/spi/package-info.java
new file mode 100644
index 0000000..5798175
--- /dev/null
+++ b/spi/java/org/openyolo/spi/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Service provider interface, which credential managers should implement
+ * to interact with apps that support OpenYOLO.
+ */
+package org.openyolo.spi;
diff --git a/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java b/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java
new file mode 100644
index 0000000..8b7f12d
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/AssetStatementsUtilTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.when;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.os.Bundle;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for AssetStatementsUtil
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class AssetStatementsUtilTest {
+    private static final String ASSET_STATEMENTS = "asset_statements";
+
+    @Mock
+    Context mockContext;
+    @Mock
+    PackageManager mockPackageManager;
+    @Mock
+    ApplicationInfo mockAppInfo;
+    @Mock
+    Resources mockResources;
+
+    private static final String APPROVED_PACKAGE = "com.dashlane";
+    private static final int KEY = 5;
+    private static final String MOCK_RESPONSE = "mockResponse";
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        when(mockContext.getPackageManager())
+                .thenReturn(mockPackageManager);
+        when(mockPackageManager.getApplicationInfo(anyString(), anyInt()))
+                .thenReturn(mockAppInfo);
+        when(mockPackageManager.getResourcesForApplication(any(ApplicationInfo.class)))
+                .thenReturn(mockResources);
+        when(mockResources.getString(KEY)).thenReturn(MOCK_RESPONSE);
+    }
+
+    @Test
+    public void testGetAssetStatements_metadata_null() throws Exception {
+        mockAppInfo.metaData = null;
+        String assetStatement = AssetStatementsUtil.getAssetStatements(mockContext,
+                APPROVED_PACKAGE);
+        assertNull(assetStatement);
+    }
+
+    @Test
+    public void testGetAssetStatements_metadata_noKey() throws Exception {
+        mockAppInfo.metaData = new Bundle();
+        String assetStatement = AssetStatementsUtil.getAssetStatements(mockContext,
+                APPROVED_PACKAGE);
+        assertNull(assetStatement);
+    }
+
+    @Test
+    public void testGetAssetStatements_metadata_withKey() throws Exception {
+        mockAppInfo.metaData = new Bundle();
+        mockAppInfo.metaData.putInt(ASSET_STATEMENTS, KEY);
+        String assetStatement = AssetStatementsUtil.getAssetStatements(mockContext,
+                APPROVED_PACKAGE);
+        assertEquals(MOCK_RESPONSE, assetStatement);
+    }
+
+    @Test
+    public void testGetAssetStatements_throwNameNotFoundExceptionOnAppInfo() throws Exception {
+        mockAppInfo.metaData = new Bundle();
+        mockAppInfo.metaData.putInt(ASSET_STATEMENTS, KEY);
+        when(mockPackageManager.getApplicationInfo(anyString(), anyInt()))
+                .thenThrow(PackageManager.NameNotFoundException.class);
+        String assetStatement = AssetStatementsUtil.getAssetStatements(mockContext,
+                APPROVED_PACKAGE);
+        assertNull(assetStatement);
+    }
+
+    @Test
+    public void getAssetStatements_throwNameNotFoundExceptionOnResources() throws Exception {
+        mockAppInfo.metaData = new Bundle();
+        mockAppInfo.metaData.putInt(ASSET_STATEMENTS, KEY);
+        when(mockPackageManager.getResourcesForApplication(any(ApplicationInfo.class)))
+                .thenThrow(PackageManager.NameNotFoundException.class);
+        String assetStatement = AssetStatementsUtil.getAssetStatements(mockContext,
+                APPROVED_PACKAGE);
+        assertNull(assetStatement);
+    }
+
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
new file mode 100644
index 0000000..ad80b0f
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/BaseCredentialQueryReceiverTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import android.support.annotation.NonNull;
+import com.google.bbq.proto.BroadcastQuery;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import okio.ByteString;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.RetrieveRequest;
+import org.openyolo.proto.CredentialRetrieveRequest;
+import org.openyolo.proto.KeyValuePair;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for BaseCredentialQueryReceiver
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class BaseCredentialQueryReceiverTest {
+    private BaseCredentialQueryReceiver underTest;
+    @Mock
+    Context mockContext;
+    @Mock
+    PackageManager mockPackageManager;
+    @Mock
+    Intent mockIntent;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        underTest = new BaseCredentialQueryReceiver("testTage") {
+            @Override
+            protected void processCredentialRequest(
+                    @NonNull Context context,
+                    @NonNull BroadcastQuery query,
+                    @NonNull RetrieveRequest request,
+                    @NonNull Set<AuthenticationDomain> requestorDomains) {
+                assertNotNull(context);
+                assertNotNull(query);
+                assertNotNull(request);
+                assertNotNull(requestorDomains);
+            }
+        };
+        PackageInfo mockPackageInfo = new PackageInfo();
+        Signature[] signatures = new Signature[1];
+        signatures[0] = mock(Signature.class);
+        when(signatures[0].toByteArray()).thenReturn(new byte[10]);
+        mockPackageInfo.signatures = signatures;
+        when(mockContext.getPackageManager()).thenReturn(mockPackageManager);
+        when(mockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mockPackageInfo);
+
+    }
+
+    @Test
+    public void testOnReceive() throws Exception {
+        underTest.onReceive(mockContext, mockIntent);
+    }
+
+    @Test
+    public void testProcessQuery_nullPointer() throws Exception {
+
+        BroadcastQuery local = new BroadcastQuery.Builder()
+                .requestingApp("org.openyolo")
+                .dataType("blah")
+                .requestId(101L)
+                .responseId(102L)
+                .queryMessage(null)
+                .build();
+        underTest.processQuery(mockContext, local);
+    }
+
+    @Test
+    public void testProcessQuery_nonNull() throws Exception {
+
+        List<String> authDomains = new ArrayList<>();
+        authDomains.add("https://www.google.com");
+        authDomains.add("https://www.yahoo.com");
+        List<String> authMethods = new ArrayList<>();
+        authMethods.add("custom://one");
+        authMethods.add("custom://two");
+        List<KeyValuePair> additionalParams = new ArrayList<>();
+        CredentialRetrieveRequest query = new CredentialRetrieveRequest(
+                authDomains,
+                authMethods,
+                additionalParams,
+                ByteString.EMPTY);
+
+        byte[] data = CredentialRetrieveRequest.ADAPTER.encode(query);
+        BroadcastQuery local = new BroadcastQuery.Builder()
+                .requestingApp("org.openyolo")
+                .dataType("blah")
+                .requestId(101L)
+                .responseId(102L)
+                .queryMessage(ByteString.of(data))
+                .build();
+        underTest.processQuery(mockContext, local);
+    }
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
new file mode 100644
index 0000000..28627f7
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/RetrieveIntentResultUtilTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.openyolo.api.AuthenticationMethods.ID_AND_PASSWORD;
+import android.content.Intent;
+import android.util.Base64;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openyolo.api.AuthenticationDomain;
+import org.openyolo.api.Credential;
+import org.openyolo.api.CredentialClient;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+/**
+ * Battery of tests for RetrieveIntentResultUtil
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class RetrieveIntentResultUtilTest {
+    public static final String EMAIL_ID = "alice@example.com";
+    private String base64string = "ChFhbGljZUBleGFtcGxlLmNvbRIXaHR0cHM6Ly93d3cuZXhhbXBsZS5jb20aGm9wZW55b2xvOi8v\naWQtYW5kLXBhc3N3b3Jk\n";
+
+    @Test
+    public void testCreateResponseData() throws Exception {
+        Credential cr = new Credential.Builder( EMAIL_ID, ID_AND_PASSWORD,
+        new AuthenticationDomain("https://www.example.com")).build();
+        Intent reposnse = RetrieveIntentResultUtil.createResponseData(cr.getProto());
+        byte[] bytes = reposnse.getExtras().getByteArray(CredentialClient.EXTRA_CREDENTIAL);
+        assertEquals(bytes.length, 72);
+        String data = Base64.encodeToString(bytes, Base64.DEFAULT);
+        assertEquals(base64string, data);
+    }
+
+    @Test
+    public void testCreateResponseData_withNull() throws Exception {
+        Intent reposnse = RetrieveIntentResultUtil.createResponseData(null);
+        assertNull(reposnse.getExtras());
+    }
+
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java
new file mode 100644
index 0000000..1cee929
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/AssetRelationshipHelperTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks;
+
+import android.content.Context;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.openyolo.spi.assetlinks.data.AssetStatement;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for {@link AssetRelationshipHelper}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class AssetRelationshipHelperTest {
+
+    @Mock
+    Context mockContext;
+
+    private final List<AssetStatement> assetStatements = Collections.emptyList();
+
+    @Test (expected = RequireViolation.class)
+    public void testNullContext() {
+        new AssetRelationshipHelper(null, "", assetStatements, assetStatements);
+    }
+
+    @Test (expected = RequireViolation.class)
+    public void testNullPackageName() {
+        new AssetRelationshipHelper(mockContext, null, assetStatements, assetStatements);
+    }
+
+    @Test (expected = RequireViolation.class)
+    public void testNullSourceAssetStmts() {
+        new AssetRelationshipHelper(mockContext, "", null, assetStatements);
+    }
+
+    @Test (expected = RequireViolation.class)
+    public void testNullTargetAssetStmts() {
+        new AssetRelationshipHelper(mockContext, "", assetStatements, null);
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java
new file mode 100644
index 0000000..17b394e
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementDeserializerTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+import org.json.JSONObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.List;
+
+/**
+ * Tests for {@link AndroidAssetStatementDeserializer}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class AndroidAssetStatementDeserializerTest {
+
+    @Test(expected = RequireViolation.class)
+    public void testNullJson() {
+        new AndroidAssetStatementDeserializer().deserialize(null);
+    }
+
+    @Test
+    public void testNoTarget() {
+        JSONObject json = new JSONObject();
+        final List<AndroidAssetStatement> assetStatements = new AndroidAssetStatementDeserializer()
+                    .deserialize(json);
+        assertNotNull(assetStatements);
+        assertTrue(assetStatements.isEmpty());
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java
new file mode 100644
index 0000000..c2be457
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidAssetStatementTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.Arrays;
+
+/**
+ * Tests for {@link AndroidAssetStatement).
+ */
+public class AndroidAssetStatementTest {
+    private final String fingerprint =
+                "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03:62:87:0C:98:B0:C9" +
+                            ":E2:2A:8E:14:DF:A8";
+
+    @Test (expected = RequireViolation.class)
+    public void testNullRelations() {
+        new AndroidAssetStatement.Builder()
+                    .target(createAndroidTarget())
+                    .build();
+    }
+
+    @Test (expected = RequireViolation.class)
+    public void testNullTarget() {
+        new AndroidAssetStatement.Builder()
+                    .relations(Arrays.asList(RelationType.GetLoginCreds))
+                    .build();
+    }
+
+    private AndroidTarget createAndroidTarget() {
+        return new AndroidTarget.Builder()
+                    .packageName("org.example")
+                    .sha256CertFingerprint(fingerprint)
+                    .build();
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidTargetTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidTargetTest.java
new file mode 100644
index 0000000..d46d1d3
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AndroidTargetTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Tests for {@link AndroidTarget}
+ */
+public class AndroidTargetTest {
+    private final String fingerprint =
+                "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03:62:87:0C:98:B0:C9" +
+                            ":E2:2A:8E:14:DF:A8";
+
+    @Test(expected = RequireViolation.class)
+    public void testNullPackageName() {
+        new AndroidTarget.Builder()
+                    .sha256CertFingerprint(fingerprint)
+                    .build();
+    }
+
+    @Test(expected = RequireViolation.class)
+    public void testNullFingerprint() {
+        new AndroidTarget.Builder()
+                    .packageName("org.example")
+                    .build();
+    }
+
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java
new file mode 100644
index 0000000..3450804
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static junit.framework.Assert.assertTrue;
+import static org.openyolo.spi.assetlinks.data.RelationType.GetLoginCreds;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Tests for {@link AssetStatement}
+ */
+@RunWith(Parameterized.class)
+public class AssetStatementTest {
+
+    private static final String fingerprint =
+                "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03:62:87:0C:98:B0:C9" +
+                            ":E2:2A:8E:14:DF:A8";
+
+    private static final List<RelationType> relations = Arrays.asList(GetLoginCreds);
+
+    public AssetStatement assetStatement;
+
+    public AssetStatementTest(AssetStatement assetStatement) {
+        this.assetStatement = assetStatement;
+    }
+
+    @Test
+    public final void testRelationsMethod() {
+        assertTrue(assetStatement.getRelations().size() == 1);
+        assertTrue(assetStatement.getRelations().contains(GetLoginCreds));
+    }
+
+    @Parameterized.Parameters
+    public static Collection<Object[]> instancesToTest() {
+        return Arrays.asList(
+                    new Object[]{createAndroidAssetStatement()},
+                    new Object[]{createWebSiteAssetStatement()}
+        );
+    }
+
+    private static WebSiteAssetStatement createWebSiteAssetStatement() {
+        return new WebSiteAssetStatement.Builder()
+                    .relations(relations)
+                    .webTarget(createWebTarget())
+                    .build();
+    }
+
+    private static WebTarget createWebTarget() {
+        return new WebTarget.Builder()
+                    .site("org.example")
+                    .build();
+    }
+
+    private static AndroidAssetStatement createAndroidAssetStatement() {
+        return new AndroidAssetStatement.Builder()
+                    .target(createAndroidTarget())
+                    .relations(relations)
+                    .build();
+    }
+
+    private static AndroidTarget createAndroidTarget() {
+        return new AndroidTarget.Builder()
+                    .packageName("org.example")
+                    .sha256CertFingerprint(fingerprint)
+                    .build();
+    }
+
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java
new file mode 100644
index 0000000..b0de0b0
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/AssetStatementsFactoryTest.java
@@ -0,0 +1,343 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Tests for {@link AssetStatementsFactory}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class AssetStatementsFactoryTest {
+
+    private final String fingerprint =
+                 "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03:62:87:0C:98:B0:C9" +
+                             ":E2:2A:8E:14:DF:A8";
+
+    @Test
+    public void emptyAssetStatements() {
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements("");
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void nullAssetStatements() {
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(null);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void invalidNamespace() {
+        String webStatement = String.format(SINGLE_WEB_STATEMENT, RelationType.GetLoginCreds, "foo",
+                    "https://www.example.com");
+
+        String stmtArray = statementsToJsonArray(webStatement);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements
+                    (stmtArray);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void nullNamespace() {
+        String webStatement = String.format(SINGLE_WEB_STATEMENT, RelationType.GetLoginCreds, null,
+                    "https://www.example.com");
+
+        String stmtArray = statementsToJsonArray(webStatement);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements
+                    (stmtArray);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void invalidWebStatement() {
+        String json = createWebStatementList(RelationType.GetLoginCreds.getDescription(), null, 1);
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void singleWebStatement() {
+        String site = "https://www.example.com";
+
+        String json = createWebStatementList(RelationType.GetLoginCreds.getDescription(), site, 1);
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+
+        assertTrue(list.size() == 1);
+        assertTrue(list.get(0) instanceof WebSiteAssetStatement);
+
+        WebSiteAssetStatement webSiteAssetStatement = (WebSiteAssetStatement) list.get(0);
+        assertTrue(webSiteAssetStatement.getRelations().size() == 1);
+        assertTrue(webSiteAssetStatement.getRelations().get(0) == RelationType.GetLoginCreds);
+
+        assertNotNull(webSiteAssetStatement.getTarget());
+        assertTrue(webSiteAssetStatement.getTarget().getNamespace() == NamespaceType.Web);
+        assertTrue(webSiteAssetStatement.getTarget().getSite().equals(site));
+    }
+
+    @Test
+    public void multipleWebStatements() {
+        String json = createWebStatementList(RelationType.GetLoginCreds.getDescription(),
+                "https://www.example.com", 3);
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+
+        assertTrue(list.size() == 3);
+        assertTrue(list.get(0) instanceof WebSiteAssetStatement);
+        assertTrue(list.get(1) instanceof WebSiteAssetStatement);
+        assertTrue(list.get(2) instanceof WebSiteAssetStatement);
+    }
+
+    @Test
+    public void invalidIncludeStatement_null_url() {
+        String json = createIncludeStatementList(null, 1);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void invalidIncludeStatement_invalid_url() {
+        String json = createIncludeStatementList("foo", 1);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void includeStatement() {
+        String url = "http://example.digitalassetlinks.org/.well-known/assetlinks.json";
+        String json = createIncludeStatementList(url, 1);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+
+        assertTrue(list.size() == 1);
+        assertTrue(list.get(0) instanceof IncludeStatement);
+
+        IncludeStatement includeStatement = (IncludeStatement) list.get(0);
+        assertNotNull(includeStatement.getInclude());
+        assertTrue(includeStatement.getInclude().equals(url));
+    }
+
+    @Test
+    public void singleAndroidStatement() {
+        String packageName = "org.example";
+
+        String json = createAndroidAppStatementList(RelationType.GetLoginCreds.getDescription(),
+                packageName, fingerprint, 1);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+
+        assertTrue(list.size() == 1);
+        assertTrue(list.get(0) instanceof AndroidAssetStatement);
+
+        AndroidAssetStatement androidAssetStatement = (AndroidAssetStatement) list.get(0);
+
+        assertNotNull(androidAssetStatement.getRelations());
+        assertTrue(androidAssetStatement.getRelations().size() == 1);
+        assertTrue(androidAssetStatement.getRelations().get(0) == RelationType.GetLoginCreds);
+
+        assertNotNull(androidAssetStatement.getTarget());
+        assertTrue(androidAssetStatement.getTarget().getNamespace() == NamespaceType.AndroidApp);
+        assertTrue(androidAssetStatement.getTarget().getPackageName().equals(packageName));
+        assertNotNull(androidAssetStatement.getTarget().getSha256CertFingerprint());
+        assertTrue(androidAssetStatement.getTarget().getSha256CertFingerprint().equals
+                (fingerprint));
+    }
+
+    @Test
+    public void multipleAndroidStatements() {
+        String json = createAndroidAppStatementList(RelationType.GetLoginCreds.getDescription(),
+                "org.example", fingerprint, 3);
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements(json);
+
+        assertTrue(list.size() == 3);
+
+        assertTrue(list.get(0) instanceof AndroidAssetStatement);
+        assertTrue(list.get(1) instanceof AndroidAssetStatement);
+        assertTrue(list.get(2) instanceof AndroidAssetStatement);
+    }
+
+    @Test
+    public void multipleFingerprints() {
+        String fingerprints = "00:12:" + fingerprint
+                    + "\",  \"11:12:" + fingerprint
+                    + "\", \"22:12" + fingerprint;
+
+        String stmt = createAndroidAppStatement(RelationType.GetLoginCreds.getDescription(), "org" +
+                ".example", fingerprints);
+
+        String stmtArray = statementsToJsonArray(stmt);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements
+                (stmtArray);
+
+        assertTrue(list.size() == 3);
+        assertTrue(list.get(0) instanceof AndroidAssetStatement);
+        assertTrue(list.get(1) instanceof AndroidAssetStatement);
+        assertTrue(list.get(2) instanceof AndroidAssetStatement);
+
+        assertNotNull(((AndroidAssetStatement) list.get(0)).getTarget().getSha256CertFingerprint());
+        assertNotNull(((AndroidAssetStatement) list.get(1)).getTarget().getSha256CertFingerprint());
+        assertNotNull(((AndroidAssetStatement) list.get(2)).getTarget().getSha256CertFingerprint());
+
+        assertTrue(((AndroidAssetStatement) list.get(0)).getTarget().getSha256CertFingerprint()
+                .startsWith("00:12"));
+        assertTrue(((AndroidAssetStatement) list.get(1)).getTarget().getSha256CertFingerprint()
+                .startsWith("11:12"));
+        assertTrue(((AndroidAssetStatement) list.get(2)).getTarget().getSha256CertFingerprint()
+                .startsWith("22:12"));
+    }
+
+    @Test
+    public void allStatementTypes() {
+        String site = "https://www.example.com";
+        String firstInclude = "http://example.digitalassetlinks.org/.well-known/assetlinks.json";
+        String secondInclude = "http://www.google.com/.well-known/assetlinks.json";
+
+        String fingerprints = "00:12:" + fingerprint
+                    + "\",  \"11:12:" + fingerprint
+                    + "\", \"22:12" + fingerprint;
+
+        String androidStatement = createAndroidAppStatement(RelationType.GetLoginCreds
+                .getDescription(), "org.example", fingerprints);
+        String webStatement = createWebStatement(RelationType.GetLoginCreds.getDescription(), site);
+        String firstIncludeStmt = createIncludeStatement("http://example.digitalassetlinks.org/" +
+                ".well-known/assetlinks.json");
+        String secondStmt = createIncludeStatement(secondInclude);
+
+        String stmtArray = statementsToJsonArray(androidStatement + ", " + webStatement + ", " +
+                firstIncludeStmt + ", " + secondStmt);
+
+        List<AssetStatement> list = AssetStatementsFactory.INSTANCE.createAssetStatements
+                (stmtArray);
+
+        assertTrue(list.size() == 6);
+        assertTrue(list.get(0) instanceof AndroidAssetStatement);
+        assertTrue(list.get(1) instanceof AndroidAssetStatement);
+        assertTrue(list.get(2) instanceof AndroidAssetStatement);
+        assertTrue(list.get(3) instanceof WebSiteAssetStatement);
+        assertTrue(list.get(4) instanceof IncludeStatement);
+        assertTrue(list.get(5) instanceof IncludeStatement);
+
+        assertTrue(((AndroidAssetStatement) list.get(0)).getTarget().getSha256CertFingerprint()
+                .startsWith("00:12"));
+        assertTrue(((AndroidAssetStatement) list.get(1)).getTarget().getSha256CertFingerprint()
+                .startsWith("11:12"));
+        assertTrue(((AndroidAssetStatement) list.get(2)).getTarget().getSha256CertFingerprint()
+                .startsWith("22:12"));
+
+        assertEquals(site, ((WebSiteAssetStatement) list.get(3)).getTarget().getSite());
+
+        assertEquals(firstInclude, ((IncludeStatement) list.get(4)).getInclude());
+        assertEquals(secondInclude, ((IncludeStatement) list.get(5)).getInclude());
+
+    }
+
+    private String createWebStatementList(String relation, String site, int count) {
+        String statements[] = new String[count];
+        for (int i = 0; i < count; i++) {
+            statements[i] = createWebStatement(relation, site);
+        }
+        return statementsToJsonArray(statements);
+    }
+
+    private String createAndroidAppStatementList(String relation, String packageName, String
+            fingerprint, int count) {
+        String statements[] = new String[count];
+        for (int i = 0; i < count; i++) {
+            statements[i] = createAndroidAppStatement(relation, packageName, fingerprint);
+        }
+        return statementsToJsonArray(statements);
+    }
+
+    private String createIncludeStatementList(String url, int count) {
+        String statements[] = new String[count];
+        for (int i = 0; i < count; i++) {
+            statements[i] = createIncludeStatement(url);
+        }
+        return statementsToJsonArray(statements);
+    }
+
+    private String createAndroidAppStatement(String relation, String packageName, String
+            fingerprint) {
+        return String.format(SINGLE_ANDROID_APP_STATEMENT, relation, NamespaceType.AndroidApp
+                .getDescription(), packageName, fingerprint);
+    }
+
+    private String createWebStatement(String relation, String site) {
+        return String.format(SINGLE_WEB_STATEMENT, relation, NamespaceType.Web.getDescription(),
+                site);
+    }
+
+    private String createIncludeStatement(String url) {
+        return String.format(SINGLE_INCLUDE_STATEMENT, url);
+    }
+
+    private final String SINGLE_INCLUDE_STATEMENT =
+            "{" +
+                    "\"include\": \"%s\"" +
+                    "}";
+
+    private final String SINGLE_ANDROID_APP_STATEMENT =
+            "{" +
+                    "\"relation\": [\"%s\"]," +
+                    "\"target\": {" +
+                    "\"namespace\": \"%s\"," +
+                    "\"package_name\": \"%s\"," +
+                    "\"sha256_cert_fingerprints\": [\"%s\"]" +
+                    "}" +
+                    "}";
+
+    private final String SINGLE_WEB_STATEMENT =
+            "{" +
+                    "\"relation\": [\"%s\"]," +
+                    "\"target\": {" +
+                    "\"namespace\": \"%s\"," +
+                    "\"site\": \"%s\"" +
+                    "}" +
+                    "}";
+
+    private String statementsToJsonArray(String... statements) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("[");
+        for (String statement : statements) {
+            sb.append(statement).append(",");
+        }
+        return sb.substring(0, sb.length() - 1) + "]";
+    }
+
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java
new file mode 100644
index 0000000..aa55f5d
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/DeserializerUtilTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link DeserializerUtil}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class DeserializerUtilTest {
+    @Test
+    public void getRelations() throws Exception {
+        JSONObject statement = getAssetStatement();
+        statement.getJSONArray("relation").put("delegate_permission/common.handle_all_urls");
+        statement.getJSONArray("relation").put("delegate_permission/common.get_login_creds");
+
+        final List<RelationType> relations = DeserializerUtil.getRelations(statement);
+        assertNotNull(relations);
+        assertTrue(relations.size() == 2);
+        assertTrue(relations.get(0) == RelationType.HandleAllUrls);
+        assertTrue(relations.get(1) == RelationType.GetLoginCreds);
+    }
+
+    @Test
+    public void invalidRelation() throws JSONException {
+        JSONObject statement = getAssetStatement();
+        statement.getJSONArray("relation").put("some invalid relation");
+        statement.getJSONArray("relation").put("delegate_permission/common.get_login_creds");
+
+        final List<RelationType> relations = DeserializerUtil.getRelations(statement);
+        assertNotNull(relations);
+        assertTrue(relations.size() == 1);
+        assertTrue(relations.get(0) == RelationType.GetLoginCreds);
+    }
+
+    @Test
+    public void emptyRelations() throws JSONException {
+        JSONObject statement = getAssetStatement();
+
+        final List<RelationType> relations = DeserializerUtil.getRelations(statement);
+        assertNotNull(relations);
+        assertTrue(relations.isEmpty());
+    }
+
+    private JSONObject getAssetStatement() throws JSONException {
+        JSONObject statement = new JSONObject();
+        JSONArray relationsJson = new JSONArray();
+        statement.put("relation", relationsJson);
+        return statement;
+    }
+
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java
new file mode 100644
index 0000000..65e6b7d
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeAssetStatementDeserializerTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+import org.json.JSONObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.List;
+
+/**
+ * Tests for {@link IncludeAssetStatementDeserializer}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class IncludeAssetStatementDeserializerTest {
+
+    @Test(expected = RequireViolation.class)
+    public void testNullJson() {
+        new IncludeAssetStatementDeserializer().deserialize(null);
+    }
+
+    @Test
+    public void testNoTarget() {
+        JSONObject json = new JSONObject();
+        final List<IncludeStatement> assetStatements = new IncludeAssetStatementDeserializer()
+                    .deserialize(json);
+        assertNotNull(assetStatements);
+        assertTrue(assetStatements.isEmpty());
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java
new file mode 100644
index 0000000..ef4123b
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/IncludeStatementTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Tests for {@link IncludeStatement}
+ */
+public class IncludeStatementTest {
+
+    @Test (expected = RequireViolation.class)
+    public void testNullSite() {
+        new IncludeStatement.Builder()
+                    .build();
+    }
+
+    @Test
+    public void testIncludeSite() {
+        final String url = "http://example.digitalassetlinks.org/.well-known/assetlinks.json";
+        final IncludeStatement statement = new IncludeStatement.Builder()
+                    .url(url)
+                    .build();
+        assertNotNull(statement);
+        assertEquals(url, statement.getInclude());
+        assertNotNull(statement.getRelations());
+        assertTrue(statement.getRelations().isEmpty());
+    }
+
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java
new file mode 100644
index 0000000..847eb8f
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/NamespaceTypeTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Tests for {@link NamespaceType}.
+ */
+public class NamespaceTypeTest {
+    @Test
+    public void androidAppTest() {
+        final NamespaceType namespaceType = NamespaceType.getNamespaceType
+                    ("android_app");
+        assertNotNull(namespaceType);
+        assertTrue(namespaceType == NamespaceType.AndroidApp);
+    }
+
+    @Test
+    public void webTest() {
+        final NamespaceType namespaceType = NamespaceType.getNamespaceType
+                    ("web");
+        assertNotNull(namespaceType);
+        assertTrue(namespaceType == NamespaceType.Web);
+    }
+
+    @Test
+    public void invalidRelationType() {
+        final NamespaceType namespaceType = NamespaceType.getNamespaceType
+                    ("foo");
+        assertNull(namespaceType);
+    }
+
+    @Test
+    public void nullInput() {
+        final NamespaceType namespaceType = NamespaceType.getNamespaceType
+                    (null);
+        assertNull(namespaceType);
+    }
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java
new file mode 100644
index 0000000..624fa0a
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/RelationTypeTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+public class RelationTypeTest {
+    @Test
+    public void loginCredsTest() {
+        final RelationType relationType = RelationType.getRelationType
+                    ("delegate_permission/common.get_login_creds");
+        assertNotNull(relationType);
+        assertTrue(relationType == RelationType.GetLoginCreds);
+    }
+
+    @Test
+    public void handleUrlsTest() {
+        final RelationType relationType = RelationType.getRelationType
+                    ("delegate_permission/common.handle_all_urls");
+        assertNotNull(relationType);
+        assertTrue(relationType == RelationType.HandleAllUrls);
+    }
+
+    @Test
+    public void invalidRelationType() {
+        final RelationType relationType = RelationType.getRelationType
+                    ("something invalid");
+        assertNull(relationType);
+    }
+
+    @Test
+    public void nullInput() {
+        final RelationType relationType = RelationType.getRelationType
+                    (null);
+        assertNull(relationType);
+    }
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java
new file mode 100644
index 0000000..40bba93
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebAssetStatementDeserializerTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+import org.json.JSONObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.List;
+
+/**
+ * Tests for {@link WebAssetStatementDeserializer}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class WebAssetStatementDeserializerTest {
+
+    @Test(expected = RequireViolation.class)
+    public void testNullJson() {
+        new WebAssetStatementDeserializer().deserialize(null);
+    }
+
+    @Test
+    public void testNoTarget() {
+        JSONObject json = new JSONObject();
+        final List<WebSiteAssetStatement> assetStatements = new WebAssetStatementDeserializer()
+                    .deserialize(json);
+        assertNotNull(assetStatements);
+        assertTrue(assetStatements.isEmpty());
+    }
+
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java
new file mode 100644
index 0000000..9bec98e
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebSiteAssetStatementTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.Arrays;
+
+/**
+ * Test for {@link WebSiteAssetStatement}
+ */
+public class WebSiteAssetStatementTest {
+
+    @Test (expected = RequireViolation.class)
+    public void testNullTarget() {
+        new WebSiteAssetStatement.Builder()
+                    .relations(Arrays.asList(RelationType.GetLoginCreds))
+                    .build();
+    }
+
+    @Test (expected = RequireViolation.class)
+    public void testNullRelations() {
+        new WebSiteAssetStatement.Builder()
+                    .webTarget(createWebTarget())
+                    .build();
+    }
+
+    private WebTarget createWebTarget() {
+        return new WebTarget.Builder()
+                    .site("org.example")
+                    .build();
+    }
+
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebTargetTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebTargetTest.java
new file mode 100644
index 0000000..22ef664
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/data/WebTargetTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.data;
+
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Tests for {@link WebTarget}
+ */
+public class WebTargetTest {
+    @Test (expected = RequireViolation.class)
+    public void testNullSite() {
+        new WebTarget.Builder()
+                    .build();
+    }
+}
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java
new file mode 100644
index 0000000..726c0ca
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAndroidAssetStatementLoaderTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.openyolo.spi.assetlinks.loader;
+
+import org.junit.Test;
+import org.openyolo.spi.assetlinks.data.AndroidAssetStatement;
+import org.openyolo.spi.assetlinks.data.AndroidTarget;
+import org.openyolo.spi.assetlinks.data.AssetStatement;
+import org.openyolo.spi.assetlinks.data.RelationType;
+import org.openyolo.spi.assetlinks.data.WebSiteAssetStatement;
+import org.openyolo.spi.assetlinks.data.WebTarget;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.*;
+import static org.openyolo.spi.assetlinks.data.RelationType.GetLoginCreds;
+import static org.openyolo.spi.assetlinks.data.RelationType.HandleAllUrls;
+
+/**
+ * Tests for {@link TargetAndroidAssetStatementLoader}.
+ */
+public class TargetAndroidAssetStatementLoaderTest {
+    @Test
+    public void containsRelation() throws Exception {
+        AndroidTarget androidTarget = createAndroidTarget
+                     ("org.example", "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03" +
+                                 ":62:87:0C:98:B0:C9:E2:2A:8E:14:DF:A8");
+
+        final AndroidAssetStatement assetStatement = new AndroidAssetStatement.Builder()
+                    .relations(Arrays.asList(GetLoginCreds, HandleAllUrls))
+                    .target(androidTarget)
+                    .build();
+
+        final boolean containsRelation = TargetAndroidAssetStatementLoader.containsRelation
+                    (assetStatement, GetLoginCreds);
+
+        assertTrue(containsRelation);
+    }
+
+    @Test
+    public void filterAssetStatementsByRelation() throws Exception {
+        AndroidTarget androidTarget1 = createAndroidTarget
+                    ("org.example", "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03" +
+                                ":62:87:0C:98:B0:C9:E2:2A:8E:14:DF:A8");
+        final AssetStatement assetStmt1 = createAndroidAssetStatement(Arrays.asList
+                    (GetLoginCreds, HandleAllUrls), androidTarget1);
+
+        AndroidTarget androidTarget2 = createAndroidTarget
+                    ("foo.example", "03:9F:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03" +
+                                ":62:87:0C:98:B0:C9:E2:2A:8E:14:DF:A8");
+        final AssetStatement assetStmt2 = createAndroidAssetStatement(Arrays.asList
+                    (HandleAllUrls), androidTarget2);
+
+        List<AssetStatement> assetStatements = Arrays.asList(assetStmt1,
+                    assetStmt2);
+
+        final List<AssetStatement> filteredStmts = TargetAndroidAssetStatementLoader
+                    .filterAssetStatements(assetStatements, GetLoginCreds);
+
+        assertNotNull(filteredStmts);
+        assertTrue(filteredStmts.size() == 1);
+        assertTrue(filteredStmts.get(0).getRelations().contains(GetLoginCreds));
+    }
+
+    @Test
+    public void filterAssetStatementsByType() throws Exception {
+        AndroidTarget androidTarget = createAndroidTarget
+                    ("org.example", "D5:03:9F:44:48:4A:70:C9:0A:AC:1D:3A:A7:67:07:EE:B8:BF:52:03" +
+                                ":62:87:0C:98:B0:C9:E2:2A:8E:14:DF:A8");
+
+        final AndroidAssetStatement assetStatement = new AndroidAssetStatement.Builder()
+                    .relations(Arrays.asList(GetLoginCreds, HandleAllUrls))
+                    .target(androidTarget)
+                    .build();
+
+        final WebTarget webTarget = createWebTarget("com.example");
+        final AssetStatement webAssetStatement = createWebAssetStatement(webTarget,
+                    Arrays.asList(GetLoginCreds, HandleAllUrls));
+
+        List<AssetStatement> assetStatements = Arrays.asList(assetStatement,
+                    webAssetStatement);
+
+        final List<AssetStatement> filteredStmts = TargetAndroidAssetStatementLoader
+                    .filterAssetStatements(assetStatements,
+                    AndroidAssetStatement.class);
+
+        assertNotNull(filteredStmts);
+        assertTrue(filteredStmts.size() == 1);
+        assertTrue(filteredStmts.get(0) instanceof AndroidAssetStatement);
+    }
+
+    private WebTarget createWebTarget(String site) {
+        return new WebTarget.Builder()
+                    .site(site)
+                    .build();
+    }
+
+    private AndroidTarget createAndroidTarget(String packageName, String fingerprint) {
+        return new AndroidTarget.Builder()
+                    .packageName(packageName)
+                    .sha256CertFingerprint(fingerprint)
+                    .build();
+    }
+
+    private AssetStatement createAndroidAssetStatement(List<RelationType> relations,
+                AndroidTarget androidTarget) {
+        return new AndroidAssetStatement.Builder()
+                    .relations(relations)
+                    .target(androidTarget)
+                    .build();
+    }
+
+    private AssetStatement createWebAssetStatement(WebTarget webTarget, List<RelationType> relations) {
+        return new WebSiteAssetStatement.Builder()
+                    .webTarget(webTarget)
+                    .relations(relations)
+                    .build();
+    }
+}
\ No newline at end of file
diff --git a/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java
new file mode 100644
index 0000000..4ae3b93
--- /dev/null
+++ b/spi/javatests/java/org/openyolo/spi/assetlinks/loader/TargetAssetStatementLoaderTest.java
@@ -0,0 +1,55 @@
+
+
+/*
+ * Copyright 2016 The OpenYOLO Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openyolo.spi.assetlinks.loader;
+
+import android.content.Context;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.openyolo.spi.assetlinks.data.AssetStatement;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.valid4j.errors.RequireViolation;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for {@link TargetAssetStatementLoader}.
+ */
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class TargetAssetStatementLoaderTest {
+
+    @Mock
+    Context mockContext;
+
+    private final List<AssetStatement> assetStatements = Collections.emptyList();
+
+    @Test (expected = RequireViolation.class)
+    public void testNullContext() {
+        new TargetAssetStatementLoader(null, assetStatements);
+    }
+
+    @Test (expected = RequireViolation.class)
+    public void testNullAssetStatements() {
+        new TargetAssetStatementLoader(mockContext, null);
+    }
+}
diff --git a/spi/proguard-rules.txt b/spi/proguard-rules.txt
new file mode 100644
index 0000000..7188697
--- /dev/null
+++ b/spi/proguard-rules.txt
@@ -0,0 +1,2 @@
+# it is safe to ignore okio warnings
+-dontwarn okio.**
\ No newline at end of file
